diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-05-15 11:58:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 11:58:22 +0200 |
commit | 1f225d4ef180ef0556e3523956a5960e41633b04 (patch) | |
tree | 7952bc91ccd15e5d7f84a665f0b5fa02fb8cde4d | |
parent | Merge pull request #32666 from DaanDeMeyer/mkosi-network (diff) | |
parent | test: Enable TEST-08-INITRD on mkosi (diff) | |
download | systemd-1f225d4ef180ef0556e3523956a5960e41633b04.tar.xz systemd-1f225d4ef180ef0556e3523956a5960e41633b04.zip |
Merge pull request #32835 from DaanDeMeyer/test
test: Enable TEST-08-INITRD on mkosi
-rw-r--r-- | mkosi.images/exitrd/mkosi.conf | 22 | ||||
-rw-r--r-- | mkosi.images/exitrd/mkosi.conf.d/10-arch.conf | 34 | ||||
-rw-r--r-- | mkosi.images/exitrd/mkosi.conf.d/10-centos-fedora.conf | 9 | ||||
-rw-r--r-- | mkosi.images/exitrd/mkosi.conf.d/10-debian-ubuntu.conf | 9 | ||||
-rw-r--r-- | mkosi.images/exitrd/mkosi.conf.d/10-opensuse.conf | 8 | ||||
-rwxr-xr-x | mkosi.images/exitrd/mkosi.extra/shutdown | 12 | ||||
-rw-r--r-- | mkosi.images/system/initrd/mkosi.extra/usr/lib/systemd/system/initrd-run-mount.service | 11 | ||||
-rw-r--r-- | mkosi.images/system/mkosi.conf | 2 | ||||
-rw-r--r-- | test/TEST-08-INITRD/meson.build | 5 | ||||
-rwxr-xr-x | test/TEST-08-INITRD/test.sh | 30 | ||||
-rw-r--r-- | test/TEST-21-DFUZZER/meson.build | 2 | ||||
-rw-r--r-- | test/TEST-64-UDEV-STORAGE/meson.build | 1 | ||||
-rw-r--r-- | test/TEST-85-NETWORK/meson.build | 1 | ||||
-rwxr-xr-x | test/integration-test-wrapper.py | 6 | ||||
-rw-r--r-- | test/meson.build | 2 | ||||
-rwxr-xr-x | test/units/TEST-08-INITRD.sh | 2 |
16 files changed, 135 insertions, 21 deletions
diff --git a/mkosi.images/exitrd/mkosi.conf b/mkosi.images/exitrd/mkosi.conf new file mode 100644 index 0000000000..2e867cbd45 --- /dev/null +++ b/mkosi.images/exitrd/mkosi.conf @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Config] +ConfigureScripts= + +[Output] +Format=directory + +[Content] +Bootable=no +@Locale=C.UTF-8 +WithDocs=no +CleanPackageMetadata=yes +MakeInitrd=yes + +BuildSources= +Packages= +BuildPackages= +VolatilePackages= + +Packages= + bash diff --git a/mkosi.images/exitrd/mkosi.conf.d/10-arch.conf b/mkosi.images/exitrd/mkosi.conf.d/10-arch.conf new file mode 100644 index 0000000000..25d20887ff --- /dev/null +++ b/mkosi.images/exitrd/mkosi.conf.d/10-arch.conf @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=arch + +[Content] +Packages= + systemd + +RemoveFiles= + # Arch Linux doesn't split their gcc-libs package so we manually remove + # unneeded stuff here to make sure it doesn't end up in the image. + /usr/lib/libgfortran.so* + /usr/lib/libgo.so* + /usr/lib/libgomp.so* + /usr/lib/libgphobos.so* + /usr/lib/libobjc.so* + /usr/lib/libasan.so* + /usr/lib/libtsan.so* + /usr/lib/liblsan.so* + /usr/lib/libubsan.so* + /usr/lib/libstdc++.so* + /usr/lib/libgdruntime.so* + + # Remove all files that are only required for development. + /usr/lib/*.a + /usr/include/* + + /usr/share/i18n/* + /usr/share/hwdata/* + /usr/share/iana-etc/* + /usr/share/locale/* + /usr/share/terminfo/* + /usr/share/zoneinfo/* diff --git a/mkosi.images/exitrd/mkosi.conf.d/10-centos-fedora.conf b/mkosi.images/exitrd/mkosi.conf.d/10-centos-fedora.conf new file mode 100644 index 0000000000..8458dee37e --- /dev/null +++ b/mkosi.images/exitrd/mkosi.conf.d/10-centos-fedora.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=|centos +Distribution=|fedora + +[Content] +Packages= + systemd-standalone-shutdown diff --git a/mkosi.images/exitrd/mkosi.conf.d/10-debian-ubuntu.conf b/mkosi.images/exitrd/mkosi.conf.d/10-debian-ubuntu.conf new file mode 100644 index 0000000000..babde60c9f --- /dev/null +++ b/mkosi.images/exitrd/mkosi.conf.d/10-debian-ubuntu.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=|debian +Distribution=|ubuntu + +[Content] +Packages= + systemd diff --git a/mkosi.images/exitrd/mkosi.conf.d/10-opensuse.conf b/mkosi.images/exitrd/mkosi.conf.d/10-opensuse.conf new file mode 100644 index 0000000000..3f6df21f84 --- /dev/null +++ b/mkosi.images/exitrd/mkosi.conf.d/10-opensuse.conf @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=opensuse + +[Content] +Packages= + systemd diff --git a/mkosi.images/exitrd/mkosi.extra/shutdown b/mkosi.images/exitrd/mkosi.extra/shutdown new file mode 100755 index 0000000000..e4c60871e8 --- /dev/null +++ b/mkosi.images/exitrd/mkosi.extra/shutdown @@ -0,0 +1,12 @@ +#!/usr/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eux + +EXIT_CODE=() + +# Translate a successful exit code to 124 so that we can detect that the exitrd was actually used. +if [[ "$*" == *"--exit-code=123"* ]]; then + EXIT_CODE+=("--exit-code=124") +fi + +exec /usr/lib/systemd/systemd-shutdown "$@" "${EXIT_CODE[@]}" diff --git a/mkosi.images/system/initrd/mkosi.extra/usr/lib/systemd/system/initrd-run-mount.service b/mkosi.images/system/initrd/mkosi.extra/usr/lib/systemd/system/initrd-run-mount.service new file mode 100644 index 0000000000..845ac57455 --- /dev/null +++ b/mkosi.images/system/initrd/mkosi.extra/usr/lib/systemd/system/initrd-run-mount.service @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Unit] +Description=Create a mount in /run that should survive the transition from initrd + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=mkdir /run/initrd-mount-source /run/initrd-mount-target +ExecStart=mount -v --bind /run/initrd-mount-source /run/initrd-mount-target +ExecStart=cp -v /etc/initrd-release /run/initrd-mount-target/hello-world diff --git a/mkosi.images/system/mkosi.conf b/mkosi.images/system/mkosi.conf index 65e5de379f..f18ad022ad 100644 --- a/mkosi.images/system/mkosi.conf +++ b/mkosi.images/system/mkosi.conf @@ -2,6 +2,7 @@ [Config] Dependencies= + exitrd minimal-base minimal-0 minimal-1 @@ -24,6 +25,7 @@ ExtraTrees= %O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity %O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig %O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template + %O/exitrd:/exitrd Packages= acl diff --git a/test/TEST-08-INITRD/meson.build b/test/TEST-08-INITRD/meson.build index d53dbe562c..34edec0d35 100644 --- a/test/TEST-08-INITRD/meson.build +++ b/test/TEST-08-INITRD/meson.build @@ -3,6 +3,9 @@ integration_tests += [ integration_test_template + { 'name' : fs.name(meson.current_source_dir()), - 'enabled' : false, + 'cmdline' : integration_test_template['cmdline'] + [ + 'rd.systemd.wants=initrd-run-mount.service', + ], + 'exit-code' : 124, }, ] diff --git a/test/TEST-08-INITRD/test.sh b/test/TEST-08-INITRD/test.sh index badb6cb31a..cbbe82080f 100755 --- a/test/TEST-08-INITRD/test.sh +++ b/test/TEST-08-INITRD/test.sh @@ -14,11 +14,11 @@ TEST_NO_NSPAWN=1 test_append_files() { local workspace="${1:?}" - local sd_initrd file dir + local exitrd file dir - # Create a shutdown initrd + # Create an exitrd # - # This should provide coverage for shutdown initrd related issues, see: + # This should provide coverage for exitrd related issues, see: # - https://github.com/systemd/systemd/issues/28645 # - https://github.com/systemd/systemd/pull/28648 # - https://github.com/systemd/systemd/pull/28793 @@ -26,25 +26,25 @@ test_append_files() { # This is a bit messier than I originally anticipated, as installing our own libraries # is handled implicitly by install_systemd() which I don't want to use here, since # I need only the systemd-shutdown binary - sd_initrd="$workspace/shutdown-initrd" - mkdir -p "$sd_initrd/etc" "$sd_initrd/usr" - initdir="$sd_initrd" image_install bash /usr/lib/os-release - ln -srf "$sd_initrd/usr/lib/os-release" "$sd_initrd/etc/initrd-release" - initdir="$sd_initrd" inst_binary "$workspace/usr/lib/systemd/systemd-shutdown" "/usr/lib/systemd/systemd-shutdown" - initdir="$sd_initrd" inst_libs "$sd_initrd/usr/lib/systemd/systemd-shutdown" + exitrd="$workspace/exitrd" + mkdir -p "$exitrd/etc" "$exitrd/usr" + initdir="$exitrd" image_install bash /usr/lib/os-release + ln -srf "$exitrd/usr/lib/os-release" "$exitrd/etc/initrd-release" + initdir="$exitrd" inst_binary "$workspace/usr/lib/systemd/systemd-shutdown" "/usr/lib/systemd/systemd-shutdown" + initdir="$exitrd" inst_libs "$exitrd/usr/lib/systemd/systemd-shutdown" # We need to deal with libsystemd stuff explicitly, as we don't call install_systemd() here while read -r file; do - initdir="$sd_initrd" inst_library "$file" "${file##"$workspace"}" - initdir="$sd_initrd" inst_libs "$file" + initdir="$exitrd" inst_library "$file" "${file##"$workspace"}" + initdir="$exitrd" inst_libs "$file" done < <(find "$workspace/usr/" -name "libsystemd*.so*") # Call systemd-shutdown indirectly, so we can show a message that we can check for - # later to make sure the shutdown initrd was actually executed - cat >"$sd_initrd/shutdown" <<\EOF + # later to make sure the exitrd was actually executed + cat >"$exitrd/shutdown" <<\EOF #!/usr/bin/bash -eu -echo "Hello from shutdown initrd" +echo "Hello from exitrd" exec /usr/lib/systemd/systemd-shutdown "$@" EOF - chmod +x "$sd_initrd/shutdown" + chmod +x "$exitrd/shutdown" } check_result_qemu_hook() { diff --git a/test/TEST-21-DFUZZER/meson.build b/test/TEST-21-DFUZZER/meson.build index aa6652910c..3373df297c 100644 --- a/test/TEST-21-DFUZZER/meson.build +++ b/test/TEST-21-DFUZZER/meson.build @@ -4,7 +4,7 @@ integration_tests += [ integration_test_template + { 'name' : fs.name(meson.current_source_dir()), 'timeout' : 3600, - 'priority' : -50, + 'priority' : 50, 'slow' : true, }, ] diff --git a/test/TEST-64-UDEV-STORAGE/meson.build b/test/TEST-64-UDEV-STORAGE/meson.build index ba1d1f8ed3..3c206d9f54 100644 --- a/test/TEST-64-UDEV-STORAGE/meson.build +++ b/test/TEST-64-UDEV-STORAGE/meson.build @@ -32,6 +32,7 @@ foreach testcase : [ 'mkosi-args' : integration_test_template['mkosi-args'] + [ '--configure-script', files('@0@.configure'.format(testcase)), ], + 'priority' : 10, }, ] endforeach diff --git a/test/TEST-85-NETWORK/meson.build b/test/TEST-85-NETWORK/meson.build index 95b91f77df..44f75ca208 100644 --- a/test/TEST-85-NETWORK/meson.build +++ b/test/TEST-85-NETWORK/meson.build @@ -37,6 +37,7 @@ foreach testcase : [ 'cmdline' : integration_test_template['cmdline'] + [ 'systemd.setenv=TEST_MATCH_TESTCASE=@0@'.format(testcase) ], + 'priority' : 10, }, ] endforeach diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index 55ea4ff0d8..55a45307e2 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -47,6 +47,7 @@ def main(): parser.add_argument('--storage', required=True) parser.add_argument('--firmware', required=True) parser.add_argument('--slow', action=argparse.BooleanOptionalAction) + parser.add_argument('--exit-code', required=True, type=int) parser.add_argument('mkosi_args', nargs="*") args = parser.parse_args() @@ -148,13 +149,12 @@ def main(): result = subprocess.run(cmd) - # Return code 123 is the expected success code - if result.returncode in (123, 77): + if result.returncode in (args.exit_code, 77): # Do not keep journal files for tests that don't fail. if journal_file: journal_file.unlink(missing_ok=True) - exit(0 if result.returncode == 123 else 77) + exit(0 if result.returncode == args.exit_code else 77) if journal_file: ops = [] diff --git a/test/meson.build b/test/meson.build index 1026be67cb..bb91ec8875 100644 --- a/test/meson.build +++ b/test/meson.build @@ -292,6 +292,7 @@ integration_test_template = { 'cmdline' : [], 'credentials' : [], 'qemu-args' : [], + 'exit-code' : 123, } testdata_subdirs = [ 'auxv', @@ -384,6 +385,7 @@ foreach integration_test : integration_tests '--name', integration_test['name'], '--storage', integration_test['storage'], '--firmware', integration_test['firmware'], + '--exit-code', integration_test['exit-code'].to_string(), ] if 'unit' in integration_test diff --git a/test/units/TEST-08-INITRD.sh b/test/units/TEST-08-INITRD.sh index 58d9bea195..2f9ec7a2bc 100755 --- a/test/units/TEST-08-INITRD.sh +++ b/test/units/TEST-08-INITRD.sh @@ -25,6 +25,6 @@ mountpoint /run/initrd-mount-target # Copy the prepared shutdown initrd to its intended location. Check the respective # test.sh file for details mkdir -p /run/initramfs -cp -r /shutdown-initrd/* /run/initramfs/ +cp -r /exitrd/* /run/initramfs/ touch /testok |