summaryrefslogtreecommitdiffstats
path: root/test/TEST-01-BASIC
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2023-07-19 14:26:26 +0200
committerLuca Boccassi <bluca@debian.org>2023-07-24 11:39:14 +0200
commit8256994c63dbcf89b5e194cd120214ec085049bb (patch)
tree49ffd230c9ccf4115cc6e3c5756a8643789e6018 /test/TEST-01-BASIC
parentswitch-root: use MS_REC for /run, unless we are soft-rebooting (diff)
downloadsystemd-8256994c63dbcf89b5e194cd120214ec085049bb.tar.xz
systemd-8256994c63dbcf89b5e194cd120214ec085049bb.zip
test: check if we correctly propagate /run mounts during switch root
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: https://github.com/systemd/systemd/issues/28452
Diffstat (limited to 'test/TEST-01-BASIC')
-rwxr-xr-xtest/TEST-01-BASIC/test.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh
index d0e714ac30..c729e95f1d 100755
--- a/test/TEST-01-BASIC/test.sh
+++ b/test/TEST-01-BASIC/test.sh
@@ -23,4 +23,31 @@ test_append_files() {
cp -v "$TEST_UNITS_DIR"/{testsuite-01,end}.service "$TEST_UNITS_DIR/testsuite.target" "$dst"
}
+# 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"
+}
+
do_test "$@"