From: Davin McCall Date: Sat, 27 Jul 2019 06:03:21 +0000 (+1000) Subject: Add integration test for gentle stop/force stop. X-Git-Tag: v0.7.0~19 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6c2281fb66e2c9de0738d9bbe3c2e20e69cfebcd;p=oweals%2Fdinit.git Add integration test for gentle stop/force stop. --- diff --git a/src/igr-tests/force-stop/expected-1 b/src/igr-tests/force-stop/expected-1 new file mode 100644 index 0000000..6737262 --- /dev/null +++ b/src/igr-tests/force-stop/expected-1 @@ -0,0 +1,3 @@ +[{+} ] boot +[{+} ] critical +[{+} ] intermediary diff --git a/src/igr-tests/force-stop/expected-2.err b/src/igr-tests/force-stop/expected-2.err new file mode 100644 index 0000000..561b7d2 --- /dev/null +++ b/src/igr-tests/force-stop/expected-2.err @@ -0,0 +1,3 @@ +dinitctl: Cannot stop service due to the following dependents: +(Only direct dependents are listed. Exercise caution before using '--force' !!) + intermediary boot diff --git a/src/igr-tests/force-stop/expected-3 b/src/igr-tests/force-stop/expected-3 new file mode 100644 index 0000000..d081f7a --- /dev/null +++ b/src/igr-tests/force-stop/expected-3 @@ -0,0 +1 @@ +Service stopped. diff --git a/src/igr-tests/force-stop/run-test.sh b/src/igr-tests/force-stop/run-test.sh new file mode 100755 index 0000000..44d52b5 --- /dev/null +++ b/src/igr-tests/force-stop/run-test.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +../../dinit -d sd -u -p socket -q & +DINITPID=$! + +# give time for socket to open +while [ ! -e socket ]; do + sleep 0.1 +done + +DINITCTLOUT="$(../../dinitctl -p socket list)" +if [ "$DINITCTLOUT" != "$(cat expected-1)" ]; then + kill $DINITPID; wait $DINITPID + exit 1 +fi + +DINITCTLOUT="$(../../dinitctl -p socket stop critical 2>&1)" +if [ "$DINITCTLOUT" != "$(cat expected-2.err)" ]; then + kill $DINITPID; wait $DINITPID + exit 1 +fi + +DINITCTLOUT="$(../../dinitctl -p socket stop --force critical 2>&1)" +if [ "$DINITCTLOUT" != "$(cat expected-3)" ]; then + kill $DINITPID; wait $DINITPID + exit 1; +fi + +# Note dinit should shutdown since all services stopped. +wait $DINITPID + +# Passed: +exit 0 diff --git a/src/igr-tests/force-stop/sd/boot b/src/igr-tests/force-stop/sd/boot new file mode 100644 index 0000000..b55189a --- /dev/null +++ b/src/igr-tests/force-stop/sd/boot @@ -0,0 +1,3 @@ +type = internal +depends-on = critical +depends-on = intermediary diff --git a/src/igr-tests/force-stop/sd/critical b/src/igr-tests/force-stop/sd/critical new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/force-stop/sd/critical @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/force-stop/sd/intermediary b/src/igr-tests/force-stop/sd/intermediary new file mode 100644 index 0000000..187d6af --- /dev/null +++ b/src/igr-tests/force-stop/sd/intermediary @@ -0,0 +1,2 @@ +type = internal +depends-on = critical diff --git a/src/igr-tests/igr-runner.cc b/src/igr-tests/igr-runner.cc index e8a906b..879fe7d 100644 --- a/src/igr-tests/igr-runner.cc +++ b/src/igr-tests/igr-runner.cc @@ -12,7 +12,7 @@ extern char **environ; int main(int argc, char **argv) { - const char * const test_dirs[] = { "basic", "environ", "ps-environ", "chain-to" }; + const char * const test_dirs[] = { "basic", "environ", "ps-environ", "chain-to", "force-stop" }; constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]); int passed = 0;