mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
Instead of having to create files, and copying them in place for each test, we move all static test files to a skeleton rootfs. This makes it a lot easier to get an overview of how things and how they work. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
67 lines
1.7 KiB
Bash
Executable File
67 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
test_setup()
|
|
{
|
|
say "Test start $(date)"
|
|
}
|
|
|
|
test_teardown()
|
|
{
|
|
say "Test done $(date)"
|
|
say "Running test teardown."
|
|
|
|
texec rm -f "$FINIT_CONF"
|
|
}
|
|
|
|
test_one()
|
|
{
|
|
pidfn=$1
|
|
service=$2
|
|
|
|
say "Add service stanza '$service' to $FINIT_CONF ..."
|
|
texec sh -c "echo '$service' > $FINIT_CONF"
|
|
|
|
say 'Reload Finit'
|
|
#texec sh -c "initctl debug"
|
|
texec sh -c "initctl reload"
|
|
#texec sh -c "initctl status"
|
|
#texec sh -c "ps"
|
|
|
|
#texec sh -c "initctl status"
|
|
#texec sh -c "ps"
|
|
#texec sh -c "initctl status serv"
|
|
|
|
retry 'assert_num_children 1 serv'
|
|
retry "assert_pidfile $pidfn" 1
|
|
|
|
say 'Stop the service'
|
|
texec sh -c "initctl stop serv"
|
|
|
|
retry 'assert_num_children 0 serv'
|
|
|
|
say 'Start the service again'
|
|
texec sh -c "initctl start serv"
|
|
|
|
retry 'assert_num_children 1 serv'
|
|
|
|
say "Done, drop service from $FINIT_CONF ..."
|
|
texec sh -c "rm $FINIT_CONF"
|
|
texec sh -c "initctl reload"
|
|
}
|
|
|
|
# shellcheck source=/dev/null
|
|
. "$TEST_DIR/tenv/lib.sh"
|
|
|
|
test_one "/run/serv.pid" "service pid:!/run/serv.pid serv -- Forking service, type 1"
|
|
test_one "/run/serv.pid" "service type:forking serv -- Forking service, type 2"
|
|
# This one could never be started by and monitored by Finit: it forks to
|
|
# background and does not create a PID file. Essentially it's lost to
|
|
# Finit, and any other sane process monitor.
|
|
#test_one "/run/serv.pid" "service pid:/run/serv.pid serv -p -- Forking service w/o PID file"
|
|
test_one "/run/serv.pid" "service pid:/run/serv.pid serv -n -- Foreground service w/o PID file"
|
|
test_one "/run/serv.pid" "service serv -n -p -- Foreground service w/ PID file"
|
|
test_one "/run/servy.pid" "service pid:/run/servy.pid serv -n -p -P /run/servy.pid -- Foreground service w/ custom PID file"
|