summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-03-06 13:23:48 +0100
committerLennart Poettering <lennart@poettering.net>2023-03-09 22:29:11 +0100
commitf5e46b9e09d4ff3f1e6ee6e3a90adc704780a661 (patch)
tree5b246b80eb6091bfddb81f9522058a33baf68efb /test
parent5ac52d1f7b7cd11cad8b5c2e9812d7ee7560a517 (diff)
downloadsystemd-f5e46b9e09d4ff3f1e6ee6e3a90adc704780a661.tar.gz
test: test new systemd-dissect --attach/--detach/--loop-ref= and /dev/loop/* symlinks
Let's test that everything we just added works in combination.
Diffstat (limited to 'test')
-rwxr-xr-xtest/units/testsuite-50.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/units/testsuite-50.sh b/test/units/testsuite-50.sh
index cb99b811c9..741167a215 100755
--- a/test/units/testsuite-50.sh
+++ b/test/units/testsuite-50.sh
@@ -430,6 +430,28 @@ mount -t ddi "${image}.gpt" "$T" -o ro,X-mount.mkdir,discard
umount -R "$T"
rmdir "$T"
+LOOP="$(systemd-dissect --attach --loop-ref=waldo "${image}.raw")"
+
+# Wait until the symlinks we want to test are established
+udevadm trigger -w "$LOOP"
+
+# Check if the /dev/loop/* symlinks really reference the right device
+test /dev/loop/by-ref/waldo -ef "$LOOP"
+
+if [ "$(stat -c '%Hd:%Ld' "${image}.raw")" != '?d:?d' ] ; then
+ # Old stat didn't know the %Hd and %Ld specifiers and turned them into ?d
+ # instead. Let's simply skip the test on such old systems.
+ test "$(stat -c '/dev/loop/by-inode/%Hd:%Ld-%i' "${image}.raw")" -ef "$LOOP"
+fi
+
+# Detach by loopback device
+systemd-dissect --detach "$LOOP"
+
+# Detach by backing inode
+systemd-dissect --attach --loop-ref=waldo "${image}.raw"
+systemd-dissect --detach "${image}.raw"
+(! systemd-dissect --detach "${image}.raw")
+
echo OK >/testok
exit 0