]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: include MAINPID in notify message in TEST-50-DISSECT for notify socket
authorLuca Boccassi <luca.boccassi@gmail.com>
Sat, 14 Dec 2024 16:44:40 +0000 (16:44 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 15 Dec 2024 00:07:57 +0000 (09:07 +0900)
Copy what systemd-notify does by default by setting it to the PID of the shell,
so that main process tracking works as expected. Also use test -S instead of ls
to check socket.

[   33.980396] (sh)[1024]: run-p1022-i1322.service: Executing: sh -c "echo READY=1 | ncat --unixsock --udp \$NOTIFY_SOCKET --source /run/notify && env"
[   34.138778] systemd[1]: run-p1022-i1322.service: Child 1024 belongs to run-p1022-i1322.service.
[   34.138825] systemd[1]: run-p1022-i1322.service: Main process exited, code=exited, status=0/SUCCESS (success)
[   34.139451] systemd[1]: run-p1022-i1322.service: Failed with result 'protocol'.
[   34.139559] systemd[1]: run-p1022-i1322.service: Service will not restart (restart setting)
[   34.139573] systemd[1]: run-p1022-i1322.service: Changed start -> failed
[   34.139945] systemd[1]: run-p1022-i1322.service: Job 1364 run-p1022-i1322.service/start finished, result=failed

Fixes #35619

Follow-up for 18bb30c3b2ea7f4497edf86414133667b3e155fe

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

index 180d069cf16afda24784fb791eead952c6d2f70d..a66b617c086bbe97efe5a9605238e6765633a0e6 100755 (executable)
@@ -81,8 +81,8 @@ 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 'echo READY=1 | ncat --unixsock --udp $NOTIFY_SOCKET --source /run/notify && ls /run/host/notify'
-systemd-run --wait -p RootImage="$MINIMAL_IMAGE.raw" -p NotifyAccess=all --service-type=notify --pipe sh -c 'echo READY=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 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 -P -p RootImage="$MINIMAL_IMAGE.raw" cat /usr/lib/os-release | grep -q -F "MARKER=1"
 mv "$MINIMAL_IMAGE.verity" "$MINIMAL_IMAGE.fooverity"