Add integration test for reload
authorDavin McCall <davmac@davmac.org>
Tue, 3 Dec 2019 11:40:18 +0000 (21:40 +1000)
committerDavin McCall <davmac@davmac.org>
Tue, 3 Dec 2019 11:40:18 +0000 (21:40 +1000)
14 files changed:
src/igr-tests/Makefile
src/igr-tests/igr-runner.cc
src/igr-tests/reload1/initial.expected [new file with mode: 0644]
src/igr-tests/reload1/output2.expected [new file with mode: 0644]
src/igr-tests/reload1/output3.expected [new file with mode: 0644]
src/igr-tests/reload1/run-test.sh [new file with mode: 0755]
src/igr-tests/reload1/sd1/a [new file with mode: 0644]
src/igr-tests/reload1/sd1/b [new file with mode: 0644]
src/igr-tests/reload1/sd1/boot [new file with mode: 0644]
src/igr-tests/reload1/sd1/c [new file with mode: 0644]
src/igr-tests/reload1/sd2/a [new file with mode: 0644]
src/igr-tests/reload1/sd2/b [new file with mode: 0644]
src/igr-tests/reload1/sd2/boot [new file with mode: 0644]
src/igr-tests/reload1/sd2/c [new file with mode: 0644]

index be072344479d7001846c6f3b8995becc51faa7eb..ba69eb41d15404cc0a5eab16be0a000718aa3661 100644 (file)
@@ -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
index 62349d4a479129f063beff0d145f466e89823bc3..536f918dcf9ca7f1772439ebcef3ba7ca8275425 100644 (file)
@@ -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 (file)
index 0000000..c92341c
--- /dev/null
@@ -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 (file)
index 0000000..6f78fa3
--- /dev/null
@@ -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 (file)
index 0000000..556ec43
--- /dev/null
@@ -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 (executable)
index 0000000..a563b66
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..c24e005
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..6257037
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -0,0 +1 @@
+type = internal