]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: test new systemd-dissect --attach/--detach/--loop-ref= and /dev/loop/* symlinks
authorLennart Poettering <lennart@poettering.net>
Mon, 6 Mar 2023 12:23:48 +0000 (13:23 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 9 Mar 2023 21:29:11 +0000 (22:29 +0100)
Let's test that everything we just added works in combination.

test/units/testsuite-50.sh

index cb99b811c937f21294abc4f24cfa1aff389e3449..741167a215499bbc40c415ff9c83d3bbb146acda 100755 (executable)
@@ -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