From 6aef38b055ba43b56a4d626b7e36d39424955005 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Fri, 22 Nov 2019 13:29:57 +0000 Subject: [PATCH] Integration test for dinitcheck dependency cycles detection --- .gitignore | 1 + src/igr-tests/Makefile | 2 +- src/igr-tests/check-cycle/expected.txt | 11 +++++++++++ src/igr-tests/check-cycle/run-test.sh | 11 +++++++++++ src/igr-tests/check-cycle/sd/a | 2 ++ src/igr-tests/check-cycle/sd/b | 2 ++ src/igr-tests/check-cycle/sd/boot | 4 ++++ src/igr-tests/check-cycle/sd/c | 2 ++ src/igr-tests/check-cycle/sd/d | 2 ++ src/igr-tests/check-cycle/sd/e | 2 ++ src/igr-tests/igr-runner.cc | 2 +- 11 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/igr-tests/check-cycle/expected.txt create mode 100755 src/igr-tests/check-cycle/run-test.sh create mode 100644 src/igr-tests/check-cycle/sd/a create mode 100644 src/igr-tests/check-cycle/sd/b create mode 100644 src/igr-tests/check-cycle/sd/boot create mode 100644 src/igr-tests/check-cycle/sd/c create mode 100644 src/igr-tests/check-cycle/sd/d create mode 100644 src/igr-tests/check-cycle/sd/e diff --git a/.gitignore b/.gitignore index 24a87a4..8910c47 100644 --- a/.gitignore +++ b/.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 diff --git a/src/igr-tests/Makefile b/src/igr-tests/Makefile index b148fb1..be07234 100644 --- a/src/igr-tests/Makefile +++ b/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 diff --git a/src/igr-tests/check-cycle/expected.txt b/src/igr-tests/check-cycle/expected.txt new file mode 100644 index 0000000..89dadf8 --- /dev/null +++ b/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. diff --git a/src/igr-tests/check-cycle/run-test.sh b/src/igr-tests/check-cycle/run-test.sh new file mode 100755 index 0000000..d75048c --- /dev/null +++ b/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 diff --git a/src/igr-tests/check-cycle/sd/a b/src/igr-tests/check-cycle/sd/a new file mode 100644 index 0000000..86fc3e0 --- /dev/null +++ b/src/igr-tests/check-cycle/sd/a @@ -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 index 0000000..62e5cc0 --- /dev/null +++ b/src/igr-tests/check-cycle/sd/b @@ -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 index 0000000..3553717 --- /dev/null +++ b/src/igr-tests/check-cycle/sd/boot @@ -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 index 0000000..86fc3e0 --- /dev/null +++ b/src/igr-tests/check-cycle/sd/c @@ -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 index 0000000..d72b929 --- /dev/null +++ b/src/igr-tests/check-cycle/sd/d @@ -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 index 0000000..5309fb9 --- /dev/null +++ b/src/igr-tests/check-cycle/sd/e @@ -0,0 +1,2 @@ +type=internal +depends-on=b # cycle! diff --git a/src/igr-tests/igr-runner.cc b/src/igr-tests/igr-runner.cc index 3d53e9b..62349d4 100644 --- a/src/igr-tests/igr-runner.cc +++ b/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; -- 2.25.1