From 87ba6f7116c3f817b64ee57aa1cb021ec6f4f38b Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Thu, 5 Dec 2019 23:45:16 +1000 Subject: [PATCH] Add 2nd reload test --- .gitignore | 2 ++ src/igr-tests/Makefile | 1 + src/igr-tests/igr-runner.cc | 2 +- src/igr-tests/reload2/initial.expected | 4 +++ src/igr-tests/reload2/output2.expected | 1 + src/igr-tests/reload2/output3.expected | 5 +++ src/igr-tests/reload2/run-test.sh | 48 ++++++++++++++++++++++++++ src/igr-tests/reload2/sd1/a | 1 + src/igr-tests/reload2/sd1/b | 1 + src/igr-tests/reload2/sd1/boot | 3 ++ src/igr-tests/reload2/sd1/c | 1 + src/igr-tests/reload2/sd1/hold | 2 ++ src/igr-tests/reload2/sd2/a | 1 + src/igr-tests/reload2/sd2/b | 1 + src/igr-tests/reload2/sd2/boot | 3 ++ src/igr-tests/reload2/sd2/c | 1 + 16 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/igr-tests/reload2/initial.expected create mode 100644 src/igr-tests/reload2/output2.expected create mode 100644 src/igr-tests/reload2/output3.expected create mode 100755 src/igr-tests/reload2/run-test.sh create mode 100644 src/igr-tests/reload2/sd1/a create mode 100644 src/igr-tests/reload2/sd1/b create mode 100644 src/igr-tests/reload2/sd1/boot create mode 100644 src/igr-tests/reload2/sd1/c create mode 100644 src/igr-tests/reload2/sd1/hold create mode 100644 src/igr-tests/reload2/sd2/a create mode 100644 src/igr-tests/reload2/sd2/b create mode 100644 src/igr-tests/reload2/sd2/boot create mode 100644 src/igr-tests/reload2/sd2/c diff --git a/.gitignore b/.gitignore index 8910c47..7b8e784 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ /src/igr-tests/restart/basic-ran /src/igr-tests/check-basic/output.txt /src/igr-tests/check-cycle/output.txt +/src/igr-tests/reload1/sd +/src/igr-tests/reload2/sd # Generated man pages: /doc/manpages/*.5 diff --git a/src/igr-tests/Makefile b/src/igr-tests/Makefile index ba69eb4..068381a 100644 --- a/src/igr-tests/Makefile +++ b/src/igr-tests/Makefile @@ -11,3 +11,4 @@ clean: rm -f restart/basic-ran rm -f check-basic/output.txt check-cycle/output.txt rm -rf reload1/sd + rm -rf reload2/sd diff --git a/src/igr-tests/igr-runner.cc b/src/igr-tests/igr-runner.cc index 536f918..130cfed 100644 --- a/src/igr-tests/igr-runner.cc +++ b/src/igr-tests/igr-runner.cc @@ -13,7 +13,7 @@ extern char **environ; int main(int argc, char **argv) { const char * const test_dirs[] = { "basic", "environ", "ps-environ", "chain-to", "force-stop", "restart", - "check-basic", "check-cycle", "reload1" }; + "check-basic", "check-cycle", "reload1", "reload2" }; constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]); int passed = 0; diff --git a/src/igr-tests/reload2/initial.expected b/src/igr-tests/reload2/initial.expected new file mode 100644 index 0000000..b3573fb --- /dev/null +++ b/src/igr-tests/reload2/initial.expected @@ -0,0 +1,4 @@ +[{+} ] boot +[{+} ] a +[{+} ] b +[{+} ] hold diff --git a/src/igr-tests/reload2/output2.expected b/src/igr-tests/reload2/output2.expected new file mode 100644 index 0000000..56d934e --- /dev/null +++ b/src/igr-tests/reload2/output2.expected @@ -0,0 +1 @@ +Service reloaded. diff --git a/src/igr-tests/reload2/output3.expected b/src/igr-tests/reload2/output3.expected new file mode 100644 index 0000000..fea67c7 --- /dev/null +++ b/src/igr-tests/reload2/output3.expected @@ -0,0 +1,5 @@ +[{+} ] boot +[ {-}] a +[{+} ] b +[{+} ] hold +[{+} ] c diff --git a/src/igr-tests/reload2/run-test.sh b/src/igr-tests/reload2/run-test.sh new file mode 100755 index 0000000..4e61f38 --- /dev/null +++ b/src/igr-tests/reload2/run-test.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# Similar to reload1 test, but with boot service stopped while we reload. + +# Start with boot depending on a,b +rm -rf sd +cp -R sd1 sd + +../../dinit -d sd -u -p socket -q & +DINITPID=$! + +# Give some time for startup +sleep 0.2 + +../../dinitctl --quiet -p socket start hold + +STATUS=PASS + +if [ "$(../../dinitctl -p socket list)" != "$(cat initial.expected)" ]; then + STATUS=FAIL +fi + +../../dinitctl --quiet -p socket stop boot + +# Put alternate descriptions in place: boot depends on b, c +if [ "$STATUS" = PASS ]; then + rm -rf sd + cp -R sd2 sd + + # This should succeed since boot is stopped + if [ "$(../../dinitctl -p socket reload boot 2>&1)" != "$(cat output2.expected)" ]; then + STATUS=FAIL + fi + +fi + +if [ "$STATUS" = PASS ]; then + ../../dinitctl --quiet -p socket start boot + if [ "$(../../dinitctl -p socket list)" != "$(cat output3.expected)" ]; then + STATUS=FAIL + fi +fi + +../../dinitctl --quiet -p socket shutdown +wait $DINITPID + +if [ $STATUS = PASS ]; then exit 0; fi +exit 1 diff --git a/src/igr-tests/reload2/sd1/a b/src/igr-tests/reload2/sd1/a new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload2/sd1/a @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload2/sd1/b b/src/igr-tests/reload2/sd1/b new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload2/sd1/b @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload2/sd1/boot b/src/igr-tests/reload2/sd1/boot new file mode 100644 index 0000000..c24e005 --- /dev/null +++ b/src/igr-tests/reload2/sd1/boot @@ -0,0 +1,3 @@ +type = internal +depends-on = a +depends-on = b diff --git a/src/igr-tests/reload2/sd1/c b/src/igr-tests/reload2/sd1/c new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload2/sd1/c @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload2/sd1/hold b/src/igr-tests/reload2/sd1/hold new file mode 100644 index 0000000..73253d7 --- /dev/null +++ b/src/igr-tests/reload2/sd1/hold @@ -0,0 +1,2 @@ +# extra service to prevent shutdown when we stop boot +type = internal diff --git a/src/igr-tests/reload2/sd2/a b/src/igr-tests/reload2/sd2/a new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload2/sd2/a @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload2/sd2/b b/src/igr-tests/reload2/sd2/b new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload2/sd2/b @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload2/sd2/boot b/src/igr-tests/reload2/sd2/boot new file mode 100644 index 0000000..6257037 --- /dev/null +++ b/src/igr-tests/reload2/sd2/boot @@ -0,0 +1,3 @@ +type = internal +depends-on = b +depends-on = c diff --git a/src/igr-tests/reload2/sd2/c b/src/igr-tests/reload2/sd2/c new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload2/sd2/c @@ -0,0 +1 @@ +type = internal -- 2.25.1