Browse Source

Integration test for dinitcheck dependency cycles detection

Davin McCall 4 years ago
parent
commit
6aef38b055

+ 1 - 0
.gitignore

@@ -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/check-cycle/output.txt
 
 # Generated man pages:
 /doc/manpages/*.5

+ 1 - 1
src/igr-tests/Makefile

@@ -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
-	rm -f check-basic/output.txt
+	rm -f check-basic/output.txt check-cycle/output.txt

+ 11 - 0
src/igr-tests/check-cycle/expected.txt

@@ -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.

+ 11 - 0
src/igr-tests/check-cycle/run-test.sh

@@ -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

+ 2 - 0
src/igr-tests/check-cycle/sd/a

@@ -0,0 +1,2 @@
+type=internal
+depends-on=b

+ 2 - 0
src/igr-tests/check-cycle/sd/b

@@ -0,0 +1,2 @@
+type=internal
+depends-on=d

+ 4 - 0
src/igr-tests/check-cycle/sd/boot

@@ -0,0 +1,4 @@
+type=internal
+depends-on=a
+depends-on=b
+depends-on=c

+ 2 - 0
src/igr-tests/check-cycle/sd/c

@@ -0,0 +1,2 @@
+type=internal
+depends-on=b

+ 2 - 0
src/igr-tests/check-cycle/sd/d

@@ -0,0 +1,2 @@
+type=internal
+depends-on=e

+ 2 - 0
src/igr-tests/check-cycle/sd/e

@@ -0,0 +1,2 @@
+type=internal
+depends-on=b  # cycle!

+ 1 - 1
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-basic", "check-cycle" };
     constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]);
 
     int passed = 0;