From 69e02d94f52817c48f83252c309783d4a4a6aeef Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 14:10:24 +0200 Subject: [PATCH 01/60] meson: Remove --debug from mkosi arguments The exit status issue for which we introduced this was fixed so let's remove --debug again to make the meson output less verbose. --- meson.build | 1 - test/integration-test-wrapper.py | 1 - 2 files changed, 2 deletions(-) diff --git a/meson.build b/meson.build index 78bd252f901..0b27285da03 100644 --- a/meson.build +++ b/meson.build @@ -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, diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index 1954d0fec0c..af8be892640 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -81,7 +81,6 @@ def main(): 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), From f779fd1f8fbebe6d32feee619c0430ca142b9a6d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 17:44:49 +0200 Subject: [PATCH 02/60] meson: Set up git submodule update on post checkout as well --- docs/HACKING.md | 3 ++- tools/git-setup.sh | 8 +++++++- ...-post-rewrite-hook.sh => git-submodule-update-hook.sh} | 0 3 files changed, 9 insertions(+), 2 deletions(-) rename tools/{git-post-rewrite-hook.sh => git-submodule-update-hook.sh} (100%) diff --git a/docs/HACKING.md b/docs/HACKING.md index 9e25ceec33f..980a45929eb 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -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. diff --git a/tools/git-setup.sh b/tools/git-setup.sh index a53f1790c17..8cc1bfdfc2a 100755 --- a/tools/git-setup.sh +++ b/tools/git-setup.sh @@ -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 diff --git a/tools/git-post-rewrite-hook.sh b/tools/git-submodule-update-hook.sh similarity index 100% rename from tools/git-post-rewrite-hook.sh rename to tools/git-submodule-update-hook.sh From ea07a6d45daf50d948a8a904f0417cf25c97ab65 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 4 May 2024 15:08:02 +0200 Subject: [PATCH 03/60] meson: Test installation fixes Let's use the new follow_symlinks flag instead on newer meson to. We also switch back to copying symlinks instead of following them and add an exclude for 25-default.link which becomes dangling when installed and recreate it manually instead. --- test/meson.build | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/meson.build b/test/meson.build index 95136c7e028..161f24dc0bc 100644 --- a/test/meson.build +++ b/test/meson.build @@ -24,21 +24,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') From 54d0507223462a0fe4dac6c6971b5553e3d6ea25 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 10:39:22 +0200 Subject: [PATCH 04/60] meson: Add missing spdx line --- test/TEST-02-UNITTESTS/meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/TEST-02-UNITTESTS/meson.build b/test/TEST-02-UNITTESTS/meson.build index 6bc04838fb9..5c3c0408583 100644 --- a/test/TEST-02-UNITTESTS/meson.build +++ b/test/TEST-02-UNITTESTS/meson.build @@ -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([ From bdade5f5971966e400f2f2d977bc36f1c180aacb Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 2 May 2024 08:52:50 +0200 Subject: [PATCH 05/60] test: Formatting fixes --- test/TEST-09-REBOOT/meson.build | 2 +- test/integration-test-wrapper.py | 2 +- test/meson.build | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/TEST-09-REBOOT/meson.build b/test/TEST-09-REBOOT/meson.build index 30a5a10707b..7f5cc704c9d 100644 --- a/test/TEST-09-REBOOT/meson.build +++ b/test/TEST-09-REBOOT/meson.build @@ -1,5 +1,5 @@ # SPDX-License-Identifier: LGPL-2.1-or-later -test_params = test_params + { +test_params += { 'storage': 'persistent', } diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index af8be892640..f3b1172a5d5 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -119,7 +119,7 @@ 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', ] diff --git a/test/meson.build b/test/meson.build index 161f24dc0bc..c4f4057e594 100644 --- a/test/meson.build +++ b/test/meson.build @@ -412,7 +412,7 @@ foreach test_number, dirname : integration_tests test_params = { 'mkosi_args' : [], 'timeout' : 1800, - 'storage': 'volatile', + 'storage' : 'volatile', } # TODO: This fs.exists call isn't included in rebuild logic @@ -435,9 +435,9 @@ foreach test_number, dirname : integration_tests # 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 : test_env, + args : args, + timeout : test_params['timeout'], + suite : 'integration-tests') endforeach From 86e249f326ce989f686a2522ef531520283ed970 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 14:13:39 +0200 Subject: [PATCH 06/60] mkosi: Update to latest --- .github/workflows/mkosi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index afdbb739ee1..6953f9e4eae 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -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 From 1c329956e5995dfffec49139096b75d9bd42decc Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 14:15:55 +0200 Subject: [PATCH 07/60] mkosi: Insist on KVM, VSOCK and TPM by default By default mkosi will not run VMs with these features if they're not available, but since various stuff in systemd makes use of these, let's fail loudly if any of these are not available by default in systemd. Users can still override these defaults locally if they wish. --- .github/workflows/mkosi.yml | 2 -- mkosi.conf | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index 6953f9e4eae..e080eb38048 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -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 diff --git a/mkosi.conf b/mkosi.conf index 0f2705f5fcb..1c2d448ef98 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -41,4 +41,7 @@ Credentials=journal.storage=persistent @Incremental=yes @RuntimeBuildSources=yes @QemuSmp=2 +@QemuSwtpm=yes +@QemuVsock=yes +@QemuKvm=yes ToolsTreePackages=virtiofsd From 89255c31a415d9b5be34c72882b8da51a4200100 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 1 May 2024 09:35:28 +0200 Subject: [PATCH 08/60] mkosi: Install dfuzzer on CentOS/Fedora images Required for TEST-21-DFUZZER. --- mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf index ba8c33f3509..8c0d8ad8d22 100644 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf @@ -23,6 +23,7 @@ VolatilePackages= Packages= bpftool cryptsetup + dfuzzer dhcp-server dnf git-core From 9bf888faf1fc1c5dc291a62c2ee775ba5f093dfd Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 1 May 2024 09:36:17 +0200 Subject: [PATCH 09/60] mkosi: Drop glibc-langpack-en from Fedora specific packages It's already added in the CentOS/Fedora shared configuration. --- mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf index 8236040c0e2..389caa43343 100644 --- a/mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf @@ -8,7 +8,6 @@ Packages= btrfs-progs compsize f2fs-tools - glibc-langpack-en sbsigntools dnf5 From f09947661c18e4f1cbe4ef1a594088a83d75ec27 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 1 May 2024 09:37:09 +0200 Subject: [PATCH 10/60] mkosi: Move sbsigntools to CentOS/Fedora shared configuration sbsigntools was added to EPEL 9. --- mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf | 1 + mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf index 8c0d8ad8d22..bff0856882e 100644 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf @@ -52,6 +52,7 @@ Packages= rpm rpm-build rpmautospec + sbsigntools squashfs-tools tpm2-tools util-linux diff --git a/mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf index 389caa43343..838c8314c40 100644 --- a/mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf @@ -8,7 +8,6 @@ Packages= btrfs-progs compsize f2fs-tools - sbsigntools dnf5 InitrdPackages= From 81af7ac925c267b002926d7be910322b93aeae32 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 2 May 2024 16:38:31 +0200 Subject: [PATCH 11/60] mkosi: Enable udev debug logging in CI It's very useful to debug race conditions with loop devices, so let's enable the logging now that it goes to the journal and not to the console. --- .github/workflows/mkosi.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index e080eb38048..fe602685e9c 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -130,8 +130,6 @@ jobs: tee mkosi.conf.d/99-ci.conf < Date: Fri, 3 May 2024 12:56:50 +0200 Subject: [PATCH 12/60] mkosi: Disable ext4's orphan_file feature for centos images Not supported by e2fsck from centos. We also disable building repart from source in CI as running it from the build directory means repart will run mkfs.ext4 from the host which doesn't know about the orphan_file feature causing it to fail. --- .github/workflows/mkosi.yml | 2 +- mkosi.conf.d/10-centos.conf | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index fe602685e9c..22e084bf7b3 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -169,7 +169,7 @@ jobs: -Dtpm2=enabled \ -Dlibcryptsetup=enabled \ -Dlibcurl=enabled \ - -Drepart=enabled \ + -Drepart=disabled \ -Dfirstboot=true \ -Dsysusers=true \ -Dtmpfiles=true \ diff --git a/mkosi.conf.d/10-centos.conf b/mkosi.conf.d/10-centos.conf index ae2706c7917..69fa1350e60 100644 --- a/mkosi.conf.d/10-centos.conf +++ b/mkosi.conf.d/10-centos.conf @@ -8,3 +8,6 @@ Distribution=centos Repositories=epel epel-next hyperscale-packages-main + +[Content] +Environment=SYSTEMD_REPART_MKFS_OPTIONS_EXT4="-O ^orphan_file" From efbd22e476c79ce9c2929ebc075f9c25db50fb6d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 12:57:29 +0200 Subject: [PATCH 13/60] mkosi: Use /etc/nsswitch.conf from repo in mkosi image --- mkosi.images/system/mkosi.postinst.chroot | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkosi.images/system/mkosi.postinst.chroot b/mkosi.images/system/mkosi.postinst.chroot index f2b0ba09c2d..8b7aff1b56f 100755 --- a/mkosi.images/system/mkosi.postinst.chroot +++ b/mkosi.images/system/mkosi.postinst.chroot @@ -72,3 +72,6 @@ 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 From 2d93e534a33ed8abe268ea54189f6d7f35d3addf Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 4 May 2024 12:18:10 +0200 Subject: [PATCH 14/60] mkosi: Install knot Required for TEST-75-RESOLVED --- mkosi.images/system/mkosi.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkosi.images/system/mkosi.conf b/mkosi.images/system/mkosi.conf index 7ae4c90bb0d..ece88c369a0 100644 --- a/mkosi.images/system/mkosi.conf +++ b/mkosi.images/system/mkosi.conf @@ -39,6 +39,7 @@ Packages= kbd kexec-tools kmod + knot less man mtools From a82d897c3da861d3cdfff087437f1b576a3ac2cd Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 4 May 2024 12:18:31 +0200 Subject: [PATCH 15/60] mkosi: Install dig Required for TEST-75-RESOLVED --- mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf | 1 + mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf | 1 + mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf | 1 + mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf | 1 + 4 files changed, 4 insertions(+) diff --git a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf index f8a5f9a3e70..308431f7662 100644 --- a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf @@ -13,6 +13,7 @@ VolatilePackages= systemd-ukify Packages= + bind bpf btrfs-progs compsize diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf index bff0856882e..f6ae87ea7ef 100644 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf @@ -21,6 +21,7 @@ VolatilePackages= systemd-ukify Packages= + bind-utils bpftool cryptsetup dfuzzer diff --git a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf index 385a8ff04d8..c66ca5d221d 100644 --- a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf @@ -36,6 +36,7 @@ Packages= ^libtss2-mu-[0-9.]+-0$ ^libubsan[0-9]+$ apt + bind9-dnsutils btrfs-progs cryptsetup-bin dbus-broker diff --git a/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf index d7248bec249..0e7fa6871de 100644 --- a/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf @@ -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 From 3c3e21fb6499ce615c8798c5fffbac0b97d0443d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 4 May 2024 12:46:11 +0200 Subject: [PATCH 16/60] mkosi: Install veritysetup Only missing on CentOS/Fedora/OpenSUSE as in Arch/Debian/Ubuntu it's part of the cryptsetup package which we already install. Required for TEST-58-REPART. --- mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf | 1 + mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf | 1 + 2 files changed, 2 insertions(+) diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf index f6ae87ea7ef..f15d14218cb 100644 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf @@ -57,6 +57,7 @@ Packages= squashfs-tools tpm2-tools util-linux + veritysetup vim-common InitrdPackages= diff --git a/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf index 0e7fa6871de..349e00bdcd7 100644 --- a/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf @@ -70,6 +70,7 @@ Packages= user(games) user(nobody) user(root) + veritysetup vim xz From 5cb66ff5a17df855ba5b23f6f7e21511a457722c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 10:25:12 +0200 Subject: [PATCH 17/60] mkosi: Install stress Required for TEST-55-OOMD. Not available on opensuse. --- mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf | 1 + mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf | 1 + mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf | 1 + 3 files changed, 3 insertions(+) diff --git a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf index 308431f7662..cc05300e802 100644 --- a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf @@ -42,6 +42,7 @@ Packages= sbsigntools shadow squashfs-tools + stress tpm2-tools tpm2-tss vim diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf index f15d14218cb..37211b0cab7 100644 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf @@ -55,6 +55,7 @@ Packages= rpmautospec sbsigntools squashfs-tools + stress tpm2-tools util-linux veritysetup diff --git a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf index c66ca5d221d..492872029de 100644 --- a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf @@ -64,6 +64,7 @@ Packages= quota sbsigntool squashfs-tools + stress tpm2-tools tzdata xxd From 7cf0efd8ecc45694d64e42bc244fd477d11644c8 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 15:03:37 +0200 Subject: [PATCH 18/60] mkosi: Make sure tmp.mount is not messed with on Debian/Ubuntu We want /tmp to be a tmpfs so let's hack the debian packaging to make sure that's the case until the debian packaging is fixed to make /tmp a tmpfs for UPSTREAM=1 builds. --- .../system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot index e8921c2efed..52a23a53b59 100755 --- a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot +++ b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot @@ -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) \ From 6817910e6fa1c0c79ea2d5a6f577c4f21f4e2ec7 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 20:46:59 +0200 Subject: [PATCH 19/60] mkosi: Remove /etc/default/keyboard if it exists Required to make TEST-73-LOCALE pass on Ubuntu. --- mkosi.images/system/mkosi.postinst.chroot | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkosi.images/system/mkosi.postinst.chroot b/mkosi.images/system/mkosi.postinst.chroot index 8b7aff1b56f..5683d5ca53b 100755 --- a/mkosi.images/system/mkosi.postinst.chroot +++ b/mkosi.images/system/mkosi.postinst.chroot @@ -75,3 +75,6 @@ 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 From 13686c0e58b02ec879cefbf0220a4048001b985e Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 21:19:26 +0200 Subject: [PATCH 20/60] mkosi: Install dbus policy required by TEST-23-UNIT-FILE Co-authored-by: Richard Maw --- .../dbus-1/system.d/systemd.test.ExecStopPost.conf | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 mkosi.images/system/mkosi.extra/usr/share/dbus-1/system.d/systemd.test.ExecStopPost.conf diff --git a/mkosi.images/system/mkosi.extra/usr/share/dbus-1/system.d/systemd.test.ExecStopPost.conf b/mkosi.images/system/mkosi.extra/usr/share/dbus-1/system.d/systemd.test.ExecStopPost.conf new file mode 100644 index 00000000000..ddd36ed5dcf --- /dev/null +++ b/mkosi.images/system/mkosi.extra/usr/share/dbus-1/system.d/systemd.test.ExecStopPost.conf @@ -0,0 +1,13 @@ + + + + + + + + + + From fc4bac8162fcdf9fd01eb22ce25f21a3a94f4e04 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 22:22:03 +0200 Subject: [PATCH 21/60] mkosi: Add dependency to system image on minimal-base The output is included as an extra tree so it should be a dependency, even if it is pulled in transitively via minimal-0 and minimal-1 already. --- mkosi.images/system/mkosi.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkosi.images/system/mkosi.conf b/mkosi.images/system/mkosi.conf index ece88c369a0..6d476d385e2 100644 --- a/mkosi.images/system/mkosi.conf +++ b/mkosi.images/system/mkosi.conf @@ -2,6 +2,7 @@ [Config] Dependencies= + minimal-base minimal-0 minimal-1 From 38db5eff344dcc97739be2ee4696f02eae1555dd Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 2 May 2024 20:21:29 +0200 Subject: [PATCH 22/60] test: Only set environment variable if integration tests are enabled. If we set it to '0' if integration tests are not enabled then we can't enable them from the command line since environment from meson takes priority over environment variables from the command line. We also rename the related variables to avoid conflicts with the existing integration_tests variable. --- meson.build | 16 ++++++++-------- src/test/meson.build | 3 +-- test/meson.build | 8 +++++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 0b27285da03..63c358194d8 100644 --- a/meson.build +++ b/meson.build @@ -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 @@ -2729,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 @@ -3028,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')], diff --git a/src/test/meson.build b/src/test/meson.build index a452021f626..3abbb94d9fb 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -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) diff --git a/test/meson.build b/test/meson.build index c4f4057e594..f93137c07a1 100644 --- a/test/meson.build +++ b/test/meson.build @@ -431,12 +431,18 @@ foreach test_number, dirname : integration_tests '--', ] + 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, + env : integration_test_env, args : args, timeout : test_params['timeout'], suite : 'integration-tests') From 3cb61e0d1cc30434294962283f79a4f909e9d9dc Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 10:27:58 +0200 Subject: [PATCH 23/60] test: Pass through test matching environment variables to the mkosi VM --- test/integration-test-wrapper.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index f3b1172a5d5..e3dcf75239f 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -64,6 +64,22 @@ def main(): """ ) + 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( """ From 0596237e0e3cbe3c3312300f00ef49742dc24562 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 10:57:50 +0200 Subject: [PATCH 24/60] test: Use MESON_TEST_ITERATION if available This allows running the same test multiple times concurrently with meson's --repeat option. Proposed upstream but not yet merged: https://github.com/mesonbuild/meson/pull/13177. --- test/integration-test-wrapper.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index e3dcf75239f..99ae43ac831 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -51,6 +51,7 @@ def main(): 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( @@ -90,7 +91,7 @@ def main(): """ ) - 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 @@ -100,7 +101,7 @@ def main(): '--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 []), *( From d91bb1cbf073f2777cd3eebd8ff39c58066bd5c1 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 11:38:09 +0200 Subject: [PATCH 25/60] test: Always shutdown on test success in mkosi When we want to get an interactive shell in a test that fails because of a race condition, we might need to run the test a few times with --repeat before it fails. However, currently, when -i is used, the VM needs to be shut down manually each time before the next run can start. Let's always shut down the VM if the test succeeds so that --repeat can be used with -i to run the test until it fails and then get an interactive shell in the VM. --- test/integration-test-wrapper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index 99ae43ac831..a32210c06f1 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -59,6 +59,8 @@ def main(): [Unit] After=multi-user.target network.target Requires=multi-user.target + SuccessAction=exit + SuccessActionExitStatus=123 [Service] StandardOutput=journal+console @@ -85,8 +87,6 @@ def main(): dropin += textwrap.dedent( """ [Unit] - SuccessAction=exit - SuccessActionExitStatus=123 FailureAction=exit """ ) @@ -143,7 +143,7 @@ def main(): 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', From 3beefac9eb1b4b764aea83b9a15eb3048e624c04 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 21:32:49 +0200 Subject: [PATCH 26/60] test: Remove flaky test comments These two tests don't seem to fail in CI, so let's remove the comments about flakyness. --- test/meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/meson.build b/test/meson.build index f93137c07a1..9dac6c0e6cb 100644 --- a/test/meson.build +++ b/test/meson.build @@ -356,7 +356,7 @@ integration_tests = { '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', @@ -383,7 +383,6 @@ integration_tests = { # '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 '59': 'TEST-59-RELOADING-RESTART', '60': 'TEST-60-MOUNT-RATELIMIT', '62': 'TEST-62-RESTRICT-IFACES', From 15faee53098c610a38f6bb063e4bf39c41c0a618 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 21:59:01 +0200 Subject: [PATCH 27/60] test: Add missing TEST-69-SHUTDOWN to list --- test/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/test/meson.build b/test/meson.build index 9dac6c0e6cb..2e776c12ab7 100644 --- a/test/meson.build +++ b/test/meson.build @@ -392,6 +392,7 @@ integration_tests = { '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', From e3ab65cff396b149cbc327296544f1e14eb4d689 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 22:00:29 +0200 Subject: [PATCH 28/60] test: Fix udev storage test name --- test/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/meson.build b/test/meson.build index 2e776c12ab7..3bc321d0ec7 100644 --- a/test/meson.build +++ b/test/meson.build @@ -387,7 +387,7 @@ integration_tests = { '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', From 7afb53371127602af3ea62cde2ce9c24d51cd363 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Fri, 5 Apr 2024 17:38:18 +0100 Subject: [PATCH 29/60] TEST-21-DFUZZER: Skip test if dfuzzer is not installed --- test/units/testsuite-21.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/units/testsuite-21.sh b/test/units/testsuite-21.sh index 7b2013fb51c..08ebfd91eb6 100755 --- a/test/units/testsuite-21.sh +++ b/test/units/testsuite-21.sh @@ -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 From ca72b8f6f8bddef39d0c87ec1e4295e0dd36d095 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 2 May 2024 08:48:57 +0200 Subject: [PATCH 30/60] TEST-21-DFUZZER: Bump timeout to 1h --- test/TEST-21-DFUZZER/meson.build | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/TEST-21-DFUZZER/meson.build diff --git a/test/TEST-21-DFUZZER/meson.build b/test/TEST-21-DFUZZER/meson.build new file mode 100644 index 00000000000..b6fc39eb5a2 --- /dev/null +++ b/test/TEST-21-DFUZZER/meson.build @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +test_params = test_params + { + 'timeout' : 3600, +} From ae25df53bfb2da7c8b18c616450d240862072a9c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 13:29:54 +0200 Subject: [PATCH 31/60] TEST-21-DFUZZER: Give higher priority This test takes a long time to run. Let's make sure it is started first to avoid it being the only test running for a long time at the end. --- test/TEST-21-DFUZZER/meson.build | 1 + test/meson.build | 2 ++ 2 files changed, 3 insertions(+) diff --git a/test/TEST-21-DFUZZER/meson.build b/test/TEST-21-DFUZZER/meson.build index b6fc39eb5a2..03cae4f7dae 100644 --- a/test/TEST-21-DFUZZER/meson.build +++ b/test/TEST-21-DFUZZER/meson.build @@ -2,4 +2,5 @@ test_params = test_params + { 'timeout' : 3600, + 'priority': -50, } diff --git a/test/meson.build b/test/meson.build index 3bc321d0ec7..4854c3806f0 100644 --- a/test/meson.build +++ b/test/meson.build @@ -413,6 +413,7 @@ foreach test_number, dirname : integration_tests 'mkosi_args' : [], 'timeout' : 1800, 'storage' : 'volatile', + 'priority' : 0, } # TODO: This fs.exists call isn't included in rebuild logic @@ -445,5 +446,6 @@ foreach test_number, dirname : integration_tests env : integration_test_env, args : args, timeout : test_params['timeout'], + priority : test_params['priority'], suite : 'integration-tests') endforeach From 9a4f925b5752ab354c21b7f4c4a8161384c114b8 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 1 May 2024 11:54:17 +0200 Subject: [PATCH 32/60] TEST-75-RESOLVED: Move knot configuration to /usr/lib/systemd/tests/testdata This allows the logic to install the configuration to be done inside the test itself which allows it to be shared with mkosi. --- test/TEST-75-RESOLVED/test.sh | 15 --------------- test/meson.build | 1 + test/units/testsuite-75.sh | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/test/TEST-75-RESOLVED/test.sh b/test/TEST-75-RESOLVED/test.sh index 55a9f1b358f..6272d5a2f89 100755 --- a/test/TEST-75-RESOLVED/test.sh +++ b/test/TEST-75-RESOLVED/test.sh @@ -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 diff --git a/test/meson.build b/test/meson.build index 4854c3806f0..43314f8c794 100644 --- a/test/meson.build +++ b/test/meson.build @@ -4,6 +4,7 @@ if install_tests foreach subdir : [ 'auxv', 'journal-data', + 'knot-data', 'test-journals', 'units', 'test-execute', diff --git a/test/units/testsuite-75.sh b/test/units/testsuite-75.sh index fc29e642fb0..fbb46bf2610 100755 --- a/test/units/testsuite-75.sh +++ b/test/units/testsuite-75.sh @@ -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 @@ -268,6 +282,7 @@ systemctl start 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 From a37e58a15605bb8966316816953497fe47dbe9a6 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 4 May 2024 12:18:50 +0200 Subject: [PATCH 33/60] TEST-75-RESOLVED: Restart systemd-networkd systemd-networkd might already be running, let's make sure we restart it if it is already running. --- test/units/testsuite-75.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/units/testsuite-75.sh b/test/units/testsuite-75.sh index fbb46bf2610..c447256526d 100755 --- a/test/units/testsuite-75.sh +++ b/test/units/testsuite-75.sh @@ -278,7 +278,7 @@ 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 From 9cd3e292c6b3fc7fdd9facee37b849bedf1bf70e Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 4 May 2024 12:19:23 +0200 Subject: [PATCH 34/60] TEST-75-RESOLVED: Add missing sleep after knotc reload We already have this workaround for knotc reload a little further in the test, let's apply it to our first invocation of knotc reload as well. --- test/units/testsuite-75.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/units/testsuite-75.sh b/test/units/testsuite-75.sh index c447256526d..4a1afad9bac 100755 --- a/test/units/testsuite-75.sh +++ b/test/units/testsuite-75.sh @@ -324,6 +324,7 @@ done < <(keymgr onlinesign.test. ds) knotc zone-commit test. knotc reload +sleep 2 ### SETUP END ### From 904fc035cb65c56667be5051d67a1f981dbb450c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 4 May 2024 12:20:24 +0200 Subject: [PATCH 35/60] TEST-75-RESOLVED: Ignore resource record ifindex field Depending on host configuration this may or may not be included (e.g. on mkosi we get a result without an ifindex field). Let's strip it from the resolved reply to avoid failing the test. --- test/units/testsuite-75.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/units/testsuite-75.sh b/test/units/testsuite-75.sh index 4a1afad9bac..a4417ce5751 100755 --- a/test/units/testsuite-75.sh +++ b/test/units/testsuite-75.sh @@ -878,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 { From b7b6bdc9e0748ff7657e1e2b14527a863f27b349 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 22 Feb 2024 13:01:13 +0000 Subject: [PATCH 36/60] TEST-74-AUX-UTILS: Support credential-provided root SSH public key When root authorized keys are provided by mkosi they are not newline-terminated so appending a public key to the file results in a corrupt key, so just to be safe we add an empty line. --- test/units/testsuite-74.ssh.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/units/testsuite-74.ssh.sh b/test/units/testsuite-74.ssh.sh index 70fb9ce56ca..5d87d9f7acd 100755 --- a/test/units/testsuite-74.ssh.sh +++ b/test/units/testsuite-74.ssh.sh @@ -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 From fe8d7d25d5f64084a1afeb2a14244db72053ad2f Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 22 Feb 2024 13:00:48 +0000 Subject: [PATCH 37/60] TEST-74-AUX-UTILS: Support systems with pre-existing modules config --- test/units/testsuite-74.modules-load.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/units/testsuite-74.modules-load.sh b/test/units/testsuite-74.modules-load.sh index 3d00e07f07c..aea2f3cbdea 100755 --- a/test/units/testsuite-74.modules-load.sh +++ b/test/units/testsuite-74.modules-load.sh @@ -17,6 +17,8 @@ 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 @@ -75,7 +77,7 @@ modprobe -v --all --remove loop 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)" ]] +[[ "$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=loop,loop,loop" SYSTEMD_PROC_CMDLINE="$CMDLINE" "$MODULES_LOAD_BIN" |& tee /tmp/out.log grep -E "^Inserted module .*loop" /tmp/out.log From 8c9d241c55555cfd840a67746d767b71ce58e6d9 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 22 Feb 2024 13:00:00 +0000 Subject: [PATCH 38/60] TEST-74-AUX-UTILS: Support running on UEFI systems --- test/units/testsuite-74.bootctl.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/units/testsuite-74.bootctl.sh b/test/units/testsuite-74.bootctl.sh index 133006e40a4..78c0e6e5d9d 100755 --- a/test/units/testsuite-74.bootctl.sh +++ b/test/units/testsuite-74.bootctl.sh @@ -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 From a2190c22b83586545a09d7e10e941cec4f4f1280 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 2 May 2024 09:16:28 +0200 Subject: [PATCH 39/60] TEST-74-AUX-UTILS: Make sure at least two locales exist --- test/units/testsuite-73.sh | 34 ++-------------------------- test/units/testsuite-74.firstboot.sh | 22 ++++++++++++++++++ test/units/util.sh | 33 +++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 32 deletions(-) diff --git a/test/units/testsuite-73.sh b/test/units/testsuite-73.sh index df5af4ba873..18539b8eab2 100755 --- a/test/units/testsuite-73.sh +++ b/test/units/testsuite-73.sh @@ -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 diff --git a/test/units/testsuite-74.firstboot.sh b/test/units/testsuite-74.firstboot.sh index be08575c9e6..7bab009d529 100755 --- a/test/units/testsuite-74.firstboot.sh +++ b/test/units/testsuite-74.firstboot.sh @@ -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" diff --git a/test/units/util.sh b/test/units/util.sh index 879e962fe94..cc9d5ec48f6 100755 --- a/test/units/util.sh +++ b/test/units/util.sh @@ -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 +} From da87c35f3537a1ee304f1d01e19cd50741da90b2 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 14:09:27 +0200 Subject: [PATCH 40/60] TEST-74-AUX-UTILS: Skip run0 test if pam snippet is not installed --- test/units/testsuite-74.run.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/test/units/testsuite-74.run.sh b/test/units/testsuite-74.run.sh index 4f3c967e2cf..b4ff72e440d 100755 --- a/test/units/testsuite-74.run.sh +++ b/test/units/testsuite-74.run.sh @@ -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 From 3d5c6ece1c72fc1d7616f1e878935b0fa310e2ed Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 15:56:52 +0200 Subject: [PATCH 41/60] TEST-74-AUX-UTILS: Drop usage of loop module This module is builtin on ubuntu causing the test to fail. Let's use just dummy instead. I tried replacing it with scsi_debug but that caused issues with modprobe complaining it could not remove scsi_debug because it was in use. --- test/units/testsuite-74.modules-load.sh | 38 +++++++++++-------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/test/units/testsuite-74.modules-load.sh b/test/units/testsuite-74.modules-load.sh index aea2f3cbdea..ceac8262bfd 100755 --- a/test/units/testsuite-74.modules-load.sh +++ b/test/units/testsuite-74.modules-load.sh @@ -20,7 +20,7 @@ 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/ @@ -29,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" < Date: Sun, 5 May 2024 11:44:50 +0200 Subject: [PATCH 42/60] TEST-74-AUX-UTILS: Use persistent journal This test depends on having the journal in /var/log/journal. --- test/TEST-74-AUX-UTILS/meson.build | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/TEST-74-AUX-UTILS/meson.build diff --git a/test/TEST-74-AUX-UTILS/meson.build b/test/TEST-74-AUX-UTILS/meson.build new file mode 100644 index 00000000000..7f5cc704c9d --- /dev/null +++ b/test/TEST-74-AUX-UTILS/meson.build @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +test_params += { + 'storage': 'persistent', +} From 6b146cef3ffaae82ec0b06f19d89abc9b4f6314c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 10:27:23 +0200 Subject: [PATCH 43/60] TEST-70-TPM2: Add dependency on tpm2.target Let's make sure the TPM is available before running the test as the test makes use of it. --- test/units/testsuite-70.service | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/units/testsuite-70.service b/test/units/testsuite-70.service index c13c2d51a32..a9c15429d42 100644 --- a/test/units/testsuite-70.service +++ b/test/units/testsuite-70.service @@ -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 From b95bb3b3bbdc1016712f892012ba5f1341c56946 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 19:15:11 +0200 Subject: [PATCH 44/60] TEST-70-TPM2: Call udevadm wait after attaching disk image Otherwise /dev/loop0p1 might not exist when calling systemd-cryptsetup attach. --- test/units/testsuite-70.cryptsetup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/units/testsuite-70.cryptsetup.sh b/test/units/testsuite-70.cryptsetup.sh index 4cd627fe1a9..0ecf34b6c86 100755 --- a/test/units/testsuite-70.cryptsetup.sh +++ b/test/units/testsuite-70.cryptsetup.sh @@ -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 From 7590e1d037c7b0bf2e9d775c6722d13eef315566 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 17 Apr 2024 16:10:09 +0100 Subject: [PATCH 45/60] TEST-07-PID1: Move mount units to test dir To load the units it is sufficient to add them to the units directory and it's a step towards not needing any customisations for this test. --- test/TEST-07-PID1/test.sh | 15 --------------- test/testsuite-07.units/issue2730-alias.mount | 1 + test/testsuite-07.units/issue2730.mount | 8 ++++++++ .../local-fs.target.wants/issue2730.mount | 1 + 4 files changed, 10 insertions(+), 15 deletions(-) create mode 120000 test/testsuite-07.units/issue2730-alias.mount create mode 100644 test/testsuite-07.units/issue2730.mount create mode 120000 test/testsuite-07.units/local-fs.target.wants/issue2730.mount diff --git a/test/TEST-07-PID1/test.sh b/test/TEST-07-PID1/test.sh index cc8a81f77df..b60f1db68fd 100755 --- a/test/TEST-07-PID1/test.sh +++ b/test/TEST-07-PID1/test.sh @@ -21,21 +21,6 @@ test_append_files() { 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" < Date: Sat, 4 May 2024 13:22:53 +0200 Subject: [PATCH 46/60] TEST-07-PID1: Lower TriggerLimitIntervalSec= unconditionally It shouldn't hurt to do this when KVM is enabled or we're not collecting coverage so let's just always lower the trigger limit interval. --- test/TEST-07-PID1/test.sh | 10 ---------- test/testsuite-07.units/issue2467.socket | 4 ++++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/test/TEST-07-PID1/test.sh b/test/TEST-07-PID1/test.sh index b60f1db68fd..2513406e0de 100755 --- a/test/TEST-07-PID1/test.sh +++ b/test/TEST-07-PID1/test.sh @@ -11,16 +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 - image_install logger socat } diff --git a/test/testsuite-07.units/issue2467.socket b/test/testsuite-07.units/issue2467.socket index af1317b409d..209b6bbce5d 100644 --- a/test/testsuite-07.units/issue2467.socket +++ b/test/testsuite-07.units/issue2467.socket @@ -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 From c5073aa2044bf44402a7ddfd01420e9db39a255b Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 17 Apr 2024 13:03:12 +0100 Subject: [PATCH 47/60] TEST-07-PID1: Test access to allocated loop instead of loop0 loop0 and 1 can be used by systemd-repart and vanish but we can guarantee that $LODEV was allocated and is available. --- test/units/testsuite-07.exec-context.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/units/testsuite-07.exec-context.sh b/test/units/testsuite-07.exec-context.sh index 10388d8526b..a3379ef4020 100755 --- a/test/units/testsuite-07.exec-context.sh +++ b/test/units/testsuite-07.exec-context.sh @@ -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*= From e86afb0314ef26fc122eb63a4418867289b45b68 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 4 May 2024 22:19:22 +0200 Subject: [PATCH 48/60] TEST-07-PID1: Schedule exit on successful execution The test unit has RemainAfterExit=yes so let's schedule our own shutdown from the test itself once we finish running. --- test/units/testsuite-07.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/units/testsuite-07.sh b/test/units/testsuite-07.sh index 2ee1457753a..873d638f76d 100755 --- a/test/units/testsuite-07.sh +++ b/test/units/testsuite-07.sh @@ -13,3 +13,4 @@ mountpoint /issue2730 run_subtests touch /testok +systemctl --no-block exit 123 From 0214a8fd754ad229aab7d35c2e9b9fee28a386a6 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 4 May 2024 16:32:57 +0200 Subject: [PATCH 49/60] TEST-04-JOURNAL: Make more robust Avoid hitting https://github.com/systemd/systemd/issues/2913 by adding some more sleeps. This is required to make the test pass when executed with mkosi on my machine. --- test/testsuite-04.units/verbose-success.service | 7 ++++++- test/units/testsuite-04.journal.sh | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/testsuite-04.units/verbose-success.service b/test/testsuite-04.units/verbose-success.service index 67c8bf10079..f4a86fd2b22 100644 --- a/test/testsuite-04.units/verbose-success.service +++ b/test/testsuite-04.units/verbose-success.service @@ -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 diff --git a/test/units/testsuite-04.journal.sh b/test/units/testsuite-04.journal.sh index 9ca1b789e3b..bb4f66d2c89 100755 --- a/test/units/testsuite-04.journal.sh +++ b/test/units/testsuite-04.journal.sh @@ -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" From f74fb048f927c7fa1d64db4b8da83aef2a377f41 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 11:46:43 +0200 Subject: [PATCH 50/60] TEST-04-JOURNAL: Run with persistent journal This test depends on having the journal in /var/log/journal. --- test/TEST-04-JOURNAL/meson.build | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/TEST-04-JOURNAL/meson.build diff --git a/test/TEST-04-JOURNAL/meson.build b/test/TEST-04-JOURNAL/meson.build new file mode 100644 index 00000000000..7f5cc704c9d --- /dev/null +++ b/test/TEST-04-JOURNAL/meson.build @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +test_params += { + 'storage': 'persistent', +} From f1d3962e6151b71779b148936ae8d67636dea8f9 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 13:58:38 +0200 Subject: [PATCH 51/60] TEST-04-JOURNAL: Skip bsod test if systemd-bsod is not installed systemd is built without qrencode support on CentOS which means systemd-bsod will not be installed. Let's skip the test if that's the case. --- test/units/testsuite-04.bsod.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/units/testsuite-04.bsod.sh b/test/units/testsuite-04.bsod.sh index 36092fe821d..83feb892be0 100755 --- a/test/units/testsuite-04.bsod.sh +++ b/test/units/testsuite-04.bsod.sh @@ -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 From 9be49de41f6a3d37a07d817866dcbfbd3fa62780 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 19 Feb 2024 17:28:00 +0000 Subject: [PATCH 52/60] TEST-55-OOMD: swapoff before adding new swapfile When running test images built with read-only /usr a swap partition is likely so needs to be turned off first. --- test/units/testsuite-55.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/units/testsuite-55.sh b/test/units/testsuite-55.sh index e5d930175f7..e803ea89c43 100755 --- a/test/units/testsuite-55.sh +++ b/test/units/testsuite-55.sh @@ -23,6 +23,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 From 8f5095ff744d5362f09458e049952868ffc2daa7 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 10:39:32 +0200 Subject: [PATCH 53/60] TEST-55-OOMD: Skip on opensuse opensuse does not have the stress tool packaged. --- test/units/testsuite-55.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/units/testsuite-55.sh b/test/units/testsuite-55.sh index e803ea89c43..5bc0eaec75e 100755 --- a/test/units/testsuite-55.sh +++ b/test/units/testsuite-55.sh @@ -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 From 9e71acab00cc1eb4b634b8d8c5f4cbb3453d4656 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 10:46:01 +0200 Subject: [PATCH 54/60] TEST-55-OOMD: Configure init.scope credential in mkosi image --- test/TEST-55-OOMD/meson.build | 7 +++++++ test/TEST-55-OOMD/systemd.unit-dropin.init.scope | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 test/TEST-55-OOMD/meson.build create mode 100644 test/TEST-55-OOMD/systemd.unit-dropin.init.scope diff --git a/test/TEST-55-OOMD/meson.build b/test/TEST-55-OOMD/meson.build new file mode 100644 index 00000000000..86a0d8f9572 --- /dev/null +++ b/test/TEST-55-OOMD/meson.build @@ -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') + ] +} diff --git a/test/TEST-55-OOMD/systemd.unit-dropin.init.scope b/test/TEST-55-OOMD/systemd.unit-dropin.init.scope new file mode 100644 index 00000000000..31b7f90957b --- /dev/null +++ b/test/TEST-55-OOMD/systemd.unit-dropin.init.scope @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Scope] +MemoryHigh=infinity +StartupMemoryHigh=10G From 6ff6b2e29b95c116aa4286865d09e5709e0a540a Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 22:17:38 +0200 Subject: [PATCH 55/60] TEST-53-ISSUE-16347: Add rtc configuration for qemu --- test/TEST-53-ISSUE-16347/meson.build | 7 +++++++ test/TEST-53-ISSUE-16347/mkosi.configure | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 test/TEST-53-ISSUE-16347/meson.build create mode 100755 test/TEST-53-ISSUE-16347/mkosi.configure diff --git a/test/TEST-53-ISSUE-16347/meson.build b/test/TEST-53-ISSUE-16347/meson.build new file mode 100644 index 00000000000..0b7644f4ad2 --- /dev/null +++ b/test/TEST-53-ISSUE-16347/meson.build @@ -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', + ], +} diff --git a/test/TEST-53-ISSUE-16347/mkosi.configure b/test/TEST-53-ISSUE-16347/mkosi.configure new file mode 100755 index 00000000000..d754fe46e2b --- /dev/null +++ b/test/TEST-53-ISSUE-16347/mkosi.configure @@ -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\"]" From 7a273d657084042c458db484fc62b05606888cf5 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 6 May 2024 11:46:52 +0200 Subject: [PATCH 56/60] TEST-46-HOMED: Only run resize tests on btrfs Other filesystems do not support online shrinking. --- test/units/testsuite-46.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/units/testsuite-46.sh b/test/units/testsuite-46.sh index 7d84b0d04d1..e4d2f704103 100755 --- a/test/units/testsuite-46.sh +++ b/test/units/testsuite-46.sh @@ -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 From a90bba42f499fb47d90236f21f779a3341aacd82 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 6 May 2024 11:47:34 +0200 Subject: [PATCH 57/60] TEST-46-HOMED: Skip barely fits test on ext4 For some reason this fails on ext4 with "No space left on device". Until we figure out why, let's skip the test on ext4 (which is reported as ext2/ext3 by stat). --- test/units/testsuite-46.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/test/units/testsuite-46.sh b/test/units/testsuite-46.sh index e4d2f704103..61f17d4e46b 100755 --- a/test/units/testsuite-46.sh +++ b/test/units/testsuite-46.sh @@ -326,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 ) From 1f2c9bda495e062c34b891ca8e77ce0ec43a5012 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 5 May 2024 18:14:44 +0200 Subject: [PATCH 58/60] test: Default to linux qemu firmware Direct kernel boot results in much faster boot times so let's use it by default. We disable it for tests that need to reboot because +-50% of the time, doing a reboot when using direct kernel boot causes qemu to hang on reboot. Until we figure that out, let's use UEFI for the tests that need to reboot. --- test/TEST-06-SELINUX/meson.build | 2 ++ test/TEST-09-REBOOT/meson.build | 2 ++ test/TEST-18-FAILUREACTION/meson.build | 6 ++++++ test/integration-test-wrapper.py | 2 ++ test/meson.build | 2 ++ 5 files changed, 14 insertions(+) create mode 100644 test/TEST-18-FAILUREACTION/meson.build diff --git a/test/TEST-06-SELINUX/meson.build b/test/TEST-06-SELINUX/meson.build index 50247d3e473..a62d144048e 100644 --- a/test/TEST-06-SELINUX/meson.build +++ b/test/TEST-06-SELINUX/meson.build @@ -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', } diff --git a/test/TEST-09-REBOOT/meson.build b/test/TEST-09-REBOOT/meson.build index 7f5cc704c9d..a511a829af2 100644 --- a/test/TEST-09-REBOOT/meson.build +++ b/test/TEST-09-REBOOT/meson.build @@ -2,4 +2,6 @@ test_params += { 'storage': 'persistent', + # FIXME; Figure out why reboot sometimes hangs with 'linux' firmware. + 'firmware' : 'uefi', } diff --git a/test/TEST-18-FAILUREACTION/meson.build b/test/TEST-18-FAILUREACTION/meson.build new file mode 100644 index 00000000000..e1bca2d7a83 --- /dev/null +++ b/test/TEST-18-FAILUREACTION/meson.build @@ -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', +} diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index a32210c06f1..575403344e4 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -48,6 +48,7 @@ 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() @@ -119,6 +120,7 @@ def main(): '--runtime-network=none', '--runtime-scratch=no', '--append', + '--qemu-firmware', args.firmware, '--kernel-command-line-extra', ' '.join([ 'systemd.hostname=H', diff --git a/test/meson.build b/test/meson.build index 43314f8c794..f5c48cedba5 100644 --- a/test/meson.build +++ b/test/meson.build @@ -415,6 +415,7 @@ foreach test_number, dirname : integration_tests 'timeout' : 1800, 'storage' : 'volatile', 'priority' : 0, + 'firmware' : 'linux', } # TODO: This fs.exists call isn't included in rebuild logic @@ -430,6 +431,7 @@ 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'] From eabf46ef89fe446dbf0a4df552fb0f6584418e36 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 3 May 2024 10:57:22 +0200 Subject: [PATCH 59/60] ci: Reduce the number of integration tests we run concurrently Since there's a bunch of CPU hungry systemd-journal-remote processes running on the host to received the forwarded logs, by running as many test as the VM has cores we overload the available resources. Let's leave use the number of cores - 1 to reduce resource contention. --- .github/workflows/mkosi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index 22e084bf7b3..eed78696f3a 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -180,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 From 77962e1242cb31b88ede015e684a534298f5ea3f Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 1 May 2024 09:37:55 +0200 Subject: [PATCH 60/60] mkosi: Enable more integration tests --- test/meson.build | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/meson.build b/test/meson.build index f5c48cedba5..63b94b1c7a1 100644 --- a/test/meson.build +++ b/test/meson.build @@ -348,10 +348,10 @@ 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', @@ -360,15 +360,15 @@ integration_tests = { '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', @@ -377,13 +377,13 @@ 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', + '55': 'TEST-55-OOMD', + '58': 'TEST-58-REPART', '59': 'TEST-59-RELOADING-RESTART', '60': 'TEST-60-MOUNT-RATELIMIT', '62': 'TEST-62-RESTRICT-IFACES', @@ -397,9 +397,9 @@ integration_tests = { '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',