summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-09-05 07:12:20 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-09-06 06:24:36 +0200
commit48878074d69a558484348f14e8887ce132938377 (patch)
tree27421379ae47ad2e842ebfd92671523a79706406
parentnspawn: only remount /usr/ with idmap when --volatile=yes (diff)
downloadsystemd-48878074d69a558484348f14e8887ce132938377.tar.xz
systemd-48878074d69a558484348f14e8887ce132938377.zip
test: add test cases for --volatile= with -U
For issue #34254.
-rwxr-xr-xtest/units/TEST-13-NSPAWN.nspawn.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/units/TEST-13-NSPAWN.nspawn.sh b/test/units/TEST-13-NSPAWN.nspawn.sh
index 7c21825d63..8f16ac1a59 100755
--- a/test/units/TEST-13-NSPAWN.nspawn.sh
+++ b/test/units/TEST-13-NSPAWN.nspawn.sh
@@ -141,6 +141,37 @@ testcase_sanity() {
test ! -e "$root/var/also-nope"
test ! -e "$root/usr/nope-too"
+ # --volatile= with -U
+ touch "$root/usr/has-usr"
+ # volatile(=yes): rootfs is tmpfs, /usr/ from the OS tree is mounted read only
+ systemd-nspawn --directory="$root"\
+ --volatile \
+ -U \
+ bash -xec 'test -e /usr/has-usr; touch /usr/read-only && exit 1; touch /nope'
+ test ! -e "$root/nope"
+ test ! -e "$root/usr/read-only"
+ systemd-nspawn --directory="$root"\
+ --volatile=yes \
+ -U \
+ bash -xec 'test -e /usr/has-usr; touch /usr/read-only && exit 1; touch /nope'
+ test ! -e "$root/nope"
+ test ! -e "$root/usr/read-only"
+ # volatile=state: rootfs is read-only, /var/ is tmpfs
+ systemd-nspawn --directory="$root" \
+ --volatile=state \
+ -U \
+ bash -xec 'test -e /usr/has-usr; mountpoint /var; touch /read-only && exit 1; touch /var/nope'
+ test ! -e "$root/read-only"
+ test ! -e "$root/var/nope"
+ # volatile=overlay: tmpfs overlay is mounted over rootfs
+ systemd-nspawn --directory="$root" \
+ --volatile=overlay \
+ -U \
+ bash -xec 'test -e /usr/has-usr; touch /nope; touch /var/also-nope; touch /usr/nope-too'
+ test ! -e "$root/nope"
+ test ! -e "$root/var/also-nope"
+ test ! -e "$root/usr/nope-too"
+
# --machine=, --hostname=
systemd-nspawn --directory="$root" \
--machine="foo-bar.baz" \