]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-50-DISSECT: add test case with systemd-notify
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 15 Dec 2024 02:02:11 +0000 (11:02 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 16 Dec 2024 11:22:39 +0000 (11:22 +0000)
This also merges the previous test cases into one.

Follow-up for 284dd31e9d7d25e8a0bdfee60cf938ab961f2a7a and
498c20fad6a472dfbbfacc1ed55754f9ebfa869e.

test/units/TEST-50-DISSECT.dissect.sh

index a66b617c086bbe97efe5a9605238e6765633a0e6..2ca07453ec0aed8e330de1e2d8882c918a773d92 100755 (executable)
@@ -81,8 +81,40 @@ systemd-run --wait -p RootImage="$MINIMAL_IMAGE.raw" mountpoint /run/systemd/jou
 
 # Test that the notify socket is bind mounted to /run/host/notify in sandboxed environments and
 # $NOTIFY_SOCKET is set correctly.
-systemd-run --wait -p RootImage="$MINIMAL_IMAGE.raw" -p NotifyAccess=all --service-type=notify --pipe sh -c 'printf MAINPID=$$$$\\nREADY=1 | ncat --unixsock --udp $NOTIFY_SOCKET --source /run/notify && test -S /run/host/notify'
-systemd-run --wait -p RootImage="$MINIMAL_IMAGE.raw" -p NotifyAccess=all --service-type=notify --pipe sh -c 'printf MAINPID=$$$$\\nREADY=1 | ncat --unixsock --udp $NOTIFY_SOCKET --source /run/notify && env' | grep NOTIFY_SOCKET=/run/host/notify
+systemd-run \
+    --wait \
+    -p RootImage="$MINIMAL_IMAGE.raw" \
+    -p NotifyAccess=all \
+    --service-type=notify \
+    --pipe \
+    bash -xec \
+    '
+        printf MAINPID=$$$$\\nREADY=1 | ncat --unixsock --udp $NOTIFY_SOCKET --source /run/notify
+        [[ "$$NOTIFY_SOCKET" == "/run/host/notify" ]]
+        [[ "$$(env)" =~ "NOTIFY_SOCKET=/run/host/notify" ]]
+        test -S /run/host/notify
+    '
+if [[ "$(findmnt -n -o FSTYPE /)" == btrfs ]]; then
+    [[ -d /test-dissect-btrfs-snapshot ]] && btrfs subvolume delete /test-dissect-btrfs-snapshot
+    btrfs subvolume snapshot / /test-dissect-btrfs-snapshot
+
+    # Same test with systemd-notify and RootDirectory=
+    systemd-run \
+        --wait \
+        -p RootDirectory=/test-dissect-btrfs-snapshot \
+        -p NotifyAccess=all \
+        --service-type=notify \
+        --pipe \
+        bash -xec \
+        '
+            systemd-notify --pid=auto --ready
+            [[ "$$NOTIFY_SOCKET" == "/run/host/notify" ]]
+            [[ "$(env)" =~ "NOTIFY_SOCKET=/run/host/notify" ]]
+            test -S /run/host/notify
+        '
+
+    btrfs subvolume delete /test-dissect-btrfs-snapshot
+fi
 
 systemd-run -P -p RootImage="$MINIMAL_IMAGE.raw" cat /usr/lib/os-release | grep -q -F "MARKER=1"
 mv "$MINIMAL_IMAGE.verity" "$MINIMAL_IMAGE.fooverity"