]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: also run some basic test cases on nspawn
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 May 2024 22:20:57 +0000 (07:20 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 21 May 2024 14:09:38 +0000 (23:09 +0900)
test/units/TEST-74-AUX-UTILS.mount.sh

index 933191e5adc9f04faab0be9e9173db5a0f99a6f0..a3b44ee91bc14113ebcecf71b0f1e03aeb671d70 100755 (executable)
@@ -6,13 +6,6 @@ set -o pipefail
 # shellcheck source=test/units/util.sh
 . "$(dirname "$0")"/util.sh
 
-# We're going to play around with block/loop devices, so bail out early
-# if we're running in nspawn
-if systemd-detect-virt --container >/dev/null; then
-    echo "Container detected, skipping the test"
-    exit 0
-fi
-
 at_exit() {
     set +e
 
@@ -23,6 +16,7 @@ at_exit() {
 trap at_exit EXIT
 
 WORK_DIR="$(mktemp -d)"
+mkdir -p "$WORK_DIR/mnt"
 
 systemd-mount --list
 systemd-mount --list --full
@@ -30,6 +24,28 @@ systemd-mount --list --no-legend
 systemd-mount --list --no-pager
 systemd-mount --list --quiet
 
+# tmpfs
+mkdir -p "$WORK_DIR/mnt/foo/bar"
+systemd-mount --tmpfs "$WORK_DIR/mnt/foo"
+test ! -d "$WORK_DIR/mnt/foo/bar"
+touch "$WORK_DIR/mnt/foo/baz"
+systemd-umount "$WORK_DIR/mnt/foo"
+test -d "$WORK_DIR/mnt/foo/bar"
+test ! -e "$WORK_DIR/mnt/foo/baz"
+
+# overlay
+systemd-mount --type=overlay --options="lowerdir=/etc,upperdir=$WORK_DIR/upper,workdir=$WORK_DIR/work" /etc "$WORK_DIR/overlay"
+touch "$WORK_DIR/overlay/foo"
+test -e "$WORK_DIR/upper/foo"
+systemd-umount "$WORK_DIR/overlay"
+
+# We're going to play around with block/loop devices, so bail out early
+# if we're running in nspawn
+if systemd-detect-virt --container >/dev/null; then
+    echo "Container detected, skipping the test"
+    exit 0
+fi
+
 # Set up a simple block device for further tests
 dd if=/dev/zero of="$WORK_DIR/simple.img" bs=1M count=16
 mkfs.ext4 -L sd-mount-test "$WORK_DIR/simple.img"
@@ -38,7 +54,6 @@ udevadm wait --timeout 60 --settle "$LOOP"
 # Also wait for the .device unit for the loop device is active. Otherwise, the .device unit activation
 # that is triggered by the .mount unit introduced by systemd-mount below may time out.
 timeout 60 bash -c "until systemctl is-active $LOOP; do sleep 1; done"
-mkdir "$WORK_DIR/mnt"
 mount "$LOOP" "$WORK_DIR/mnt"
 touch "$WORK_DIR/mnt/foo.bar"
 umount "$LOOP"
@@ -148,18 +163,3 @@ systemctl status "$WORK_DIR/mnt"
 touch "$WORK_DIR/mnt/hello"
 [[ "$(stat -c "%U:%G" "$WORK_DIR/mnt/hello")" == "testuser:testuser" ]]
 systemd-umount LABEL=owner-vfat
-
-# tmpfs
-mkdir -p "$WORK_DIR/mnt/foo/bar"
-systemd-mount --tmpfs "$WORK_DIR/mnt/foo"
-test ! -d "$WORK_DIR/mnt/foo/bar"
-touch "$WORK_DIR/mnt/foo/baz"
-systemd-umount "$WORK_DIR/mnt/foo"
-test -d "$WORK_DIR/mnt/foo/bar"
-test ! -e "$WORK_DIR/mnt/foo/baz"
-
-# overlay
-systemd-mount --type=overlay --options="lowerdir=/etc,upperdir=$WORK_DIR/upper,workdir=$WORK_DIR/work" /etc "$WORK_DIR/overlay"
-touch "$WORK_DIR/overlay/foo"
-test -e "$WORK_DIR/upper/foo"
-systemd-umount "$WORK_DIR/overlay"