From 0b182c063e36d893ded44ac8b1f8bb41d17b4e20 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 10 Feb 2026 16:00:57 +0100 Subject: [PATCH] test: Extend depserv test with per-service reload, fix slay race Verify that 'initctl reload foo' properly triggers dependent services by checking that bar gets a new PID after the reload. Also change the second test case from service/foo/running to service/foo/ready which is the actual condition set by pidfile.so. Fix a race in slay where the target process could exit between the PID lookup and kill -9, causing spurious test failures in tight kill loops (e.g., start-kill-service.sh). Signed-off-by: Joachim Wiberg --- test/depserv.sh | 13 +++++++++++-- test/skel/bin/slay | 2 +- test/src/serv.c | 6 ++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/depserv.sh b/test/depserv.sh index 2f5c7a3c..9c0ebb73 100755 --- a/test/depserv.sh +++ b/test/depserv.sh @@ -5,6 +5,7 @@ # - bar must not start until foo is ready # - bar must be stopped when foo goes down # - bar must be restarted when foo is restarted +# - bar must be restarted when foo is reloaded (per-service reload) # # Regression test bug #314, that bar is not in a restart loop when foo # is stopped. Also, verify that changing between runlevels, where foo @@ -49,6 +50,13 @@ test_one() run "initctl status" assert "bar is restarted" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid" + say "Verify bar is restarted when foo is reloaded (per-service) ..." + retry 'assert_status "bar" "running"' 5 1 + pid=$(texec initctl |grep bar | awk '{print $1;}') + run "initctl reload foo" + retry 'assert_status "bar" "running"' 5 1 + assert "bar is restarted on reload" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid" + # Wait for spice to be stolen by the Harkonnen sleep 3 # bar should now have detected the loss of spice and be in restart @@ -61,8 +69,9 @@ test_one() assert_status "bar" "waiting" } +run "initctl debug" sep test_one "pid/foo" sep -run "initctl debug" -test_one "service/foo/running" +#run "initctl debug" +test_one "service/foo/ready" diff --git a/test/skel/bin/slay b/test/skel/bin/slay index 314ba1f3..d1c04efc 100755 --- a/test/skel/bin/slay +++ b/test/skel/bin/slay @@ -52,4 +52,4 @@ done echo "$pid" > /tmp/oldpid #echo "PID $pid, kill -9 ..." -kill -9 "$pid" +kill -9 "$pid" 2>/dev/null || true diff --git a/test/src/serv.c b/test/src/serv.c index dd9567e2..8129efb1 100644 --- a/test/src/serv.c +++ b/test/src/serv.c @@ -325,6 +325,12 @@ int main(int argc, char *argv[]) #endif } } + + if (melange) { + mine(melange); + vanish = -2; + } + if (do_pidfile > 0) pidfile(NULL); reloading = 0;