]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-01-BASIC/test.sh
test: check if we correctly propagate /run mounts during switch root
[thirdparty/systemd.git] / test / TEST-01-BASIC / test.sh
CommitLineData
ff12a795 1#!/usr/bin/env bash
7b3cec95 2# SPDX-License-Identifier: LGPL-2.1-or-later
818567fc 3set -e
3f161ba9 4
898720b7 5TEST_DESCRIPTION="Basic systemd setup"
8c3534b5 6IMAGE_NAME="basic"
9103671d 7RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}
9d84eb20 8TEST_REQUIRE_INSTALL_TESTS=0
508a7f04 9TEST_SUPPORTING_SERVICES_SHOULD_BE_MASKED=0
898720b7 10
06afda6b
FS
11# Check if we can correctly deserialize if the kernel cmdline contains "weird" stuff
12# like an invalid argument, "end of arguments" separator, or a sysvinit argument (-z)
13# See: https://github.com/systemd/systemd/issues/28184
14KERNEL_APPEND="foo -- -z bar --- baz $KERNEL_APPEND"
15
3f161ba9
FS
16# shellcheck source=test/test-functions
17. "${TEST_BASE_DIR:?}/test-functions"
898720b7 18
d9e606e8
LB
19test_append_files() {
20 # install tests manually so the test is functional even when -Dinstall-tests=false
3f161ba9 21 local dst="${1:?}/usr/lib/systemd/tests/testdata/units/"
59b8cb3c 22 mkdir -p "$dst"
3f161ba9 23 cp -v "$TEST_UNITS_DIR"/{testsuite-01,end}.service "$TEST_UNITS_DIR/testsuite.target" "$dst"
898720b7
HH
24}
25
8256994c
FS
26# Setup a one shot service in initrd that creates a dummy bind mount under /run
27# to check if the mount persists though the initrd transition. The "check" part
28# is in the respective testsuite-01.sh script.
29#
30# See: https://github.com/systemd/systemd/issues/28452
31run_qemu_hook() {
32 local extra="$WORKDIR/initrd.extra"
33
34 mkdir -m 755 "$extra"
35 mkdir -m 755 "$extra/etc" "$extra/etc/systemd" "$extra/etc/systemd/system" "$extra/etc/systemd/system/initrd.target.wants"
36
37 cat >"$extra/etc/systemd/system/initrd-run-mount.service" <<EOF
38[Unit]
39Description=Create a mount in /run that should survive the transition from initrd
40
41[Service]
42Type=oneshot
43RemainAfterExit=yes
44ExecStart=sh -xec "mkdir /run/initrd-mount-source /run/initrd-mount-target; mount -v --bind /run/initrd-mount-source /run/initrd-mount-target"
45EOF
46 ln -svrf "$extra/etc/systemd/system/initrd-run-mount.service" "$extra/etc/systemd/system/initrd.target.wants/initrd-run-mount.service"
47
48 (cd "$extra" && find . | cpio -o -H newc -R root:root > "$extra.cpio")
49
50 INITRD_EXTRA="$extra.cpio"
51}
52
c4cd6205 53do_test "$@"