diff --git a/TODO.org b/TODO.org index 79d5fd0c..1c661aad 100644 --- a/TODO.org +++ b/TODO.org @@ -1,5 +1,6 @@ * TODO fix pid parser, //run/foo.pid -> /var/run///run/foo.pid -* TODO test framework refactor 'texec sh -c ...' -> 'run ...' +** DONE test framework refactor 'texec sh -c ...' -> 'run ...' * TODO Clean up tests a bit * TODO Drop tenv or common and rename tenv-root +* TODO rename test/lib.sh to start.sh or sth diff --git a/test/add-remove-dynamic-service-sub-config.sh b/test/add-remove-dynamic-service-sub-config.sh index a1f4387f..81bcc1d7 100755 --- a/test/add-remove-dynamic-service-sub-config.sh +++ b/test/add-remove-dynamic-service-sub-config.sh @@ -10,25 +10,25 @@ TEST_DIR=$(dirname "$0") test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_RCSD/service.conf" + say "Running test teardown." + run "rm -f $FINIT_RCSD/service.conf" } say "Test start $(date)" say "Add a dynamic service in $FINIT_RCSD/service.conf" -texec sh -c "echo 'service [2345] kill:20 log service.sh -- Dyn serv' > $FINIT_RCSD/service.conf" +run "echo 'service [2345] kill:20 log service.sh -- Dyn serv' > $FINIT_RCSD/service.conf" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" retry 'assert_num_children 1 service.sh' say 'Remove the dynamic service from /etc/finit.d/service.conf' -texec sh -c "echo > $FINIT_RCSD/service.conf" +run "echo > $FINIT_RCSD/service.conf" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" retry 'assert_num_children 0 service.sh' diff --git a/test/add-remove-dynamic-service.sh b/test/add-remove-dynamic-service.sh index 0adef719..14a31b2b 100755 --- a/test/add-remove-dynamic-service.sh +++ b/test/add-remove-dynamic-service.sh @@ -10,25 +10,25 @@ TEST_DIR=$(dirname "$0") test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } say "Test start $(date)" say "Add a dynamic service in $FINIT_CONF" -texec sh -c "echo 'service [2345] kill:20 log service.sh -- Dyn service' > $FINIT_CONF" +run "echo 'service [2345] kill:20 log service.sh -- Dyn service' > $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" retry 'assert_num_children 1 service.sh' say 'Remove the dynamic service from /etc/finit.conf' -texec sh -c "echo > $FINIT_CONF" +run "echo > $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" retry 'assert_num_children 0 service.sh' diff --git a/test/cond-start-task.sh b/test/cond-start-task.sh index 13a07b63..62bb504d 100755 --- a/test/cond-start-task.sh +++ b/test/cond-start-task.sh @@ -22,7 +22,7 @@ test_teardown() { say "Test done $(date)" say "Running test teardown." - texec rm -f "$TEST_CONF" + run "rm -f $TEST_CONF" } test_one() @@ -32,60 +32,60 @@ test_one() sleep 5 say 'Enable finit debug, try to figure out what is going on ...' - texec sh -c "initctl debug" + run "initctl debug" say "Add stanza '$stanza' to $TEST_CONF ..." - texec sh -c "echo '$stanza' > $TEST_CONF" + run "echo '$stanza' > $TEST_CONF" - texec sh -c "ls -l /run/ /run/finit/" + run "ls -l /run/ /run/finit/" say 'Reload Finit' - texec sh -c "initctl ls" - texec sh -c "initctl reload" - texec sh -c "initctl status" - texec sh -c "ps" + run "initctl ls" + run "initctl reload" + run "initctl status" + run "ps" date sleep 2 date - texec sh -c "ls -l /run/ /run/finit/" + run "ls -l /run/ /run/finit/" say 'Asserting condition' - texec sh -c "initctl cond set $cond" + run "initctl cond set $cond" date sleep 2 date - texec sh -c "ls -l /run/ /run/finit/" - texec sh -c "initctl status" - texec sh -c "ps" - texec sh -c "initctl status task.sh" + run "ls -l /run/ /run/finit/" + run "initctl status" + run "ps" + run "initctl status task.sh" sleep 1 - texec sh -c "echo Hej; cat /run/task.state" + run "echo Hej; cat /run/task.state" assert_file_contains /run/task.state 1 say 'Reload Finit' - texec sh -c "initctl reload" + run "initctl reload" sleep 1 say 'Ensure task has not run again ...' assert_file_contains /run/task.state 1 say 'Switch to another runlevel ...' - texec sh -c "initctl runlevel 3" + run "initctl runlevel 3" sleep 1 say 'Ensure task has run again ...' assert_file_contains /run/task.state 2 say 'Touch task.sh .conf file and reload Finit ...' - texec sh -c "touch $TEST_CONF" - texec sh -c "initctl reload" + run "touch $TEST_CONF" + run "initctl reload" sleep 1 -# texec sh -c "initctl status task.sh" +# run "initctl status task.sh" assert_file_contains /run/task.state 3 say "Done, drop stanza from $TEST_CONF ..." - texec sh -c "rm $TEST_CONF" - texec sh -c "initctl reload" + run "rm $TEST_CONF" + run "initctl reload" } test_one "hello" "task task.sh -- Hello task" diff --git a/test/crashing.sh b/test/crashing.sh index fc4ffb72..40af29d4 100755 --- a/test/crashing.sh +++ b/test/crashing.sh @@ -13,9 +13,9 @@ test_setup() test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_CONF" "/tmp/post" + say "Running test teardown." + run "rm -f $FINIT_CONF" "/tmp/post" } crashit() @@ -28,7 +28,7 @@ crashit() while [ $i -lt $laps ]; do i=$((i + 1)) say "Lap $i/$laps, killing service $nm ..." # we have this, no sleep needed - if ! texec sh -c "slay $nm"; then + if ! run "slay $nm"; then break; fi done @@ -43,27 +43,27 @@ test_one() args=$* say "Add service stanza in $FINIT_CONF" - texec sh -c "echo service log:stderr oncrash:script post:/bin/post.sh $nm $args > $FINIT_CONF" + run "echo service log:stderr oncrash:script post:/bin/post.sh $nm $args > $FINIT_CONF" say 'Reload Finit' - texec sh -c "initctl reload" + run "initctl reload" if [ "$type" = "sig" ]; then retry "assert_num_children 1 $nm" - texec sh -c "initctl status $nm" + run "initctl status $nm" crashit "$nm" fi retry "assert_status $nm crashed" 500 - texec cat /tmp/post + run "cat /tmp/post" assert_file_contains "/tmp/post" "POST" - texec rm -f "/tmp/post" + run "rm -f /tmp/post" } # shellcheck source=/dev/null . "$TEST_DIR/tenv/lib.sh" -#texec sh -c "initctl debug" +#run "initctl debug" test_one sig service.sh " -- Test crashing service.sh" test_one app serv "-np -c -- Test crashing serv" diff --git a/test/depserv.sh b/test/depserv.sh index 47ee5dbe..3c9a2af2 100755 --- a/test/depserv.sh +++ b/test/depserv.sh @@ -24,7 +24,7 @@ test_teardown() say "Test done $(date)" say "Running test teardown." - texec rm -f "$FINIT_CONF" "/tmp/post" + run "rm -f $FINIT_CONF" "/tmp/post" } # shellcheck source=/dev/null @@ -51,7 +51,7 @@ test_one() say "Verify bar is restarted with foo is ..." pid=$(texec initctl |grep bar | awk '{print $1;}') - texec initctl restart foo + run "initctl restart foo" assert "bar is restarted" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid" # Wait for spice to be stolen by the Harkonnen diff --git a/test/devmon.sh b/test/devmon.sh index c308ce67..77b08d55 100755 --- a/test/devmon.sh +++ b/test/devmon.sh @@ -20,7 +20,7 @@ test_teardown() say "Test done $(date)" say "Running test teardown." - texec rm -f "$FINIT_CONF" "/tmp/post" + run "rm -f $FINIT_CONF /tmp/post" } # Cannot run mknod as non-root even in a chroot diff --git a/test/failing-sysv.sh b/test/failing-sysv.sh index fea55480..740d8d1e 100755 --- a/test/failing-sysv.sh +++ b/test/failing-sysv.sh @@ -9,15 +9,15 @@ TEST_DIR=$(dirname "$0") test_setup() { say "Test start $(date)" - texec sh -c "mkdir -p /etc/default" + run "mkdir -p /etc/default" } test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } # shellcheck source=/dev/null @@ -27,21 +27,21 @@ test_teardown() # if it cannot find "xyzzy", thus triggering a premature # exit which Finit should act on to retstart it. say "Setting up bogus /etc/default/serv" -texec sh -c "echo 'SERV_ARGS=\"-e xyzzy:lives\"' > /etc/default/serv" +run "echo 'SERV_ARGS=\"-e xyzzy:lives\"' > /etc/default/serv" say "Add sysv stanza to $FINIT_CONF" -texec sh -c "echo 'sysv restart:5 [2345] pid:!/run/serv.pid name:serv /etc/init.d/S02-serv.sh -- Crashing SysV service' > $FINIT_CONF" +run "echo 'sysv restart:5 [2345] pid:!/run/serv.pid name:serv /etc/init.d/S02-serv.sh -- Crashing SysV service' > $FINIT_CONF" -#texec sh -c "initctl debug" +#run "initctl debug" say 'Reload Finit' -texec sh -c "initctl reload" -#texec sh -c "initctl status serv" -#texec sh -c "ps" +run "initctl reload" +#run "initctl status serv" +#run "ps" say 'Pending sysv restarts by Finit ...' -#texec sh -c "initctl status serv" -#texec sh -c "ps" +#run "initctl status serv" +#run "ps" retry 'assert_restarts 5 serv' 20 1 return 0 diff --git a/test/global-envs.sh b/test/global-envs.sh index 62c7c668..f635b4ef 100755 --- a/test/global-envs.sh +++ b/test/global-envs.sh @@ -12,45 +12,46 @@ test_teardown() { say "Test done $(date)" - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } # shellcheck source=/dev/null . "$TEST_DIR/tenv/lib.sh" -#texec sh -c "initctl debug" +#run "initctl debug" say "Add custom envs to $FINIT_CONF ..." -texec sh -c "echo 'foo=bar' > $FINIT_CONF" -texec sh -c "echo 'baz=qux' >> $FINIT_CONF" +run "echo 'foo=bar' > $FINIT_CONF" +run "echo 'baz=qux' >> $FINIT_CONF" say "Add service stanza to $FINIT_CONF ..." -texec sh -c "echo 'service serv -np -e foo:bar -- Verify foo=bar' >> $FINIT_CONF" +run "echo 'service serv -np -e foo:bar -- Verify foo=bar' >> $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" sleep 1 retry 'assert_num_children 1 serv' say "Modify $FINIT_CONF slightly ..." -texec sh -c "sed -i 's/foo:bar/baz:qux/; s/foo=bar/baz=qux/' $FINIT_CONF" +run "sed -i 's/foo:bar/baz:qux/; s/foo=bar/baz=qux/' $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" sleep 1 retry 'assert_num_children 1 serv' say "Swap envs completely in $FINIT_CONF ..." -texec sh -c "echo 'bar=foo' > $FINIT_CONF" -texec sh -c "echo 'qux=baz' >> $FINIT_CONF" +run "echo 'bar=foo' > $FINIT_CONF" +run "echo 'qux=baz' >> $FINIT_CONF" say "Add swapped service stanza to $FINIT_CONF ..." -texec sh -c "echo 'service serv -np -e bar:foo -E baz -- Verify bar=foo and no baz' >> $FINIT_CONF" +run "echo 'service serv -np -e bar:foo -E baz -- Verify bar=foo and no baz' >> $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" sleep 1 retry 'assert_num_children 1 serv' say "Done, drop service from $FINIT_CONF ..." -texec sh -c "rm $FINIT_CONF" -texec sh -c "initctl reload" +run "rm $FINIT_CONF" +run "initctl reload" diff --git a/test/initctl-status-subset.sh b/test/initctl-status-subset.sh index ccd9fd61..db851531 100755 --- a/test/initctl-status-subset.sh +++ b/test/initctl-status-subset.sh @@ -16,12 +16,13 @@ test_teardown() { say "Test done $(date)" - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } test_init() { - texec sh -c "echo '# Three foo and one bar enter Finit' > $FINIT_CONF" + run "echo '# Three foo and one bar enter Finit' > $FINIT_CONF" } test_add_one() @@ -29,7 +30,7 @@ test_add_one() service=$1 say "Add service stanza '$service' to $FINIT_CONF ..." - texec sh -c "echo '$service' >> $FINIT_CONF" + run "echo '$service' >> $FINIT_CONF" } # shellcheck source=/dev/null @@ -43,13 +44,13 @@ test_add_one "task manual:yes name:foo :3 serv -- Foo \#3" test_add_one "task manual:yes name:foobar serv -- Foobar" say 'Reload Finit' -#texec sh -c "initctl debug" -texec sh -c "initctl reload" -texec sh -c "initctl status" +#run "initctl debug" +run "initctl reload" +run "initctl status" -#texec sh -c "initctl status" -#texec sh -c "ps" -#texec sh -c "initctl status serv" +#run "initctl status" +#run "ps" +#run "initctl status serv" assert_num_services 3 foo assert_desc "Foobar" foobar diff --git a/test/pre-post-serv.sh b/test/pre-post-serv.sh index 00d216fd..d4652a11 100755 --- a/test/pre-post-serv.sh +++ b/test/pre-post-serv.sh @@ -12,7 +12,8 @@ test_teardown() { say "Test done $(date)" - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } test_one() @@ -24,35 +25,35 @@ test_one() postcont=$5 say "Add service stanza '$service' to $FINIT_CONF ..." - texec sh -c "echo '$service' > $FINIT_CONF" + run "echo '$service' > $FINIT_CONF" say 'Reload Finit' - texec sh -c "initctl reload" + run "initctl reload" retry 'assert_num_children 1 serv' if [ -n "$pre" ]; then assert_file_contains "$pre" "$precont" - texec sh -c "rm -f $pre" + run "rm -f $pre" fi say 'Stop the service' - texec sh -c "initctl stop serv" + run "initctl stop serv" retry 'assert_num_children 0 serv' if [ -n "$post" ]; then assert_file_contains "$post" "$postcont" - texec sh -c "rm -f $post" + run "rm -f $post" fi say "Done, drop service from $FINIT_CONF ..." - texec sh -c "rm $FINIT_CONF" - texec sh -c "initctl reload" + run "rm $FINIT_CONF" + run "initctl reload" } # shellcheck source=/dev/null . "$TEST_DIR/tenv/lib.sh" -#texec sh -c "initctl debug" +#run "initctl debug" test_one "" "" "service serv -np -- Regular fg service, no pre/post scripts" "" "" test_one "" "" "service env:/etc/env serv -np -e foo:bar -- serv + env, no pre/post scripts" "" "" diff --git a/test/ready-serv.sh b/test/ready-serv.sh index 6a7718f8..62b07d3d 100755 --- a/test/ready-serv.sh +++ b/test/ready-serv.sh @@ -13,7 +13,8 @@ test_teardown() { say "Test done $(date)" - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } test_one() @@ -22,28 +23,28 @@ test_one() file=/tmp/ready say "Add service stanza '$service' to $FINIT_CONF ..." - texec sh -c "echo '$service' > $FINIT_CONF" + run "echo '$service' > $FINIT_CONF" say 'Reload Finit' - texec sh -c "initctl reload" + run "initctl reload" retry 'assert_num_children 1 serv' assert_file_contains "$file" "READY" - texec sh -c "rm -f $file" + run "rm -f $file" say 'Stop the service' - texec sh -c "initctl stop serv" + run "initctl stop serv" retry 'assert_num_children 0 serv' say "Done, drop service from $FINIT_CONF ..." - texec sh -c "rm $FINIT_CONF" - texec sh -c "initctl reload" + run "rm $FINIT_CONF" + run "initctl reload" } # shellcheck source=/dev/null . "$TEST_DIR/tenv/lib.sh" -#texec sh -c "initctl debug" +#run "initctl debug" test_one "service ready:/bin/ready.sh serv -np -- Native style notification" test_one "service notify:s6 ready:/bin/ready.sh serv -np -N %n -- s6 style notification" diff --git a/test/restart-self.sh b/test/restart-self.sh index fef8f010..e4a7b6cf 100755 --- a/test/restart-self.sh +++ b/test/restart-self.sh @@ -7,15 +7,15 @@ TEST_DIR=$(dirname "$0") test_setup() { say "Test start $(date)" - texec sh -c "mkdir -p /etc/default" + run "mkdir -p /etc/default" } test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } check_restarts() @@ -28,18 +28,18 @@ check_restarts() . "$TEST_DIR/tenv/lib.sh" say "Add stanza to $FINIT_CONF" -texec sh -c "echo 'service serv -np -r serv -- Restart self' > $FINIT_CONF" +run "echo 'service serv -np -r serv -- Restart self' > $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" sleep 2 -texec sh -c "initctl status serv" -texec sh -c "ps" +run "initctl status serv" +run "ps" sleep 2 -texec sh -c "initctl status serv" -texec sh -c "ps" +run "initctl status serv" +run "ps" say 'Pending restarts by itself ...' retry 'check_restarts /tmp/serv-restart.cnt 3' 20 1 diff --git a/test/runlevel.sh b/test/runlevel.sh index c8691623..b4062512 100755 --- a/test/runlevel.sh +++ b/test/runlevel.sh @@ -21,7 +21,7 @@ test_teardown() . "$TEST_DIR/tenv/lib.sh" say 'Check runlevel' -lvl=$(texec sh -c "initctl runlevel | awk '{print \$2;}'") +lvl=$(run "initctl runlevel | awk '{print \$2;}'") if [ "$lvl" -eq "9" ]; then return 0 fi diff --git a/test/signal-service.sh b/test/signal-service.sh index de104ca7..6338610a 100755 --- a/test/signal-service.sh +++ b/test/signal-service.sh @@ -11,9 +11,9 @@ TEST_DIR=$(dirname "$0") test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } say "Test start $(date)" diff --git a/test/start-kill-service.sh b/test/start-kill-service.sh index d343e20e..49067965 100755 --- a/test/start-kill-service.sh +++ b/test/start-kill-service.sh @@ -12,24 +12,24 @@ TEST_DIR=$(dirname "$0") test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } say "Test start $(date)" rm -f "$TENV_ROOT"/oldpid say "Add service stanza in $FINIT_CONF" -texec sh -c "echo 'service [2345] respawn log:stderr service.sh -- Test service' > $FINIT_CONF" +run "echo 'service [2345] respawn log:stderr service.sh -- Test service' > $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" -#texec sh -c "initctl status" -#texec sh -c "initctl debug" +run "initctl reload" +#run "initctl status" +#run "initctl debug" retry 'assert_num_children 1 service.sh' -texec sh -c "initctl status service.sh" +run "initctl status service.sh" say 'Simulate service crash (kill -9 ..)' i=0 @@ -37,7 +37,7 @@ laps=1000 while [ $i -lt $laps ]; do i=$((i + 1)) say "Lap $i/$laps, killing service ..." # we have this, no sleep needed - texec sh -c "slay service.sh" + run "slay service.sh" done retry 'assert_new_pid service.sh /run/service.pid' diff --git a/test/start-kill-stop.sh b/test/start-kill-stop.sh index 1cd6138d..63c8dce6 100755 --- a/test/start-kill-stop.sh +++ b/test/start-kill-stop.sh @@ -14,11 +14,11 @@ TEST_DIR=$(dirname "$0") test_teardown() { -# texec sh -c "initctl status -j serv" +# run "initctl status -j serv" say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } say "Check deps ..." @@ -28,37 +28,37 @@ say "Test start $(date)" rm -f "$TENV_ROOT"/oldpid say "Add service stanza in $FINIT_CONF" -texec sh -c "echo 'service [2345] log:stderr serv -np -- Test service' > $FINIT_CONF" +run "echo 'service [2345] log:stderr serv -np -- Test service' > $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" say 'Verify serv is running ...' retry 'assert_num_children 1 serv' say 'Verify reload does not change forking type of service' -#texec sh -c "initctl status -j serv" -texec sh -c "initctl reload" -#texec sh -c "initctl status -j serv" +#run "initctl status -j serv" +run "initctl reload" +#run "initctl status -j serv" assert_forking serv false say 'Simulate service crash (kill -9 ..)' -texec sh -c "initctl debug" +run "initctl debug" i=0 laps=7 while [ $i -lt $laps ]; do i=$((i + 1)) say "Lap $i/$laps, killing service ..." # we have this, no sleep needed - texec sh -c "slay serv" + run "slay serv" done say 'Verify stopping service actually stops it' sleep 1 -texec sh -c "initctl stop serv" +run "initctl stop serv" sleep 5 -#texec sh -c "initctl status serv" +#run "initctl status serv" assert_status serv stopped say 'Verify restarting service actually starts it' -texec sh -c "initctl start serv" +run "initctl start serv" retry 'assert_num_children 1 serv' diff --git a/test/start-stop-serv.sh b/test/start-stop-serv.sh index 83fcb685..45065101 100755 --- a/test/start-stop-serv.sh +++ b/test/start-stop-serv.sh @@ -11,9 +11,9 @@ test_setup() test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } test_one() @@ -22,34 +22,34 @@ test_one() service=$2 say "Add service stanza '$service' to $FINIT_CONF ..." - texec sh -c "echo '$service' > $FINIT_CONF" + run "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" + #run "initctl debug" + run "initctl reload" + #run "initctl status" + #run "ps" - #texec sh -c "initctl status" - #texec sh -c "ps" - #texec sh -c "initctl status serv" + #run "initctl status" + #run "ps" + #run "initctl status serv" retry 'assert_num_children 1 serv' retry "assert_pidfile $pidfn" 1 say 'Stop the service' - texec sh -c "initctl stop serv" + run "initctl stop serv" retry 'assert_num_children 0 serv' say 'Start the service again' - texec sh -c "initctl start serv" + run "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" + run "rm $FINIT_CONF" + run "initctl reload" } # shellcheck source=/dev/null diff --git a/test/start-stop-service-sub-config.sh b/test/start-stop-service-sub-config.sh index 937c05e6..d700d9d3 100755 --- a/test/start-stop-service-sub-config.sh +++ b/test/start-stop-service-sub-config.sh @@ -10,30 +10,30 @@ TEST_DIR=$(dirname "$0") test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_RCSD/service.conf" + say "Running test teardown." + run "rm -f $FINIT_RCSD/service.conf" } say "Test start $(date)" say "Add service stanza in $FINIT_RCSD/service.conf" -texec sh -c "echo 'service [2345] kill:20 log service.sh -- Subserv' > $FINIT_RCSD/service.conf" +run "echo 'service [2345] kill:20 log service.sh -- Subserv' > $FINIT_RCSD/service.conf" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" sleep 2 -texec sh -c "ps" +run "ps" retry 'assert_num_children 1 service.sh' say 'Stop the service' -texec sh -c "initctl stop service.sh" +run "initctl stop service.sh" retry 'assert_num_children 0 service.sh' say 'Start the service again' -texec sh -c "initctl start service.sh" +run "initctl start service.sh" retry 'assert_num_children 1 service.sh' diff --git a/test/start-stop-service.sh b/test/start-stop-service.sh index 40a53479..ca0da31a 100755 --- a/test/start-stop-service.sh +++ b/test/start-stop-service.sh @@ -10,27 +10,27 @@ TEST_DIR=$(dirname "$0") test_teardown() { say "Test done $(date)" - say "Running test teardown." - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } say "Test start $(date)" say "Add service stanza in $FINIT_CONF" -texec sh -c "echo 'service [2345] kill:20 log service.sh -- Test service' > $FINIT_CONF" +run "echo 'service [2345] kill:20 log service.sh -- Test service' > $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" retry 'assert_num_children 1 service.sh' say 'Stop the service' -texec sh -c "initctl stop service.sh" +run "initctl stop service.sh" retry 'assert_num_children 0 service.sh' say 'Start the service again' -texec sh -c "initctl start service.sh" +run "initctl start service.sh" retry 'assert_num_children 1 service.sh' diff --git a/test/start-stop-sysv.sh b/test/start-stop-sysv.sh index 17a33756..a73d7a99 100755 --- a/test/start-stop-sysv.sh +++ b/test/start-stop-sysv.sh @@ -9,29 +9,29 @@ TEST_DIR=$(dirname "$0") test_teardown() { - say "Test done $(date)" - say "Running test teardown." + say "Test done $(date)" - texec rm -f "$FINIT_CONF" + say "Running test teardown." + run "rm -f $FINIT_CONF" } say "Test start $(date)" say "Add sysv stanza in $FINIT_CONF" -texec sh -c "echo 'sysv [2345] pid:!/run/service.pid name:service.sh /etc/init.d/S01-service.sh -- SysV test service' > $FINIT_CONF" +run "echo 'sysv [2345] pid:!/run/service.pid name:service.sh /etc/init.d/S01-service.sh -- SysV test service' > $FINIT_CONF" say 'Reload Finit' -texec sh -c "initctl reload" +run "initctl reload" retry 'assert_num_children 1 service.sh' say 'Stop the sysv service' -texec sh -c "initctl stop service.sh" +run "initctl stop service.sh" retry 'assert_num_children 0 service.sh' say 'Start the sysv service again' -texec sh -c "initctl start service.sh" +run "initctl start service.sh" retry 'assert_num_children 1 service.sh'