From: Davin McCall Date: Tue, 3 Dec 2019 11:40:18 +0000 (+1000) Subject: Add integration test for reload X-Git-Tag: v0.8.0~13 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0b94d900a87b8545ee7308deabec3f5e7bd5eec6;p=oweals%2Fdinit.git Add integration test for reload --- diff --git a/src/igr-tests/Makefile b/src/igr-tests/Makefile index be07234..ba69eb4 100644 --- a/src/igr-tests/Makefile +++ b/src/igr-tests/Makefile @@ -10,3 +10,4 @@ clean: rm -f igr-runner basic/basic-ran environ/env-record ps-environ/env-record chain-to/recorded-output rm -f restart/basic-ran rm -f check-basic/output.txt check-cycle/output.txt + rm -rf reload1/sd diff --git a/src/igr-tests/igr-runner.cc b/src/igr-tests/igr-runner.cc index 62349d4..536f918 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" }; + "check-basic", "check-cycle", "reload1" }; constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]); int passed = 0; diff --git a/src/igr-tests/reload1/initial.expected b/src/igr-tests/reload1/initial.expected new file mode 100644 index 0000000..c92341c --- /dev/null +++ b/src/igr-tests/reload1/initial.expected @@ -0,0 +1,3 @@ +[{+} ] boot +[{+} ] a +[{+} ] b diff --git a/src/igr-tests/reload1/output2.expected b/src/igr-tests/reload1/output2.expected new file mode 100644 index 0000000..6f78fa3 --- /dev/null +++ b/src/igr-tests/reload1/output2.expected @@ -0,0 +1 @@ +dinitctl: Could not reload service; service in wrong state, incompatible change, or bad service description. diff --git a/src/igr-tests/reload1/output3.expected b/src/igr-tests/reload1/output3.expected new file mode 100644 index 0000000..556ec43 --- /dev/null +++ b/src/igr-tests/reload1/output3.expected @@ -0,0 +1,4 @@ +[{+} ] boot +[ {-}] a +[{+} ] b +[{+} ] c diff --git a/src/igr-tests/reload1/run-test.sh b/src/igr-tests/reload1/run-test.sh new file mode 100755 index 0000000..a563b66 --- /dev/null +++ b/src/igr-tests/reload1/run-test.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# 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 + +STATUS=PASS + +if [ "$(../../dinitctl -p socket list)" != "$(cat initial.expected)" ]; then + STATUS=FAIL +fi + +# Put alternate descriptions in place: boot depends on b, c +if [ "$STATUS" = PASS ]; then + rm -rf sd + cp -R sd2 sd + + # First attempt should fail, c not started + if [ "$(../../dinitctl --quiet -p socket reload boot 2>&1)" != "$(cat output2.expected)" ]; then + STATUS=FAIL + fi + +fi + +if [ "$STATUS" = PASS ]; then + ../../dinitctl --quiet -p socket start c + ../../dinitctl --quiet -p socket reload boot + if [ "$(../../dinitctl --quiet -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/reload1/sd1/a b/src/igr-tests/reload1/sd1/a new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload1/sd1/a @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload1/sd1/b b/src/igr-tests/reload1/sd1/b new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload1/sd1/b @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload1/sd1/boot b/src/igr-tests/reload1/sd1/boot new file mode 100644 index 0000000..c24e005 --- /dev/null +++ b/src/igr-tests/reload1/sd1/boot @@ -0,0 +1,3 @@ +type = internal +depends-on = a +depends-on = b diff --git a/src/igr-tests/reload1/sd1/c b/src/igr-tests/reload1/sd1/c new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload1/sd1/c @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload1/sd2/a b/src/igr-tests/reload1/sd2/a new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload1/sd2/a @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload1/sd2/b b/src/igr-tests/reload1/sd2/b new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload1/sd2/b @@ -0,0 +1 @@ +type = internal diff --git a/src/igr-tests/reload1/sd2/boot b/src/igr-tests/reload1/sd2/boot new file mode 100644 index 0000000..6257037 --- /dev/null +++ b/src/igr-tests/reload1/sd2/boot @@ -0,0 +1,3 @@ +type = internal +depends-on = b +depends-on = c diff --git a/src/igr-tests/reload1/sd2/c b/src/igr-tests/reload1/sd2/c new file mode 100644 index 0000000..06545a6 --- /dev/null +++ b/src/igr-tests/reload1/sd2/c @@ -0,0 +1 @@ +type = internal