From 8f764b32eabd3d39abfc0f4eaffd282223df4768 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 27 Nov 2023 17:48:24 +0000 Subject: [PATCH 1/7] test: Create analyze chroot with --rbind The systemd-analyze integration test also tests chroots. It builds its chroot by bind-mounting /, but since /usr might be a separate mountpoint it should create the chroot with --rbind. --- test/units/testsuite-65.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/units/testsuite-65.sh b/test/units/testsuite-65.sh index 6c819dfe4a..6415734651 100755 --- a/test/units/testsuite-65.sh +++ b/test/units/testsuite-65.sh @@ -179,7 +179,7 @@ systemd-analyze security --json=short | jq if [[ ! -v ASAN_OPTIONS ]]; then # check that systemd-analyze cat-config paths work in a chroot mkdir -p /tmp/root - mount --bind / /tmp/root + mount --rbind / /tmp/root systemd-analyze cat-config systemd/system-preset >/tmp/out1 chroot /tmp/root systemd-analyze cat-config systemd/system-preset >/tmp/out2 diff /tmp/out{1,2} From 0129395173773574cca07523797df18980baf7ff Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 5 Dec 2023 18:09:18 +0000 Subject: [PATCH 2/7] test: slacken plugged -> dead test This test is for if devices transition from plugged -> dead -> plugged on boot, but it is normal to see loop devices transition plugged -> dead on first boot when systemd-repart adds the root partition. --- test/units/testsuite-31.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/units/testsuite-31.sh b/test/units/testsuite-31.sh index 03aba36ab8..5e99302299 100755 --- a/test/units/testsuite-31.sh +++ b/test/units/testsuite-31.sh @@ -3,7 +3,7 @@ set -eux set -o pipefail -if journalctl -b -t systemd --grep '\.device: Changed plugged -> dead'; then +if journalctl -b -t systemd --grep '(? dead'; then exit 1 fi From 8799346862285903a2348dad5e0a0cf513f8317e Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Fri, 8 Dec 2023 18:56:25 +0000 Subject: [PATCH 3/7] test: mount overlayfs over /usr in some tests Most of the integration tests have been made to not write to /usr but some genuinely need to do so. Because mkosi creates images with a read-only /usr it is not normally writeable. By mounting an overlayfs with /usr as the lower dir and upper and working dirs in /var tests may write to /usr. --- test/units/testsuite-15.sh | 5 +++++ test/units/testsuite-26.sh | 3 +++ test/units/testsuite-60.sh | 3 +++ test/units/testsuite-73.sh | 3 +++ test/units/util.sh | 16 ++++++++++++++++ 5 files changed, 30 insertions(+) diff --git a/test/units/testsuite-15.sh b/test/units/testsuite-15.sh index e790b37c70..0266f6266f 100755 --- a/test/units/testsuite-15.sh +++ b/test/units/testsuite-15.sh @@ -5,6 +5,11 @@ set -o pipefail # shellcheck source=test/units/test-control.sh . "$(dirname "$0")"/test-control.sh +# shellcheck source=test/units/util.sh +. "$(dirname "$0")"/util.sh + +maybe_mount_usr_overlay +trap 'maybe_umount_usr_overlay' EXIT clear_unit() { local unit_name="${1:?}" diff --git a/test/units/testsuite-26.sh b/test/units/testsuite-26.sh index 5aaac099f4..9f672c738a 100755 --- a/test/units/testsuite-26.sh +++ b/test/units/testsuite-26.sh @@ -12,10 +12,13 @@ at_exit() { rm -fvr "/usr/lib/systemd/system/$UNIT_NAME" "/etc/systemd/system/$UNIT_NAME.d" "+4" fi + maybe_umount_usr_overlay + rm -f /etc/init.d/issue-24990 return 0 } +maybe_mount_usr_overlay trap at_exit EXIT # Create a simple unit file for testing diff --git a/test/units/testsuite-60.sh b/test/units/testsuite-60.sh index e800a7a12c..3d0723e7dc 100755 --- a/test/units/testsuite-60.sh +++ b/test/units/testsuite-60.sh @@ -6,6 +6,9 @@ set -o pipefail # shellcheck source=test/units/util.sh . "$(dirname "$0")"/util.sh +maybe_mount_usr_overlay +trap 'maybe_umount_usr_overlay' EXIT + teardown_test_dependencies() ( set +eux diff --git a/test/units/testsuite-73.sh b/test/units/testsuite-73.sh index df5af4ba87..3e5b78879a 100755 --- a/test/units/testsuite-73.sh +++ b/test/units/testsuite-73.sh @@ -9,6 +9,9 @@ set -o pipefail # shellcheck source=test/units/util.sh . "$(dirname "$0")"/util.sh +maybe_mount_usr_overlay +trap 'maybe_umount_usr_overlay' EXIT + enable_debug() { mkdir -p /run/systemd/system/systemd-localed.service.d cat >>/run/systemd/system/systemd-localed.service.d/override.conf < Date: Tue, 5 Dec 2023 18:06:40 +0000 Subject: [PATCH 4/7] mkosi: Allow the output directory to be overridden For integration tests it would be preferable to operate on a copy so tests can be run in parallel and avoid interfering. --- mkosi.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi.conf b/mkosi.conf index 9961407a04..5e941959e5 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -4,7 +4,7 @@ Images=system [Output] -OutputDirectory=mkosi.output +@OutputDirectory=mkosi.output BuildDirectory=mkosi.builddir CacheDirectory=mkosi.cache From 0947748555c77754e09f0c6fe6919112b0aed2f0 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 27 Nov 2023 17:50:49 +0000 Subject: [PATCH 5/7] mkosi: Add testuser and tar to system image The integration tests are installed into the image with the intention that it should be possible to run those tests, but those tests require the named user testuser and tar is needed for machined-import --- mkosi.images/system/mkosi.conf | 1 + mkosi.images/system/mkosi.postinst.chroot | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/mkosi.images/system/mkosi.conf b/mkosi.images/system/mkosi.conf index 7612f221cc..6948f8eb7c 100644 --- a/mkosi.images/system/mkosi.conf +++ b/mkosi.images/system/mkosi.conf @@ -33,6 +33,7 @@ Packages= strace systemd tmux + tar tree udev util-linux diff --git a/mkosi.images/system/mkosi.postinst.chroot b/mkosi.images/system/mkosi.postinst.chroot index e0728de279..0fec067ebb 100755 --- a/mkosi.images/system/mkosi.postinst.chroot +++ b/mkosi.images/system/mkosi.postinst.chroot @@ -83,3 +83,12 @@ if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 alternatives --set python3 /usr/bin/python3.9 fi + +mkdir -p /usr/lib/sysusers.d +cat >/usr/lib/sysusers.d/testuser.conf </usr/lib/tmpfiles.d/testuser.conf < Date: Tue, 12 Dec 2023 13:14:36 +0000 Subject: [PATCH 6/7] mkosi: Install locales in fedora locale files are not generated on-demand in Fedora like they are in Debian-like systems and are typically installed from package instead. This is necessary for the locale tests, which expect en_US.UTF-8 to be available. --- mkosi.images/system/mkosi.conf.d/10-fedora.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkosi.images/system/mkosi.conf.d/10-fedora.conf b/mkosi.images/system/mkosi.conf.d/10-fedora.conf index 281e9464f6..620688e51b 100644 --- a/mkosi.images/system/mkosi.conf.d/10-fedora.conf +++ b/mkosi.images/system/mkosi.conf.d/10-fedora.conf @@ -8,4 +8,5 @@ Packages= btrfs-progs compsize f2fs-tools + glibc-langpack-en kernel-core From 566f1000d1850e821026dc4ed77e7701b20162a1 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Fri, 8 Dec 2023 18:47:04 +0000 Subject: [PATCH 7/7] mkosi: make sysvinit path inference consistent The integration tests use /etc/rc.d/init.d if it exists or falls back to /etc/init.d, while the mkosi.build.chroot script dereferenced /etc/init.d. This produces inconsistent results, as sometimes an image can be made that has systemd built to expect /etc/init.d but /etc/rc.d/init.d also exists. --- mkosi.images/base/mkosi.build.chroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi.images/base/mkosi.build.chroot b/mkosi.images/base/mkosi.build.chroot index f26098cedf..b60ed8d731 100755 --- a/mkosi.images/base/mkosi.build.chroot +++ b/mkosi.images/base/mkosi.build.chroot @@ -44,7 +44,7 @@ EOF fi if [ ! -f "$BUILDDIR"/build.ninja ]; then - sysvinit_path=$(realpath /etc/init.d) + [[ -d /etc/rc.d/init.d ]] && sysvinit_path="/etc/rc.d/init.d" || sysvinit_path="/etc/init.d" if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then UKIFY="disabled"