Merge pull request #32835 from DaanDeMeyer/test
test: Enable TEST-08-INITRD on mkosi
This commit is contained in:
@@ -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
|
||||
@@ -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/*
|
||||
@@ -0,0 +1,9 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
[Match]
|
||||
Distribution=|centos
|
||||
Distribution=|fedora
|
||||
|
||||
[Content]
|
||||
Packages=
|
||||
systemd-standalone-shutdown
|
||||
@@ -0,0 +1,9 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
[Match]
|
||||
Distribution=|debian
|
||||
Distribution=|ubuntu
|
||||
|
||||
[Content]
|
||||
Packages=
|
||||
systemd
|
||||
@@ -0,0 +1,8 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
[Match]
|
||||
Distribution=opensuse
|
||||
|
||||
[Content]
|
||||
Packages=
|
||||
systemd
|
||||
Executable
+12
@@ -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[@]}"
|
||||
+11
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
]
|
||||
|
||||
+15
-15
@@ -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() {
|
||||
|
||||
@@ -4,7 +4,7 @@ integration_tests += [
|
||||
integration_test_template + {
|
||||
'name' : fs.name(meson.current_source_dir()),
|
||||
'timeout' : 3600,
|
||||
'priority' : -50,
|
||||
'priority' : 50,
|
||||
'slow' : true,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -32,6 +32,7 @@ foreach testcase : [
|
||||
'mkosi-args' : integration_test_template['mkosi-args'] + [
|
||||
'--configure-script', files('@0@.configure'.format(testcase)),
|
||||
],
|
||||
'priority' : 10,
|
||||
},
|
||||
]
|
||||
endforeach
|
||||
|
||||
@@ -37,6 +37,7 @@ foreach testcase : [
|
||||
'cmdline' : integration_test_template['cmdline'] + [
|
||||
'systemd.setenv=TEST_MATCH_TESTCASE=@0@'.format(testcase)
|
||||
],
|
||||
'priority' : 10,
|
||||
},
|
||||
]
|
||||
endforeach
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user