Skip to content

Commit 0b182c0

Browse files
committed
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 <troglobit@gmail.com>
1 parent f0914f6 commit 0b182c0

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

test/depserv.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# - bar must not start until foo is ready
66
# - bar must be stopped when foo goes down
77
# - bar must be restarted when foo is restarted
8+
# - bar must be restarted when foo is reloaded (per-service reload)
89
#
910
# Regression test bug #314, that bar is not in a restart loop when foo
1011
# is stopped. Also, verify that changing between runlevels, where foo
@@ -49,6 +50,13 @@ test_one()
4950
run "initctl status"
5051
assert "bar is restarted" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid"
5152

53+
say "Verify bar is restarted when foo is reloaded (per-service) ..."
54+
retry 'assert_status "bar" "running"' 5 1
55+
pid=$(texec initctl |grep bar | awk '{print $1;}')
56+
run "initctl reload foo"
57+
retry 'assert_status "bar" "running"' 5 1
58+
assert "bar is restarted on reload" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid"
59+
5260
# Wait for spice to be stolen by the Harkonnen
5361
sleep 3
5462
# bar should now have detected the loss of spice and be in restart
@@ -61,8 +69,9 @@ test_one()
6169
assert_status "bar" "waiting"
6270
}
6371

72+
run "initctl debug"
6473
sep
6574
test_one "pid/foo"
6675
sep
67-
run "initctl debug"
68-
test_one "service/foo/running"
76+
#run "initctl debug"
77+
test_one "service/foo/ready"

test/skel/bin/slay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ done
5252
echo "$pid" > /tmp/oldpid
5353

5454
#echo "PID $pid, kill -9 ..."
55-
kill -9 "$pid"
55+
kill -9 "$pid" 2>/dev/null || true

test/src/serv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,12 @@ int main(int argc, char *argv[])
325325
#endif
326326
}
327327
}
328+
329+
if (melange) {
330+
mine(melange);
331+
vanish = -2;
332+
}
333+
328334
if (do_pidfile > 0)
329335
pidfile(NULL);
330336
reloading = 0;

0 commit comments

Comments
 (0)