]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: make TEST-07-PID1.issue-14566 more robust
authorLuca Boccassi <luca.boccassi@gmail.com>
Mon, 29 Jun 2026 10:56:30 +0000 (11:56 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 29 Jun 2026 11:03:40 +0000 (12:03 +0100)
The test slept a fixed 4s after starting the service, then read the
child PID from /leakedtestpid. On a loaded host the executor had not
exec'd the script yet:

[ 1571.079978] TEST-07-PID1.sh[17329]: + systemctl start issue14566-repro
[ 1571.079978] TEST-07-PID1.sh[17329]: + sleep 4
[ 1571.079978] TEST-07-PID1.sh[17329]: + systemctl status issue14566-repro
[ 1562.350438] systemd[1]: init.scope: Child 17296 belongs to init.scope.
[ 1571.081084] TEST-07-PID1.sh[17333]: ● issue14566-repro.service - Issue 14566 Repro
[ 1571.081084] TEST-07-PID1.sh[17333]:      Loaded: loaded (/usr/lib/systemd/tests/testdata/TEST-07-PID1.units/issue14566-repro.service; static)
[ 1571.081084] TEST-07-PID1.sh[17333]:     Drop-In: /usr/lib/systemd/system/service.d
[ 1571.081084] TEST-07-PID1.sh[17333]:              └─10-timeout-abort.conf
[ 1571.081084] TEST-07-PID1.sh[17333]:      Active: active (running) since Mon 2026-06-29 06:19:07 UTC; 4s ago
[ 1571.081084] TEST-07-PID1.sh[17333]:  Invocation: b3356aa5fff24eee85e302250ecb06b1
[ 1571.081084] TEST-07-PID1.sh[17333]:    Main PID: 17331 (9)
[ 1571.081084] TEST-07-PID1.sh[17333]:       Tasks: 1 (limit: 4468)
[ 1571.081084] TEST-07-PID1.sh[17333]:      Memory: 768K (peak: 768K)
[ 1571.081084] TEST-07-PID1.sh[17333]:         CPU: 1ms
[ 1571.081084] TEST-07-PID1.sh[17333]:      CGroup: /system.slice/issue14566-repro.service
[ 1571.081084] TEST-07-PID1.sh[17333]:              └─17331 systemd-executor --deserialize 66 --log-level debug,console:info --log-target journal
[ 1562.350492] systemd[1]: Child 17297 ((sd-close)) died (code=exited, status=0/SUCCESS)
[ 1571.082379] TEST-07-PID1.sh[17334]: ++ cat /leakedtestpid
[ 1571.082379] TEST-07-PID1.sh[17334]: cat: /leakedtestpid: No such file or directory

Make the service Type=notify and notify readiness after writing the PID
file, and wait for the service to go inactive in a timeout loop instead
of fixed sleeps.

Follow-up for c1566ef0d22ed786b9ecf4c476e53b8a91e67578

test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.service
test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.sh
test/units/TEST-07-PID1.issue-14566.sh

index 4fd77160813d68bd15cf8e42414eeeaaa208dc9e..e285277188d2d5ccb6cfecb7468ff57106407ea1 100644 (file)
@@ -3,6 +3,8 @@
 Description=Issue 14566 Repro
 
 [Service]
+Type=notify
+NotifyAccess=all
 ExecStart=/usr/lib/systemd/tests/testdata/TEST-07-PID1.units/%N.sh
 ExecStopPost=true
 KillMode=mixed
index 74fa7605e7a220d5678600370878f3e89cc60102..ec0268e8916da9d508fbb2646d88a6e4f344ce31 100755 (executable)
@@ -3,4 +3,5 @@
 
 sleep infinity &
 echo $! >/leakedtestpid
+systemd-notify --ready
 wait $!
index ecc18e411bdb879aadd520d84ed007916d027d04..05fade9c4c4e0726f68c5ed47d2637857d36287d 100755 (executable)
@@ -14,13 +14,12 @@ if [[ -v ASAN_OPTIONS ]]; then
 fi
 
 systemctl start issue14566-repro
-sleep 4
 systemctl status issue14566-repro
 
 leaked_pid=$(cat /leakedtestpid)
 
 systemctl stop issue14566-repro
-sleep 4
+timeout 30 bash -c 'while systemctl is-active issue14566-repro; do sleep .5; done'
 
 # Leaked PID will still be around if we're buggy.
 # I personally prefer to see 42.