mirror of
https://github.com/troglobit/finit.git
synced 2026-10-15 10:29:35 +00:00
test: Retry asserting number of Finit children for a while
Signed-off-by: Jacques de Laval <jacques@de-laval.se>
This commit is contained in:
1 parent
644273fc5c
commit
0ef17f55ff
3 files changed
+39
-14
No files matched your search
@@ -2,6 +2,11 @@
|
||||
|
||||
set -eu
|
||||
|
||||
assert_num_children() {
|
||||
texec ps -opid,ppid,args
|
||||
assert "$1 services are running" "$(texec pgrep -P 1 | wc -l)" -eq "$1"
|
||||
}
|
||||
|
||||
# Test
|
||||
say 'Set up a service'
|
||||
cp "$TEST_DIR"/service.sh test_root/bin
|
||||
@@ -10,20 +15,16 @@ texec sh -c "echo 'service [2345] kill:20 log /bin/service.sh' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec kill -SIGHUP 1
|
||||
sleep 1
|
||||
|
||||
service_pids=$(texec pgrep -P 1 | wc -l)
|
||||
assert 'One service is running' "$service_pids" -eq 1
|
||||
retry 'assert_num_children 1'
|
||||
|
||||
say 'Remove the service'
|
||||
texec sh -c "echo > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec kill -SIGHUP 1
|
||||
sleep 1
|
||||
|
||||
service_pids=$(texec pgrep -P 1 | wc -l)
|
||||
assert 'Zero services are running' "$service_pids" -eq 0
|
||||
retry 'assert_num_children 0'
|
||||
|
||||
# Teardown
|
||||
rm -f test_root/bin/service.sh
|
||||
Reference in new issue
Block a user