test: verify finit restarts crashing services & registers new PID

We extend the service.sh to emulate a well behaving service that creates
and removes its own PID file.

The new test emulates a crash by sending SIGKILL to service.sh.  We then
verify that Finit restarts it, and eventually registers the new PID when
the services recreates the PID file.

Issue #226

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2022-02-12 13:30:05 +01:00
1 parent f567b866a0
commit e9c8d3d740
4 files changed
+45

No files matched your search

+5
View File
@@ -25,6 +25,11 @@ assert_num_children() {
assert "$1 services are running" "$(texec pgrep -P 1 "$2" | wc -l)" -eq "$1"
}
assert_new_pid() {
# shellcheck disable=SC2086
assert "Finit has registered new PID" "$(texec initctl |grep $1 |awk '{print $1}')" -eq "$(texec cat $2)"
}
texec() {
# shellcheck disable=SC2154
"$TEST_DIR/tenv/exec.sh" "$finit_pid" "$@"