Merge pull request #32606 from DaanDeMeyer/mkosi

mkosi: Enable more integration tests
This commit is contained in:
Daan De Meyer
2024-05-06 13:11:43 +02:00
committed by GitHub
54 changed files with 383 additions and 196 deletions

View File

@@ -71,7 +71,7 @@ jobs:
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- uses: systemd/mkosi@5329eb0fe823634fe57daddce88ae8ccddfe3364
- uses: systemd/mkosi@22d212dcb229b553572578ef16c809f9a9961ee8
# Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space
# immediately, we remove the files in the background. However, we first move them to a different location
@@ -121,8 +121,6 @@ jobs:
[Host]
ToolsTree=default
ToolsTreeDistribution=fedora
QemuVsock=yes
QemuKvm=yes
# TODO: Drop once https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2038777 is fixed in Github Actions
QemuFirmware=uefi
EOF
@@ -132,8 +130,6 @@ jobs:
tee mkosi.conf.d/99-ci.conf <<EOF
[Host]
KernelCommandLineExtra=
# udev's debug log output is very verbose, so up it to info in CI.
udev.log_level=info
# Root device can take a long time to appear, so let's bump the timeout.
systemd.default_device_timeout_sec=180
EOF
@@ -173,7 +169,7 @@ jobs:
-Dtpm2=enabled \
-Dlibcryptsetup=enabled \
-Dlibcurl=enabled \
-Drepart=enabled \
-Drepart=disabled \
-Dfirstboot=true \
-Dsysusers=true \
-Dtmpfiles=true \
@@ -184,7 +180,7 @@ jobs:
run: meson compile -C build mkosi
- name: Run integration tests
run: meson test -C build --no-rebuild --suite integration-tests --print-errorlogs --no-stdsplit
run: meson test -C build --no-rebuild --suite integration-tests --print-errorlogs --no-stdsplit --num-processes "$(($(nproc) - 1))"
- name: Archive failed test journals
uses: actions/upload-artifact@v4

View File

@@ -27,7 +27,8 @@ $ git config submodule.recurse true
$ git config fetch.recurseSubmodules on-demand
$ git config push.recurseSubmodules no
$ cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
$ cp tools/git-post-rewrite-hook.sh .git/hooks/post-rewrite
$ cp tools/git-submodule-update-hook.sh .git/hooks/post-rewrite
$ cp tools/git-submodule-update-hook.sh .git/hooks/post-checkout
```
Please always test your work before submitting a PR.

View File

@@ -319,9 +319,9 @@ userspace_c_ld_args = []
meson_build_sh = find_program('tools/meson-build.sh')
want_tests = get_option('tests')
slow_tests = want_tests != 'false' and get_option('slow-tests')
fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
integration_tests = want_tests != 'false' and get_option('integration-tests')
want_slow_tests = want_tests != 'false' and get_option('slow-tests')
want_fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
want_integration_tests = want_tests != 'false' and get_option('integration-tests')
install_tests = want_tests != 'false' and get_option('install-tests')
if add_languages('cpp', native : false, required : fuzzer_build)
@@ -1684,7 +1684,7 @@ conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesync
conf.set10('ENABLE_SSH_PROXY_CONFIG', sshconfdir != 'no')
conf.set10('ENABLE_SSH_USERDB_CONFIG', conf.get('ENABLE_USERDB') == 1 and sshdconfdir != 'no')
conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', want_slow_tests)
#####################################################################
@@ -2594,7 +2594,7 @@ endif
#####################################################################
mkosi = find_program('mkosi', required : false)
if integration_tests and not mkosi.found()
if want_integration_tests and not mkosi.found()
error('Could not find mkosi which is required to run the integration tests')
endif
@@ -2619,7 +2619,6 @@ if mkosi.found()
'--cache-dir', meson.current_build_dir() / 'mkosi.cache',
'--build-dir', meson.current_build_dir() / 'mkosi.builddir',
'--force',
'--debug',
'build',
],
depends : mkosi_depends,
@@ -2730,7 +2729,7 @@ foreach tuple : fuzz_sanitizers
message('Not compiling @0@ because tests is set to false'.format(name))
continue
endif
if not fuzz_tests
if not want_fuzz_tests
message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
continue
endif
@@ -3029,8 +3028,8 @@ foreach tuple : [
['debug mmap cache'],
['debug siphash'],
['trace logging', conf.get('LOG_TRACE') == 1],
['slow tests', slow_tests],
['fuzz tests', fuzz_tests],
['slow tests', want_slow_tests],
['fuzz tests', want_fuzz_tests],
['install tests', install_tests],
['link-udev-shared', get_option('link-udev-shared')],
['link-systemctl-shared', get_option('link-systemctl-shared')],

View File

@@ -41,4 +41,7 @@ Credentials=journal.storage=persistent
@Incremental=yes
@RuntimeBuildSources=yes
@QemuSmp=2
@QemuSwtpm=yes
@QemuVsock=yes
@QemuKvm=yes
ToolsTreePackages=virtiofsd

View File

@@ -8,3 +8,6 @@ Distribution=centos
Repositories=epel
epel-next
hyperscale-packages-main
[Content]
Environment=SYSTEMD_REPART_MKFS_OPTIONS_EXT4="-O ^orphan_file"

View File

@@ -2,6 +2,7 @@
[Config]
Dependencies=
minimal-base
minimal-0
minimal-1
@@ -39,6 +40,7 @@ Packages=
kbd
kexec-tools
kmod
knot
less
man
mtools

View File

@@ -13,6 +13,7 @@ VolatilePackages=
systemd-ukify
Packages=
bind
bpf
btrfs-progs
compsize
@@ -41,6 +42,7 @@ Packages=
sbsigntools
shadow
squashfs-tools
stress
tpm2-tools
tpm2-tss
vim

View File

@@ -21,8 +21,10 @@ VolatilePackages=
systemd-ukify
Packages=
bind-utils
bpftool
cryptsetup
dfuzzer
dhcp-server
dnf
git-core
@@ -51,9 +53,12 @@ Packages=
rpm
rpm-build
rpmautospec
sbsigntools
squashfs-tools
stress
tpm2-tools
util-linux
veritysetup
vim-common
InitrdPackages=

View File

@@ -40,6 +40,10 @@ EOF
cat debian/changelog >>debian/changelog.new
mv debian/changelog.new debian/changelog
# FIXME: Remove after tmp.mount is kept intact in the debian packaging for UPSTREAM=1 builds.
sed --in-place '/tmp.mount/d' debian/rules
sed --in-place '/tmp.mount/d' debian/not-installed
build() {
DEB_BUILD_OPTIONS=$(awk '$1=$1' <<<"\
$( ((WITH_TESTS)) || echo nocheck) \

View File

@@ -36,6 +36,7 @@ Packages=
^libtss2-mu-[0-9.]+-0$
^libubsan[0-9]+$
apt
bind9-dnsutils
btrfs-progs
cryptsetup-bin
dbus-broker
@@ -63,6 +64,7 @@ Packages=
quota
sbsigntool
squashfs-tools
stress
tpm2-tools
tzdata
xxd

View File

@@ -8,8 +8,6 @@ Packages=
btrfs-progs
compsize
f2fs-tools
glibc-langpack-en
sbsigntools
dnf5
InitrdPackages=

View File

@@ -25,6 +25,7 @@ VolatilePackages=
# We install gawk, gzip, grep, xz, sed, rsync and docbook-xsl-stylesheets here explicitly so that the busybox
# versions don't get installed instead.
Packages=
bind-utils
bpftool
btrfs-progs
cryptsetup
@@ -69,6 +70,7 @@ Packages=
user(games)
user(nobody)
user(root)
veritysetup
vim
xz

View File

@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<!--
SPDX-License-Identifier: LGPL-2.1-or-later
-->
<busconfig>
<policy user="root">
<allow own="systemd.test.ExecStopPost"/>
</policy>
</busconfig>

View File

@@ -72,3 +72,9 @@ done
# We want /var/log/journal to be created on first boot so it can be created with the right chattr settings by
# systemd-journald.
rm -r "$BUILDROOT/var/log/journal"
rm -f /etc/nsswitch.conf
cp "$SRCDIR/factory/etc/nsswitch.conf" /etc/nsswitch.conf
# Remove to make TEST-73-LOCALE pass on Ubuntu.
rm -f /etc/default/keyboard

View File

@@ -14,8 +14,7 @@ test_env = environment()
test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map)
test_env.set('PATH', project_build_root + ':' + path)
test_env.set('PROJECT_BUILD_ROOT', project_build_root)
test_env.set('SYSTEMD_SLOW_TESTS', slow_tests ? '1' : '0')
test_env.set('SYSTEMD_INTEGRATION_TESTS', integration_tests ? '1' : '0')
test_env.set('SYSTEMD_SLOW_TESTS', want_slow_tests ? '1' : '0')
if efi_addon != ''
test_env.set('EFI_ADDON', efi_addon)

View File

@@ -1,3 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'mkosi_args': test_params['mkosi_args'] + [
'--kernel-command-line-extra=' + ' '.join([

View File

@@ -0,0 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'storage': 'persistent',
}

View File

@@ -2,4 +2,6 @@
test_params += {
'mkosi_args' : ['--kernel-command-line-extra=apparmor=0 selinux=1 enforcing=0 lsm=selinux systemd.wants=autorelabel.service systemd.wants=firstboot-autorelabel.service'],
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
'firmware' : 'uefi',
}

View File

@@ -11,31 +11,6 @@ NSPAWN_ARGUMENTS="--capability=CAP_NET_ADMIN"
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
local workspace="${1:?}"
# We might not be fast enough to hit the limit (20 triggers per 2 secs)
# in certain environments, i.e. when running without KVM or when collecting
# coverage. Let's help it a bit in such case.
if ! get_bool "$QEMU_KVM" || get_bool "$IS_BUILT_WITH_COVERAGE"; then
mkdir -p "$workspace/etc/systemd/system/issue2467.socket.d"
printf "[Socket]\nTriggerLimitIntervalSec=10\n" >"$workspace/etc/systemd/system/issue2467.socket.d/TriggerLimitInterval.conf"
fi
# Issue: https://github.com/systemd/systemd/issues/2730
mkdir -p "$workspace/etc/systemd/system/"
cat >"$workspace/etc/systemd/system/issue2730.mount" <<EOF
[Mount]
What=tmpfs
Where=/issue2730
Type=tmpfs
[Install]
WantedBy=local-fs.target
Alias=issue2730-alias.mount
EOF
"${SYSTEMCTL:?}" enable --root="$workspace" issue2730.mount
ln -svrf "$workspace/etc/systemd/system/issue2730.mount" "$workspace/etc/systemd/system/issue2730-alias.mount"
image_install logger socat
}

View File

@@ -1,5 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params = test_params + {
test_params += {
'storage': 'persistent',
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
'firmware' : 'uefi',
}

View File

@@ -0,0 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
'firmware' : 'uefi',
}

View File

@@ -0,0 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params = test_params + {
'timeout' : 3600,
'priority': -50,
}

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'mkosi_args' : test_params['mkosi_args'] + [
'--configure-script', meson.current_source_dir() / 'mkosi.configure',
],
}

View File

@@ -0,0 +1,6 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
RTC="$(date -u +%Y-%m-%dT%H:%M:%S -d "+3 days")"
jq ".QemuArgs += [\"-rtc\", \"base=$RTC\"]"

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'mkosi_args' : test_params['mkosi_args'] + [
'--credential=@0@'.format(meson.current_source_dir() / 'systemd.unit-dropin.init.scope')
]
}

View File

@@ -0,0 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Scope]
MemoryHigh=infinity
StartupMemoryHigh=10G

View File

@@ -0,0 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'storage': 'persistent',
}

View File

@@ -11,14 +11,7 @@ NSPAWN_ARGUMENTS="--private-network"
test_require_bin knotd
# We need at least Knot 3.0 which support (among others) the ds-push directive
if ! knotc -c "${TEST_BASE_DIR:?}/knot-data/knot.conf" conf-check; then
echo "This test requires at least Knot 3.0. skipping..."
exit 0
fi
test_append_files() {
local workspace="${1:?}"
# Install knot
image_install kzonecheck keymgr kjournalprint knotc knotd
image_install "${ROOTLIBDIR:?}/system/knot.service"
@@ -26,14 +19,6 @@ test_append_files() {
image_install -o /etc/dbus-1/system.d/cz.nic.knotd.conf
image_install -o /etc/default/knot
# Copy over our configuration
mkdir -p "${workspace:?}/var/lib/knot/zones/" "${workspace:?}/etc/knot/"
cp -rfv "${TEST_BASE_DIR:?}"/knot-data/zones/* "$workspace/var/lib/knot/zones/"
cp -fv "${TEST_BASE_DIR:?}/knot-data/knot.conf" "$workspace/etc/knot/knot.conf"
chgrp -R knot "$workspace/etc/knot/" "$workspace/var/lib/knot/"
chmod -R ug+rwX "$workspace/var/lib/knot/"
chmod -R g+r "$workspace/etc/knot/"
# Install DNS-related utilities (usually found in the bind-utils package)
image_install delv dig host nslookup

View File

@@ -48,9 +48,11 @@ def main():
parser.add_argument('--test-name', required=True)
parser.add_argument('--test-number', required=True)
parser.add_argument('--storage', required=True)
parser.add_argument('--firmware', required=True)
parser.add_argument('mkosi_args', nargs="*")
args = parser.parse_args()
name = args.test_name + (f"-{i}" if (i := os.getenv("MESON_TEST_ITERATION")) else "")
test_unit = f"testsuite-{args.test_number}.service"
dropin = textwrap.dedent(
@@ -58,34 +60,49 @@ def main():
[Unit]
After=multi-user.target network.target
Requires=multi-user.target
SuccessAction=exit
SuccessActionExitStatus=123
[Service]
StandardOutput=journal+console
"""
)
if os.getenv("TEST_MATCH_SUBTEST"):
dropin += textwrap.dedent(
f"""
[Service]
Environment=TEST_MATCH_SUBTEST={os.environ["TEST_MATCH_SUBTEST"]}
"""
)
if os.getenv("TEST_MATCH_TESTCASE"):
dropin += textwrap.dedent(
f"""
[Service]
Environment=TEST_MATCH_TESTCASE={os.environ["TEST_MATCH_TESTCASE"]}
"""
)
if not sys.stderr.isatty():
dropin += textwrap.dedent(
"""
[Unit]
SuccessAction=exit
SuccessActionExitStatus=123
FailureAction=exit
"""
)
journal_file = (args.meson_build_dir / (f"test/journal/{args.test_name}.journal")).absolute()
journal_file = (args.meson_build_dir / (f"test/journal/{name}.journal")).absolute()
journal_file.unlink(missing_ok=True)
else:
journal_file = None
cmd = [
'mkosi',
'--debug',
'--directory', os.fspath(args.meson_source_dir),
'--output-dir', os.fspath(args.meson_build_dir / 'mkosi.output'),
'--extra-search-path', os.fspath(args.meson_build_dir),
'--machine', args.test_name,
'--machine', name,
'--ephemeral',
*(['--forward-journal', journal_file] if journal_file else []),
*(
@@ -103,6 +120,7 @@ def main():
'--runtime-network=none',
'--runtime-scratch=no',
'--append',
'--qemu-firmware', args.firmware,
'--kernel-command-line-extra',
' '.join([
'systemd.hostname=H',
@@ -120,14 +138,14 @@ def main():
else []
),
]),
'--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}" ,
'--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}",
*args.mkosi_args,
'qemu',
]
result = subprocess.run(cmd)
# Return code 123 is the expected success code
if result.returncode != (0 if sys.stderr.isatty() else 123):
if result.returncode != 123:
if result.returncode != 77 and journal_file:
cmd = [
'journalctl',

View File

@@ -4,6 +4,7 @@ if install_tests
foreach subdir : [
'auxv',
'journal-data',
'knot-data',
'test-journals',
'units',
'test-execute',
@@ -24,21 +25,29 @@ if install_tests
'testsuite-63.units',
'testsuite-80.units',
]
# install_subdir() does not handle symlinks correctly which causes a very ugly warning when
# installing, so if rsync is available we use that instead. TODO: switch to the new option
# 'follow_symlinks' once we require Meson 1.3.0 or greater, see:
# https://github.com/mesonbuild/meson/commit/0af126fec798d6dbb0d1ad52168cc1f3f1758acd
if rsync.found()
rsync_r = rsync.full_path() + ' -rLpt --exclude .gitattributes -- "@0@" "${DESTDIR:-}@1@"'
# install_subdir() before meson 1.3.0 does not handle symlinks correctly (it follows them
# instead of copying the symlink) so we use rsync instead.
if meson.version().version_compare('<1.3.0')
if not rsync.found()
error('rsync is required to install the integration test data')
endif
rsync_r = rsync.full_path() + ' -rlpt --exclude .gitattributes --exclude 25-default.link -- "@0@" "${DESTDIR:-}@1@"'
meson.add_install_script(sh, '-c',
rsync_r.format(meson.current_source_dir() / subdir, testdata_dir))
else
install_subdir(subdir,
exclude_files : '.gitattributes',
install_dir : testdata_dir)
exclude_files : ['.gitattributes', '25-default.link'],
install_dir : testdata_dir,
follow_symlinks : false)
endif
endforeach
# test-network/conf/25-default.link is a local symlink that becomes dangling when installed, so we
# exclude it and create the correct symlink here.
meson.add_install_script(sh, '-c', ln_s.format(networkdir / '99-default.link',
testdata_dir / 'test-network/conf/25-default.link'))
install_data(kbd_model_map,
install_dir : testdata_dir + '/test-keymap-util')
@@ -339,27 +348,27 @@ integration_tests = {
'01': 'TEST-01-BASIC',
'02': 'TEST-02-UNITTESTS',
'03': 'TEST-03-JOBS',
# '04': 'TEST-04-JOURNAL', # Extremely flaky
'04': 'TEST-04-JOURNAL',
'05': 'TEST-05-RLIMITS',
'06': 'TEST-06-SELINUX',
# '07': 'TEST-07-PID1',
'07': 'TEST-07-PID1',
# '08': 'TEST-08-INITRD',
'09': 'TEST-09-REBOOT',
'13': 'TEST-13-NSPAWN',
'15': 'TEST-15-DROPIN',
'16': 'TEST-16-EXTEND-TIMEOUT',
'17': 'TEST-17-UDEV', # Can be flaky when overloaded if timeout abort test is slow
'17': 'TEST-17-UDEV',
'18': 'TEST-18-FAILUREACTION',
'19': 'TEST-19-CGROUP',
# '21': 'TEST-21-DFUZZER',
'21': 'TEST-21-DFUZZER',
'22': 'TEST-22-TMPFILES',
# '23': 'TEST-23-UNIT-FILE',
'23': 'TEST-23-UNIT-FILE',
# '24': 'TEST-24-CRYPTSETUP',
'25': 'TEST-25-IMPORT',
'26': 'TEST-26-SYSTEMCTL',
'29': 'TEST-29-PORTABLE',
'30': 'TEST-30-ONCLOCKCHANGE',
# '31': 'TEST-31-DEVICE-ENUMERATION',
'31': 'TEST-31-DEVICE-ENUMERATION',
'32': 'TEST-32-OOMPOLICY',
'34': 'TEST-34-DYNAMICUSERMIGRATE',
'35': 'TEST-35-LOGIN',
@@ -368,29 +377,29 @@ integration_tests = {
'43': 'TEST-43-PRIVATEUSER-UNPRIV',
'44': 'TEST-44-LOG-NAMESPACE',
'45': 'TEST-45-TIMEDATE',
# '46': 'TEST-46-HOMED',
'46': 'TEST-46-HOMED',
'50': 'TEST-50-DISSECT',
# '52': 'TEST-52-HONORFIRSTSHUTDOWN',
# '53': 'TEST-53-ISSUE-16347',
'52': 'TEST-52-HONORFIRSTSHUTDOWN',
'53': 'TEST-53-ISSUE-16347',
# '54': 'TEST-54-CREDS',
# '55': 'TEST-55-OOMD',
# '58': 'TEST-58-REPART',
# Can be flaky when overloaded if daemon-reload is too slow to be rate-limited
'55': 'TEST-55-OOMD',
'58': 'TEST-58-REPART',
'59': 'TEST-59-RELOADING-RESTART',
'60': 'TEST-60-MOUNT-RATELIMIT',
'62': 'TEST-62-RESTRICT-IFACES',
'63': 'TEST-63-PATH',
# '64': 'TEST-54-UDEV-STORAGE',
# '64': 'TEST-64-UDEV-STORAGE',
'65': 'TEST-65-ANALYZE',
'66': 'TEST-66-DEVICE-ISOLATION',
'67': 'TEST-67-INTEGRITY',
'68': 'TEST-68-PROPAGATE-EXIT-STATUS',
# '69': 'TEST-69-SHUTDOWN',
'70': 'TEST-70-TPM2',
'71': 'TEST-71-HOSTNAME',
'72': 'TEST-72-SYSUPDATE',
# '73': 'TEST-73-LOCALE',
# '74': 'TEST-74-AUX-UTILS',
# '75': 'TEST-75-RESOLVED',
'73': 'TEST-73-LOCALE',
'74': 'TEST-74-AUX-UTILS',
'75': 'TEST-75-RESOLVED',
'76': 'TEST-76-SYSCTL',
'78': 'TEST-78-SIGQUEUE',
'79': 'TEST-79-MEMPRESS',
@@ -404,7 +413,9 @@ foreach test_number, dirname : integration_tests
test_params = {
'mkosi_args' : [],
'timeout' : 1800,
'storage': 'volatile',
'storage' : 'volatile',
'priority' : 0,
'firmware' : 'linux',
}
# TODO: This fs.exists call isn't included in rebuild logic
@@ -420,16 +431,24 @@ foreach test_number, dirname : integration_tests
'--test-name', dirname,
'--test-number', test_number,
'--storage', test_params['storage'],
'--firmware', test_params['firmware'],
'--',
] + test_params['mkosi_args']
integration_test_env = {}
if want_integration_tests
integration_test_env = {'SYSTEMD_INTEGRATION_TESTS': '1'}
endif
# We don't explicitly depend on the "mkosi" target because that means the image is rebuilt
# on every "ninja -C build". Instead, the mkosi target has to be rebuilt manually before
# running the integration tests with mkosi.
test(dirname,
integration_test_wrapper,
env: test_env,
args : args,
timeout : test_params['timeout'],
suite : 'integration-tests')
integration_test_wrapper,
env : integration_test_env,
args : args,
timeout : test_params['timeout'],
priority : test_params['priority'],
suite : 'integration-tests')
endforeach

View File

@@ -3,4 +3,9 @@
Description=Verbose successful service
[Service]
ExecStart=/bin/echo success
Type=oneshot
# Sleep so that the cgroup is still there when journald processes the log message which is required for
# journald to add the expected fields to the log message.
ExecStart=sleep 2
ExecStart=echo success
ExecStart=sleep 2

View File

@@ -1,3 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Socket]
ListenStream=/run/test.ctl
# We might not be fast enough to hit the default limit (20 triggers per 2 secs)
# in certain environments, i.e. when running without KVM or when collecting
# coverage. Let's help it a bit in such cases by lowering the limit to 10 seconds.
TriggerLimitIntervalSec=10

View File

@@ -0,0 +1 @@
issue2730.mount

View File

@@ -0,0 +1,8 @@
[Mount]
What=tmpfs
Where=/issue2730
Type=tmpfs
[Install]
WantedBy=local-fs.target
Alias=issue2730-alias.mount

View File

@@ -0,0 +1 @@
../issue2730.mount

View File

@@ -4,7 +4,12 @@ set -eux
set -o pipefail
if systemd-detect-virt -cq; then
echo "This test requires a VM, skipping the test"
echo "This test requires a VM, skipping the test" | tee --append /skipped
exit 0
fi
if [[ ! -x /usr/lib/systemd/systemd-bsod ]]; then
echo "systemd-bsod is not installed, skipping the test" | tee --append /skipped
exit 0
fi

View File

@@ -109,13 +109,12 @@ journalctl --sync
# Test syslog identifiers exclusion
systemctl start verbose-success.service
timeout 30 bash -xec 'while systemctl -q is-active verbose-success.service; do sleep 1; done'
journalctl --sync
[[ -n "$(journalctl -b -q -u verbose-success.service -t systemd)" ]]
[[ -n "$(journalctl -b -q -u verbose-success.service -t echo)" ]]
[[ -n "$(journalctl -b -q -u verbose-success.service -T systemd)" ]]
[[ -n "$(journalctl -b -q -u verbose-success.service -T echo)" ]]
[[ -z "$(journalctl -b -q -u verbose-success.service -T echo -T '(echo)' -T systemd -T '(systemd)' -T systemd-executor)" ]]
[[ -z "$(journalctl -b -q -u verbose-success.service -T echo -T '(echo)' -T sleep -T '(sleep)' -T systemd -T '(systemd)' -T systemd-executor)" ]]
# Exercise the matching machinery
SYSTEMD_LOG_LEVEL=debug journalctl -b -n 1 /dev/null /dev/zero /dev/null /dev/null /dev/null
@@ -263,7 +262,7 @@ UNIT_NAME="test-cursor-$RANDOM.service"
CURSOR_FILE="$(mktemp)"
# Generate some messages we can match against
journalctl --cursor-file="$CURSOR_FILE" -n1
systemd-run --unit="$UNIT_NAME" --wait --service-type=exec bash -xec "echo hello; echo world"
systemd-run --unit="$UNIT_NAME" --wait --service-type=exec bash -ec "sleep 2; set -x; echo hello; echo world; set +x; sleep 2"
journalctl --sync
# --after-cursor= + --unit=
# The format of the "Starting ..." message depends on StatusUnitFormat=, so match only the beginning
@@ -277,6 +276,7 @@ diff <(journalctl --cursor-file="$CURSOR_FILE" -p info -o cat _SYSTEMD_UNIT="$UN
hello
+ echo world
world
+ set +x
EOF
rm -f "$CURSOR_FILE"

View File

@@ -158,13 +158,13 @@ if ! systemd-detect-virt -cq; then
-p DevicePolicy=closed
-p DevicePolicy=strict
-p DeviceAllow="char-mem rm" # Allow read & mknod for /dev/{null,zero,...}
-p DeviceAllow="/dev/loop0 rw"
-p DeviceAllow="/dev/loop0 w" # Allow write for /dev/loop0
-p DeviceAllow="$LODEV rw"
-p DeviceAllow="$LODEV w" # Allow write for the loop
# Everything else should be disallowed per the strict policy
)
systemd-run --wait --pipe --unit "$SERVICE_NAME" "${ARGUMENTS[@]}" \
bash -xec 'test -r /dev/null; test ! -w /dev/null; test ! -r /dev/loop0; test -w /dev/loop0; test ! -r /dev/tty; test ! -w /dev/tty'
bash -xec "test -r /dev/null; test ! -w /dev/null; test ! -r $LODEV; test -w $LODEV; test ! -r /dev/tty; test ! -w /dev/tty"
if ! systemctl --version | grep -qF -- "-BPF_FRAMEWORK"; then
# SocketBind*=

View File

@@ -13,3 +13,4 @@ mountpoint /issue2730
run_subtests
touch /testok
systemctl --no-block exit 123

View File

@@ -3,6 +3,12 @@
set -eux
set -o pipefail
# check dfuzzer is present before testing
if ! command -v dfuzzer &>/dev/null; then
echo "dfuzzer is not installed, skipping" | tee --append /skipped
exit 77
fi
# Save the end.service state before we start fuzzing, as it might get changed
# on the fly by one of the fuzzers
systemctl list-jobs | grep -F 'end.service' && SHUTDOWN_AT_EXIT=1 || SHUTDOWN_AT_EXIT=0

View File

@@ -33,6 +33,8 @@ wait_for_state() {
done
}
FSTYPE="$(stat --file-system --format "%T" /)"
systemd-analyze log-level debug
systemctl service-log-level systemd-homed debug
@@ -129,8 +131,9 @@ if ! systemd-detect-virt -cq ; then
inspect test-user
fi
# Do some resize tests, but only if we run on real kernels, as quota inside of containers will fail
if ! systemd-detect-virt -cq ; then
# Do some resize tests, but only if we run on real kernels and are on btrfs, as quota inside of containers
# will fail and minimizing while active only works on btrfs.
if ! systemd-detect-virt -cq && [[ "$FSTYPE" == "btrfs" ]]; then
# grow while inactive
PASSWORD=xEhErW0ndafV4s homectl resize test-user 300M
inspect test-user
@@ -323,16 +326,19 @@ inspect blob-user
(! checkblob avatar /tmp/external-avatar )
# file that's exactly 64M still fits
PASSWORD=EMJuc3zQaMibJo homectl update blob-user \
-b barely-fits=/tmp/external-barely-fits
(! checkblob test1 /tmp/blob1/test1 )
(! checkblob test1 /tmp/blob2/test1 )
(! checkblob test2 /tmp/blob1/test2 )
(! checkblob test2 /tmp/blob2/test2 )
(! checkblob фаил /tmp/blob1/фаил )
(! checkblob test3 /tmp/external-test3 )
(! checkblob avatar /tmp/external-avatar )
checkblob barely-fits /tmp/external-barely-fits
# FIXME: Figure out why this fails on ext4.
if [[ "$FSTYPE" != "ext2/ext3" ]]; then
PASSWORD=EMJuc3zQaMibJo homectl update blob-user \
-b barely-fits=/tmp/external-barely-fits
(! checkblob test1 /tmp/blob1/test1 )
(! checkblob test1 /tmp/blob2/test1 )
(! checkblob test2 /tmp/blob1/test2 )
(! checkblob test2 /tmp/blob2/test2 )
(! checkblob фаил /tmp/blob1/фаил )
(! checkblob test3 /tmp/external-test3 )
(! checkblob avatar /tmp/external-avatar )
checkblob barely-fits /tmp/external-barely-fits
fi
# error out if the file is too big
(! PASSWORD=EMJuc3zQaMibJo homectl update blob-user -b huge=/tmp/external-toobig )

View File

@@ -6,6 +6,14 @@ set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
. /etc/os-release
# OpenSUSE does not have the stress tool packaged. It does have stress-ng but the stress-ng does not support
# --vm-stride which this test uses.
if [[ "$ID" =~ "opensuse" ]]; then
echo "Skipping due to missing stress package in OpenSUSE" >>/skipped
exit 77
fi
systemd-analyze log-level debug
# Ensure that the init.scope.d drop-in is applied on boot
@@ -23,6 +31,7 @@ rm -rf /run/systemd/system/testsuite-55-testbloat.service.d
# Activate swap file if we are in a VM
if systemd-detect-virt --vm --quiet; then
swapoff --all
if [[ "$(findmnt -n -o FSTYPE /)" == btrfs ]]; then
btrfs filesystem mkswapfile -s 64M /swapfile
else

View File

@@ -212,6 +212,7 @@ Encrypt=tpm2
EOF
PASSWORD=passphrase systemd-repart --tpm2-device-key=/tmp/srk.pub --definitions=/tmp/dditest --empty=create --size=50M /tmp/dditest.raw --tpm2-pcrs=
DEVICE="$(systemd-dissect --attach /tmp/dditest.raw)"
udevadm wait --settle --timeout=10 "$DEVICE"
systemd-cryptsetup attach dditest "$DEVICE"p1 - tpm2-device=auto,headless=yes
mkdir /tmp/dditest.mnt
mount -t ext4 /dev/mapper/dditest /tmp/dditest.mnt

View File

@@ -1,6 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-70-TPM2
Wants=tpm2.target
After=tpm2.target
[Service]
Type=oneshot

View File

@@ -28,31 +28,6 @@ EOF
systemctl daemon-reload
}
restore_locale() {
if [[ -d /usr/lib/locale/xx_XX.UTF-8 ]]; then
rmdir /usr/lib/locale/xx_XX.UTF-8
fi
if [[ -f /tmp/locale.conf.bak ]]; then
mv /tmp/locale.conf.bak /etc/locale.conf
else
rm -f /etc/locale.conf
fi
if [[ -f /tmp/default-locale.bak ]]; then
mv /tmp/default-locale.bak /etc/default/locale
else
rm -f /etc/default/locale
rmdir --ignore-fail-on-non-empty /etc/default
fi
if [[ -f /tmp/locale.gen.bak ]]; then
mv /tmp/locale.gen.bak /etc/locale.gen
else
rm -f /etc/locale.gen
fi
}
testcase_locale() {
local i output
@@ -77,13 +52,8 @@ testcase_locale() {
mkdir -p /etc/default
trap restore_locale RETURN
if command -v locale-gen >/dev/null 2>&1 &&
! localectl list-locales | grep -F "en_US.UTF-8"; then
# ensure at least one utf8 locale exist
echo "en_US.UTF-8 UTF-8" >/etc/locale.gen
locale-gen en_US.UTF-8
fi
# Ensure at least one UTF-8 locale exists.
generate_locale en_US.UTF-8
# create invalid locale
mkdir -p /usr/lib/locale/xx_XX.UTF-8

View File

@@ -59,8 +59,8 @@ basic_tests() {
}
testcase_bootctl_basic() {
assert_eq "$(bootctl --print-esp-path)" "/efi"
assert_eq "$(bootctl --print-boot-path)" "/boot"
assert_in "$(bootctl --print-esp-path)" "^(/boot/|/efi)$"
assert_in "$(bootctl --print-boot-path)" "^(/boot/|/efi)$"
bootctl --print-root-device
basic_tests
@@ -266,10 +266,14 @@ EOF
testcase_bootctl_varlink() {
varlinkctl call --collect /run/systemd/io.systemd.BootControl io.systemd.BootControl.ListBootEntries '{}'
# We have no UEFI in the test environment, hence just check that this fails cleanly
( SYSTEMD_LOG_TARGET=console varlinkctl call --json=short /run/systemd/io.systemd.BootControl io.systemd.BootControl.GetRebootToFirmware '{}' 2>&1 || true ) | grep -q io.systemd.BootControl.RebootToFirmwareNotSupported
( SYSTEMD_LOG_TARGET=console varlinkctl call --json=short /run/systemd/io.systemd.BootControl io.systemd.BootControl.SetRebootToFirmware '{"state":true}' 2>&1 || true ) | grep -q io.systemd.BootControl.RebootToFirmwareNotSupported
( SYSTEMD_LOG_TARGET=console varlinkctl call --json=short /run/systemd/io.systemd.BootControl io.systemd.BootControl.SetRebootToFirmware '{"state":false}' 2>&1 || true ) | grep -q io.systemd.BootControl.RebootToFirmwareNotSupported
# We may have UEFI in the test environment.
# If we don't have UEFI then we can test whether bootctl's varlink API fails cleanly.
# If we do have UEFI then the rest of the clean fail tests should be skipped.
if ! (SYSTEMD_LOG_TARGET=console varlinkctl call --json=short /run/systemd/io.systemd.BootControl io.systemd.BootControl.GetRebootToFirmware '{}' || true) |& grep -q io.systemd.BootControl.RebootToFirmwareNotSupported; then
return 0
fi
(SYSTEMD_LOG_TARGET=console varlinkctl call --json=short /run/systemd/io.systemd.BootControl io.systemd.BootControl.SetRebootToFirmware '{"state":true}' || true) |& grep -q io.systemd.BootControl.RebootToFirmwareNotSupported
(SYSTEMD_LOG_TARGET=console varlinkctl call --json=short /run/systemd/io.systemd.BootControl io.systemd.BootControl.SetRebootToFirmware '{"state":false}' || true) |& grep -q io.systemd.BootControl.RebootToFirmwareNotSupported
}
run_testcases

View File

@@ -3,6 +3,9 @@
set -eux
set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
if ! command -v systemd-firstboot >/dev/null; then
echo "systemd-firstboot not found, skipping the test"
exit 0
@@ -13,6 +16,8 @@ at_exit() {
ls -lR "$ROOT"
rm -fr "$ROOT"
fi
restore_locale
}
trap at_exit EXIT
@@ -24,6 +29,23 @@ ROOT_HASHED_PASSWORD1='$6$foobarsalt$YbwdaATX6IsFxvWbY3QcZj2gB31R/LFRFrjlFrJtTTq
# shellcheck disable=SC2016
ROOT_HASHED_PASSWORD2='$6$foobarsalt$q.P2932zYMLbKnjFwIxPI8y3iuxeuJ2BgE372LcZMMnj3Gcg/9mJg2LPKUl.ha0TG/.fRNNnRQcLfzM0SNot3.'
if [[ -f /etc/locale.conf ]]; then
cp /etc/locale.conf /tmp/locale.conf.bak
fi
# Debian/Ubuntu specific file
if [[ -f /etc/default/locale ]]; then
cp /etc/default/locale /tmp/default-locale.bak
fi
if [[ -f /etc/locale.gen ]]; then
cp /etc/locale.gen /tmp/locale.gen.bak
fi
# Make sure at least two locales exist (C.UTF-8 and en_US.UTF-8) as systemd-firstboot --prompt-locale will
# skip writing the locale if it detects only one is installed.
generate_locale en_US.UTF-8
# Debian and Ubuntu use /etc/default/locale instead of /etc/locale.conf. Make
# sure we use the appropriate path for locale configuration.
LOCALE_PATH="/etc/locale.conf"

View File

@@ -17,8 +17,10 @@ if systemd-detect-virt -cq; then
exit 0
fi
ORIG_MODULES_LOAD_CONFIG="$(systemd-analyze cat-config modules-load.d)"
# Check if we have required kernel modules
modprobe --all --resolve-alias loop dummy
modprobe --all --resolve-alias dummy
mkdir -p /run/modules-load.d/
@@ -27,62 +29,58 @@ mkdir -p /run/modules-load.d/
"$MODULES_LOAD_BIN" --version
# Explicit config file
modprobe -v --all --remove loop dummy
printf "loop\ndummy" >"$CONFIG_FILE"
modprobe -v --all --remove dummy
printf "dummy" >"$CONFIG_FILE"
"$MODULES_LOAD_BIN" "$CONFIG_FILE" |& tee /tmp/out.log
grep -E "Inserted module .*loop" /tmp/out.log
grep -E "Inserted module .*dummy" /tmp/out.log
# Implicit config file
modprobe -v --all --remove loop dummy
printf "loop\ndummy" >"$CONFIG_FILE"
modprobe -v --all --remove dummy
printf "dummy" >"$CONFIG_FILE"
"$MODULES_LOAD_BIN" |& tee /tmp/out.log
grep -E "Inserted module .*loop" /tmp/out.log
grep -E "Inserted module .*dummy" /tmp/out.log
# Valid & invalid data mixed together
modprobe -v --all --remove loop dummy
modprobe -v --all --remove dummy
cat >"$CONFIG_FILE" <<EOF
loop
loop
loop
loop
dummy
dummy
dummy
dummy
dummy
\\n\n\n\\\\\\
loo!@@123##2455
dumm!@@123##2455
# This is a comment
$(printf "%.0sx" {0..4096})
dummy
loop
dummy
foo-bar-baz
1
"
'
EOF
"$MODULES_LOAD_BIN" |& tee /tmp/out.log
grep -E "^Inserted module .*loop" /tmp/out.log
grep -E "^Inserted module .*dummy" /tmp/out.log
grep -E "^Failed to find module .*foo-bar-baz" /tmp/out.log
(! grep -E "This is a comment" /tmp/out.log)
# Each module should be loaded only once, even if specified multiple times
[[ "$(grep -Ec "^Inserted module" /tmp/out.log)" -eq 2 ]]
[[ "$(grep -Ec "^Inserted module" /tmp/out.log)" -eq 1 ]]
[[ "$(grep -Ec "^Failed to find module" /tmp/out.log)" -eq 7 ]]
# Command line arguments
modprobe -v --all --remove loop dummy
modprobe -v --all --remove dummy
# Make sure we have no config files left over that might interfere with
# following tests
rm -fv "$CONFIG_FILE"
[[ -z "$(systemd-analyze cat-config modules-load.d)" ]]
CMDLINE="ro root= modules_load= modules_load=, / = modules_load=foo-bar-baz,dummy modules_load=loop,loop,loop"
[[ "$ORIG_MODULES_LOAD_CONFIG" == "$(systemd-analyze cat-config modules-load.d)" ]]
CMDLINE="ro root= modules_load= modules_load=, / = modules_load=foo-bar-baz,dummy modules_load=dummy,dummy,dummy"
SYSTEMD_PROC_CMDLINE="$CMDLINE" "$MODULES_LOAD_BIN" |& tee /tmp/out.log
grep -E "^Inserted module .*loop" /tmp/out.log
grep -E "^Inserted module .*dummy" /tmp/out.log
grep -E "^Failed to find module .*foo-bar-baz" /tmp/out.log
# Each module should be loaded only once, even if specified multiple times
[[ "$(grep -Ec "^Inserted module" /tmp/out.log)" -eq 2 ]]
[[ "$(grep -Ec "^Inserted module" /tmp/out.log)" -eq 1 ]]
(! "$MODULES_LOAD_BIN" --nope)
(! "$MODULES_LOAD_BIN" /foo/bar/baz)

View File

@@ -231,15 +231,17 @@ assert_eq "$KVER" "$UNIT_KVER"
umount /proc/version
rm -f "$TMP_KVER"
# Check that invoking the tool under the run0 alias name works
run0 ls /
assert_eq "$(run0 echo foo)" "foo"
# Check if we set some expected environment variables
for arg in "" "--user=root" "--user=testuser"; do
assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_USER')" "$USER"
assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_UID')" "$(id -u "$USER")"
assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_GID')" "$(id -u "$USER")"
done
# Let's chain a couple of run0 calls together, for fun
readarray -t cmdline < <(printf "%.0srun0\n" {0..31})
assert_eq "$("${cmdline[@]}" bash -c 'echo $SUDO_USER')" "$USER"
if [[ -e /usr/lib/pam.d/systemd-run0 ]] || [[ -e /etc/pam.d/systemd-run0 ]]; then
# Check that invoking the tool under the run0 alias name works
run0 ls /
assert_eq "$(run0 echo foo)" "foo"
# Check if we set some expected environment variables
for arg in "" "--user=root" "--user=testuser"; do
assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_USER')" "$USER"
assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_UID')" "$(id -u "$USER")"
assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_GID')" "$(id -u "$USER")"
done
# Let's chain a couple of run0 calls together, for fun
readarray -t cmdline < <(printf "%.0srun0\n" {0..31})
assert_eq "$("${cmdline[@]}" bash -c 'echo $SUDO_USER')" "$USER"
fi

View File

@@ -32,7 +32,9 @@ removesshid() {
ssh-keygen -N '' -C '' -t rsa -f "$ROOTID"
mkdir -p 0700 /root/.ssh
cat "$ROOTID".pub >> /root/.ssh/authorized_keys
# Add a newline in case authorized_keys wasn't terminated correctly.
echo >>/root/.ssh/authorized_keys
cat "$ROOTID".pub >>/root/.ssh/authorized_keys
# set root pw to "foo", just to set it to something valid
# shellcheck disable=SC2016

View File

@@ -14,6 +14,12 @@ set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
# We need at least Knot 3.0 which support (among others) the ds-push directive
if ! knotc -c /usr/lib/systemd/tests/testdata/knot-data/knot.conf conf-check; then
echo "This test requires at least Knot 3.0. skipping..." | tee --append /skipped
exit 77
fi
RUN_OUT="$(mktemp)"
run() {
@@ -246,6 +252,14 @@ ln -svf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
mkdir -p "/etc/dnssec-trust-anchors.d/"
echo local >/etc/dnssec-trust-anchors.d/local.negative
# Copy over our knot configuration
mkdir -p /var/lib/knot/zones/ /etc/knot/
cp -rfv /usr/lib/systemd/tests/testdata/knot-data/zones/* /var/lib/knot/zones/
cp -fv /usr/lib/systemd/tests/testdata/knot-data/knot.conf /etc/knot/knot.conf
chgrp -R knot /etc/knot/ /var/lib/knot/
chmod -R ug+rwX /var/lib/knot/
chmod -R g+r /etc/knot/
# Sign the root zone
keymgr . generate algorithm=ECDSAP256SHA256 ksk=yes zsk=yes
# Create a trust anchor for resolved with our root zone
@@ -264,10 +278,11 @@ ln -svf /etc/bind.keys /etc/bind/bind.keys
# Start the services
systemctl unmask systemd-networkd
systemctl start systemd-networkd
systemctl restart systemd-networkd
/usr/lib/systemd/systemd-networkd-wait-online --interface=dns1:routable --timeout=60
systemctl reload systemd-resolved
systemctl start resolved-dummy-server
# Create knot's runtime dir, since from certain version it's provided only by
# the package and not created by tmpfiles/systemd
if [[ ! -d /run/knot ]]; then
@@ -309,6 +324,7 @@ done < <(keymgr onlinesign.test. ds)
knotc zone-commit test.
knotc reload
sleep 2
### SETUP END ###
@@ -862,8 +878,8 @@ test "$(resolvectl --json=short query -t AAAA localhost)" == '{"key":{"class":1,
test "$(resolvectl --json=short query -t A localhost)" == '{"key":{"class":1,"type":1,"name":"localhost"},"address":[127,0,0,1]}'
# Test ResolveRecord RR resolving via Varlink
test "$(varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveRecord '{"name":"localhost","type":1}' --json=short)" == '{"rrs":[{"ifindex":1,"rr":{"key":{"class":1,"type":1,"name":"localhost"},"address":[127,0,0,1]},"raw":"CWxvY2FsaG9zdAAAAQABAAAAAAAEfwAAAQ=="}],"flags":786945}'
test "$(varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveRecord '{"name":"localhost","type":28}' --json=short)" == '{"rrs":[{"ifindex":1,"rr":{"key":{"class":1,"type":28,"name":"localhost"},"address":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]},"raw":"CWxvY2FsaG9zdAAAHAABAAAAAAAQAAAAAAAAAAAAAAAAAAAAAQ=="}],"flags":786945}'
test "$(varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveRecord '{"name":"localhost","type":1}' --json=short | jq -rc 'del(.rrs | .[] | .ifindex)')" == '{"rrs":[{"rr":{"key":{"class":1,"type":1,"name":"localhost"},"address":[127,0,0,1]},"raw":"CWxvY2FsaG9zdAAAAQABAAAAAAAEfwAAAQ=="}],"flags":786945}'
test "$(varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveRecord '{"name":"localhost","type":28}' --json=short | jq -rc 'del(.rrs | .[] | .ifindex)')" == '{"rrs":[{"rr":{"key":{"class":1,"type":28,"name":"localhost"},"address":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]},"raw":"CWxvY2FsaG9zdAAAHAABAAAAAAAQAAAAAAAAAAAAAAAAAAAAAQ=="}],"flags":786945}'
# Ensure that reloading keeps the manually configured address
{

View File

@@ -345,3 +345,36 @@ EOF
echo -e "[Unit]\nUpholds=foo.service" >"$initdir/usr/lib/systemd/system/multi-user.target.d/10-foo-service.conf"
mksquashfs "$initdir" /tmp/app-reload.raw -noappend
}
restore_locale() {
if [[ -d /usr/lib/locale/xx_XX.UTF-8 ]]; then
rmdir /usr/lib/locale/xx_XX.UTF-8
fi
if [[ -f /tmp/locale.conf.bak ]]; then
mv /tmp/locale.conf.bak /etc/locale.conf
else
rm -f /etc/locale.conf
fi
if [[ -f /tmp/default-locale.bak ]]; then
mv /tmp/default-locale.bak /etc/default/locale
else
rm -rf /etc/default
fi
if [[ -f /tmp/locale.gen.bak ]]; then
mv /tmp/locale.gen.bak /etc/locale.gen
else
rm -f /etc/locale.gen
fi
}
generate_locale() {
local locale="${1:?}"
if command -v locale-gen >/dev/null && ! localectl list-locales | grep -F "$locale"; then
echo "$locale UTF-8" >/etc/locale.gen
locale-gen "$locale"
fi
}

View File

@@ -20,9 +20,15 @@ if [ -f .git/hooks/pre-commit.sample ] && [ ! -f .git/hooks/pre-commit ]; then
fi
if [ ! -f .git/hooks/post-rewrite ]; then
cp -p tools/git-post-rewrite-hook.sh .git/hooks/post-rewrite
cp -p tools/git-submodule-update-hook.sh .git/hooks/post-rewrite
echo 'Activated post-rewrite hook'
ret=0
fi
if [ ! -f .git/hooks/post-checkout ]; then
cp -p tools/git-submodule-update-hook.sh .git/hooks/post-checkout
echo 'Activated post-checkout hook'
ret=0
fi
exit $ret