Integration test for dinitcheck dependency cycles detection
authorDavin McCall <davmac@davmac.org>
Fri, 22 Nov 2019 13:29:57 +0000 (13:29 +0000)
committerDavin McCall <davmac@davmac.org>
Fri, 22 Nov 2019 13:29:57 +0000 (13:29 +0000)
.gitignore
src/igr-tests/Makefile
src/igr-tests/check-cycle/expected.txt [new file with mode: 0644]
src/igr-tests/check-cycle/run-test.sh [new file with mode: 0755]
src/igr-tests/check-cycle/sd/a [new file with mode: 0644]
src/igr-tests/check-cycle/sd/b [new file with mode: 0644]
src/igr-tests/check-cycle/sd/boot [new file with mode: 0644]
src/igr-tests/check-cycle/sd/c [new file with mode: 0644]
src/igr-tests/check-cycle/sd/d [new file with mode: 0644]
src/igr-tests/check-cycle/sd/e [new file with mode: 0644]
src/igr-tests/igr-runner.cc

index 24a87a4bbfe9d7b0d530acbf4e36c9b5435b3f6e..8910c47e9d534a60991a96ef9c88833396beb55a 100644 (file)
@@ -25,6 +25,7 @@
 /src/igr-tests/chain-to/recorded-output
 /src/igr-tests/restart/basic-ran
 /src/igr-tests/check-basic/output.txt
 /src/igr-tests/chain-to/recorded-output
 /src/igr-tests/restart/basic-ran
 /src/igr-tests/check-basic/output.txt
+/src/igr-tests/check-cycle/output.txt
 
 # Generated man pages:
 /doc/manpages/*.5
 
 # Generated man pages:
 /doc/manpages/*.5
index b148fb1085b4a71f101adf35753942ddc43b8796..be072344479d7001846c6f3b8995becc51faa7eb 100644 (file)
@@ -9,4 +9,4 @@ igr-runner: igr-runner.cc
 clean:
        rm -f igr-runner basic/basic-ran environ/env-record ps-environ/env-record chain-to/recorded-output
        rm -f restart/basic-ran
 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
+       rm -f check-basic/output.txt check-cycle/output.txt
diff --git a/src/igr-tests/check-cycle/expected.txt b/src/igr-tests/check-cycle/expected.txt
new file mode 100644 (file)
index 0000000..89dadf8
--- /dev/null
@@ -0,0 +1,11 @@
+Checking service: boot...
+Checking service: a...
+Checking service: b...
+Checking service: c...
+Checking service: d...
+Checking service: e...
+Found dependency cycle:
+    b ->
+    d ->
+    e ->
+    b.
diff --git a/src/igr-tests/check-cycle/run-test.sh b/src/igr-tests/check-cycle/run-test.sh
new file mode 100755 (executable)
index 0000000..d75048c
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+../../dinitcheck -d sd > output.txt 2>&1
+
+STATUS=FAIL
+if cmp -s expected.txt output.txt; then
+   STATUS=PASS
+fi
+
+if [ $STATUS = PASS ]; then exit 0; fi
+exit 1
diff --git a/src/igr-tests/check-cycle/sd/a b/src/igr-tests/check-cycle/sd/a
new file mode 100644 (file)
index 0000000..86fc3e0
--- /dev/null
@@ -0,0 +1,2 @@
+type=internal
+depends-on=b
diff --git a/src/igr-tests/check-cycle/sd/b b/src/igr-tests/check-cycle/sd/b
new file mode 100644 (file)
index 0000000..62e5cc0
--- /dev/null
@@ -0,0 +1,2 @@
+type=internal
+depends-on=d
diff --git a/src/igr-tests/check-cycle/sd/boot b/src/igr-tests/check-cycle/sd/boot
new file mode 100644 (file)
index 0000000..3553717
--- /dev/null
@@ -0,0 +1,4 @@
+type=internal
+depends-on=a
+depends-on=b
+depends-on=c
diff --git a/src/igr-tests/check-cycle/sd/c b/src/igr-tests/check-cycle/sd/c
new file mode 100644 (file)
index 0000000..86fc3e0
--- /dev/null
@@ -0,0 +1,2 @@
+type=internal
+depends-on=b
diff --git a/src/igr-tests/check-cycle/sd/d b/src/igr-tests/check-cycle/sd/d
new file mode 100644 (file)
index 0000000..d72b929
--- /dev/null
@@ -0,0 +1,2 @@
+type=internal
+depends-on=e
diff --git a/src/igr-tests/check-cycle/sd/e b/src/igr-tests/check-cycle/sd/e
new file mode 100644 (file)
index 0000000..5309fb9
--- /dev/null
@@ -0,0 +1,2 @@
+type=internal
+depends-on=b  # cycle!
index 3d53e9b292bfba6513075e9f2a86ca5b48ae4e4a..62349d4a479129f063beff0d145f466e89823bc3 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",
 int main(int argc, char **argv)
 {
     const char * const test_dirs[] = { "basic", "environ", "ps-environ", "chain-to", "force-stop", "restart",
-            "check-basic" };
+            "check-basic", "check-cycle" };
     constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]);
 
     int passed = 0;
     constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]);
 
     int passed = 0;