diff --git a/test/Makefile.am b/test/Makefile.am index 8e9b3750..d3d9b229 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -28,6 +28,7 @@ EXTRA_DIST += failing-sysv.sh EXTRA_DIST += global-envs.sh EXTRA_DIST += initctl-status-subset.sh EXTRA_DIST += notify.sh +EXTRA_DIST += pidfile.sh EXTRA_DIST += pre-post-serv.sh EXTRA_DIST += ready-serv.sh EXTRA_DIST += restart-self.sh @@ -64,6 +65,7 @@ TESTS += failing-sysv.sh TESTS += global-envs.sh TESTS += initctl-status-subset.sh TESTS += notify.sh +TESTS += pidfile.sh TESTS += pre-post-serv.sh TESTS += ready-serv.sh TESTS += restart-self.sh diff --git a/test/pidfile.sh b/test/pidfile.sh new file mode 100755 index 00000000..013c44b8 --- /dev/null +++ b/test/pidfile.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Verify parsing of pid: argument + +set -eu + +TEST_DIR=$(dirname "$0") + +test_setup() +{ + say "Test start $(date)" +} + +test_teardown() +{ + say "Test done $(date)" + say "Running test teardown." + + run "rm -f $FINIT_CONF" "/tmp/post" +} + +# shellcheck source=/dev/null +. "$TEST_DIR/tenv/lib.sh" + +#run "initctl debug" +#run "ls -l /run/finit/cond/pid/ /lib/finit/plugins/" + +test_one() +{ + pidfn=$1 + service=$2 + + sep + say "Add service stanza '$service' to $FINIT_CONF ..." + run "echo '$service' > $FINIT_CONF" + run "initctl reload" + + assert_is_pidfile "serv" "$pidfn" + + say "Done, drop service from $FINIT_CONF ..." + run "rm $FINIT_CONF" + run "initctl reload" +} + +test_one "/run/serv.pid" "service serv -np" +test_one "/run/serv.pid" "service pid:!/run/serv.pid serv" +test_one "/run/serv.pid" "service type:forking serv" +test_one "/run/serv.pid" "service pid:!//run/serv.pid serv -np" +test_one "/run/serv.pid" "service pid://run/serv.pid serv -n" +test_one "/run/serv.pid" "service pid://../run/serv.pid serv -n" +test_one "/run/serv.pid" "service pid://run/../run//serv.pid serv -n" + +sep diff --git a/test/tenv/lib.sh b/test/tenv/lib.sh index d95c54e8..8bde5f37 100755 --- a/test/tenv/lib.sh +++ b/test/tenv/lib.sh @@ -86,6 +86,11 @@ assert_nocond() assert "Condition $cond cleared" "$(texec initctl -v cond get "$cond")" = "off" } +assert_is_pidfile() +{ + assert "Process has PID file: $2" "$(texec initctl -p status "$1" | awk '/PID file/{print $4}')" = "$2" +} + # shellcheck disable=SC2086 assert_has_pidfile() {