Browse Source

Add integration test for dinit-check cycle checking (via before)

Add a test for detecting cycles via "before" relationships specified in
a service
Davin McCall 9 months ago
parent
commit
00a60750a3

+ 1 - 0
.gitignore

@@ -28,6 +28,7 @@
 /src/igr-tests/restart/basic-ran
 /src/igr-tests/check-basic/output.txt
 /src/igr-tests/check-cycle/output.txt
+/src/igr-tests/check-cycle2/output.txt
 /src/igr-tests/check-lint/output.txt
 /src/igr-tests/reload1/sd
 /src/igr-tests/reload2/sd

+ 10 - 0
src/igr-tests/check-cycle2/expected.txt

@@ -0,0 +1,10 @@
+Checking service: boot...
+Checking service: c...
+Checking service: b...
+Checking service: a...
+Found dependency cycle:
+    c ->
+    b ->
+    a -> (via 'before')
+    c.
+One or more errors/warnings issued.

+ 14 - 0
src/igr-tests/check-cycle2/run-test.sh

@@ -0,0 +1,14 @@
+#!/bin/sh
+
+cd "$(dirname "$0")"
+
+"$DINITCHECK_EXEC" -d sd > output.txt 2>&1
+if [ $? != 1 ]; then exit 1; fi
+
+STATUS=FAIL
+if cmp -s expected.txt output.txt; then
+   STATUS=PASS
+fi
+
+if [ $STATUS != PASS ]; then exit 1; fi
+exit 0

+ 1 - 0
src/igr-tests/check-cycle2/sd/a

@@ -0,0 +1 @@
+type=internal

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

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

+ 2 - 0
src/igr-tests/check-cycle2/sd/boot

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

+ 3 - 0
src/igr-tests/check-cycle2/sd/c

@@ -0,0 +1,3 @@
+type=internal
+depends-on=b
+before=a

+ 2 - 2
src/igr-tests/igr-runner.cc

@@ -13,8 +13,8 @@ extern char **environ;
 int main(int argc, char **argv)
 {
     const char * const test_dirs[] = { "basic", "environ", "environ2", "ps-environ", "chain-to", "force-stop",
-            "restart", "check-basic", "check-cycle", "check-lint", "reload1", "reload2", "no-command-error",
-            "add-rm-dep", "var-subst", "svc-start-fail", "dep-not-found" };
+            "restart", "check-basic", "check-cycle", "check-cycle2", "check-lint", "reload1", "reload2",
+			"no-command-error", "add-rm-dep", "var-subst", "svc-start-fail", "dep-not-found" };
     constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]);
 
     int passed = 0;