Add 2nd reload test
authorDavin McCall <davmac@davmac.org>
Thu, 5 Dec 2019 13:45:16 +0000 (23:45 +1000)
committerDavin McCall <davmac@davmac.org>
Thu, 5 Dec 2019 13:45:23 +0000 (23:45 +1000)
16 files changed:
.gitignore
src/igr-tests/Makefile
src/igr-tests/igr-runner.cc
src/igr-tests/reload2/initial.expected [new file with mode: 0644]
src/igr-tests/reload2/output2.expected [new file with mode: 0644]
src/igr-tests/reload2/output3.expected [new file with mode: 0644]
src/igr-tests/reload2/run-test.sh [new file with mode: 0755]
src/igr-tests/reload2/sd1/a [new file with mode: 0644]
src/igr-tests/reload2/sd1/b [new file with mode: 0644]
src/igr-tests/reload2/sd1/boot [new file with mode: 0644]
src/igr-tests/reload2/sd1/c [new file with mode: 0644]
src/igr-tests/reload2/sd1/hold [new file with mode: 0644]
src/igr-tests/reload2/sd2/a [new file with mode: 0644]
src/igr-tests/reload2/sd2/b [new file with mode: 0644]
src/igr-tests/reload2/sd2/boot [new file with mode: 0644]
src/igr-tests/reload2/sd2/c [new file with mode: 0644]

index 8910c47e9d534a60991a96ef9c88833396beb55a..7b8e784ccf2551600e7776a6cb782de54cae8919 100644 (file)
@@ -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
index ba69eb41d15404cc0a5eab16be0a000718aa3661..068381a6339d63b956077c6d0a031684b150e58e 100644 (file)
@@ -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
index 536f918dcf9ca7f1772439ebcef3ba7ca8275425..130cfed472f220def3f457b9d525b2b5f194502d 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", "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 (file)
index 0000000..b3573fb
--- /dev/null
@@ -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 (file)
index 0000000..56d934e
--- /dev/null
@@ -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 (file)
index 0000000..fea67c7
--- /dev/null
@@ -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 (executable)
index 0000000..4e61f38
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..c24e005
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..73253d7
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -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 (file)
index 0000000..6257037
--- /dev/null
@@ -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 (file)
index 0000000..06545a6
--- /dev/null
@@ -0,0 +1 @@
+type = internal