test: extend start-stop-serv test w/ all supported combinations

serv: add support for foregrounding, running with and without PID file,
      including custom PID filename.

test: verify Finit can start & monitor services that:
      1) Fork and creates a PID file in a known location
      2) Don't fork and don't create a PID file, but Finit does
      3) Don't fork but create a PID file
      4) Don't fork and create custom named PID file

Note: Finit cannot support a service that forks and doesn't create a PID
      file.  This combination is impossible to support without tracking
      all processes created in /proc -- which Finit does not do atm.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2022-04-03 11:56:42 +02:00
1 parent b4af86255d
commit 27ba3b27f5
3 files changed
+120 -38

No files matched your search

+10
View File
@@ -32,6 +32,12 @@ assert_new_pid()
assert "Finit has registered new PID" "$(texec initctl |grep $1 |awk '{print $1}')" -eq "$(texec cat $2)"
}
# shellcheck disable=SC2086
assert_pidfile()
{
assert "Process has PID file" "$(texec find $1 2>/dev/null)"
}
# shellcheck disable=SC2154
texec()
{
@@ -157,6 +163,10 @@ log "$color_reset" 'Setup of test environment done' ''
finit_pid=$(retry "pgrep -P $finit_ppid")
if type test_setup > /dev/null 2>&1 ; then
test_setup
fi
#tty=/dev/$(texec cat /sys/class/tty/console/active)
#texec cat "$tty" &
#sleep 1