2020-03-04 09:35:06 +00:00
#!/usr/bin/env bash
2021-10-17 18:13:06 +02:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2017-08-07 21:09:21 +02:00
set -e
2021-04-19 13:01:59 +02:00
2012-05-21 18:55:48 +02:00
TEST_DESCRIPTION = "Basic systemd setup"
2019-12-12 09:37:19 +01:00
IMAGE_NAME = "basic"
2018-12-23 14:28:01 +01:00
RUN_IN_UNPRIVILEGED_CONTAINER = ${ RUN_IN_UNPRIVILEGED_CONTAINER :- yes }
2019-12-17 12:52:35 +01:00
TEST_REQUIRE_INSTALL_TESTS = 0
2022-02-16 20:29:14 +01:00
TEST_SUPPORTING_SERVICES_SHOULD_BE_MASKED = 0
2012-05-21 18:55:48 +02:00
2023-06-29 13:31:19 +02:00
# Check if we can correctly deserialize if the kernel cmdline contains "weird" stuff
# like an invalid argument, "end of arguments" separator, or a sysvinit argument (-z)
# See: https://github.com/systemd/systemd/issues/28184
KERNEL_APPEND = " foo -- -z bar --- baz $KERNEL_APPEND "
2021-04-19 13:01:59 +02:00
# shellcheck source=test/test-functions
. " ${ TEST_BASE_DIR : ? } /test-functions "
2012-05-21 18:55:48 +02:00
2021-01-06 21:42:28 +00:00
test_append_files( ) {
# install tests manually so the test is functional even when -Dinstall-tests=false
2021-04-19 13:01:59 +02:00
local dst = " ${ 1 : ? } /usr/lib/systemd/tests/testdata/units/ "
2020-11-18 09:39:50 -05:00
mkdir -p " $dst "
2021-04-19 13:01:59 +02:00
cp -v " $TEST_UNITS_DIR " /{ testsuite-01,end} .service " $TEST_UNITS_DIR /testsuite.target " " $dst "
2012-05-21 18:55:48 +02:00
}
2023-07-19 14:26:26 +02:00
# Setup a one shot service in initrd that creates a dummy bind mount under /run
# to check if the mount persists though the initrd transition. The "check" part
# is in the respective testsuite-01.sh script.
#
# See: https://github.com/systemd/systemd/issues/28452
run_qemu_hook( ) {
local extra = " $WORKDIR /initrd.extra "
mkdir -m 755 " $extra "
mkdir -m 755 " $extra /etc " " $extra /etc/systemd " " $extra /etc/systemd/system " " $extra /etc/systemd/system/initrd.target.wants "
cat >" $extra /etc/systemd/system/initrd-run-mount.service " <<EOF
[ Unit]
Description = Create a mount in /run that should survive the transition from initrd
[ Service]
Type = oneshot
RemainAfterExit = yes
ExecStart = sh -xec "mkdir /run/initrd-mount-source /run/initrd-mount-target; mount -v --bind /run/initrd-mount-source /run/initrd-mount-target"
EOF
ln -svrf " $extra /etc/systemd/system/initrd-run-mount.service " " $extra /etc/systemd/system/initrd.target.wants/initrd-run-mount.service "
( cd " $extra " && find . | cpio -o -H newc -R root:root > " $extra .cpio " )
INITRD_EXTRA = " $extra .cpio "
}
2021-04-26 19:20:18 +02:00
do_test " $@ "