Add integration test for "chain-to" service parameter
authorDavin McCall <davmac@davmac.org>
Thu, 11 Jul 2019 12:38:19 +0000 (22:38 +1000)
committerDavin McCall <davmac@davmac.org>
Thu, 11 Jul 2019 12:38:19 +0000 (22:38 +1000)
.gitignore
src/igr-tests/Makefile
src/igr-tests/chain-to/record-param.sh [new file with mode: 0755]
src/igr-tests/chain-to/run-test.sh [new file with mode: 0755]
src/igr-tests/chain-to/sd/part1 [new file with mode: 0644]
src/igr-tests/chain-to/sd/part2 [new file with mode: 0644]
src/igr-tests/chain-to/sd/part3 [new file with mode: 0644]
src/igr-tests/igr-runner.cc

index 125406b006b53a42815a8cf304e631dc4ff0f664..264f0e5d5a5b9883cb7f37a1bee0941e6ec4355f 100644 (file)
 /src/tests/cptests/cptests
 /src/tests/cptests/corpus
 /src/tests/cptests/fuzz
-/src/igr-tests/basic/basic-ran
-/src/igr-tests/environ/env-record
 /src/igr-tests/igr-runner
 /mconfig
+
+# Integration test output:
+/src/igr-tests/basic/basic-ran
+/src/igr-tests/environ/env-record
+/src/igr-tests/ps-environ/env-record
+/src/igr-tests/chain-to/recorded-output
index 9d6d7a280ad6a7f10744a037f10911200b86b6fc..d033d917e65683f3bc80f5de35abb72e0a199333 100644 (file)
@@ -7,5 +7,4 @@ igr-runner: igr-runner.cc
        $(CXX) $(CXXOPTS) igr-runner.cc -o igr-runner
 
 clean:
-       rm -f igr-runner basic/basic-ran environ/env-record ps-environ/env-record
-
+       rm -f igr-runner basic/basic-ran environ/env-record ps-environ/env-record chain-to/recorded-output
diff --git a/src/igr-tests/chain-to/record-param.sh b/src/igr-tests/chain-to/record-param.sh
new file mode 100755 (executable)
index 0000000..7d789c3
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+# append parameter to file
+
+echo "$1" >> ./recorded-output
diff --git a/src/igr-tests/chain-to/run-test.sh b/src/igr-tests/chain-to/run-test.sh
new file mode 100755 (executable)
index 0000000..157a9f5
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+rm -f ./recorded-output
+
+../../dinit -d sd -u -p socket -q \
+       part1
+
+STATUS=FAIL
+if [ -e recorded-output ]; then
+   if [ "$(cat recorded-output)" = "$(echo part1; echo part2; echo part3)" ]; then
+       STATUS=PASS
+   fi
+fi
+
+if [ $STATUS = PASS ]; then exit 0; fi
+exit 1
diff --git a/src/igr-tests/chain-to/sd/part1 b/src/igr-tests/chain-to/sd/part1
new file mode 100644 (file)
index 0000000..a651e2b
--- /dev/null
@@ -0,0 +1,3 @@
+type = process
+command = ./record-param.sh part1
+chain-to = part2
diff --git a/src/igr-tests/chain-to/sd/part2 b/src/igr-tests/chain-to/sd/part2
new file mode 100644 (file)
index 0000000..c6000e9
--- /dev/null
@@ -0,0 +1,3 @@
+type = process
+command = ./record-param.sh part2
+chain-to = part3
diff --git a/src/igr-tests/chain-to/sd/part3 b/src/igr-tests/chain-to/sd/part3
new file mode 100644 (file)
index 0000000..119917d
--- /dev/null
@@ -0,0 +1,2 @@
+type = process
+command = ./record-param.sh part3
index 79a82cfda1735e6f920988bb7fbe2b9327b3bad8..e8a906be138c9ab2a620a53d038482f88d460377 100644 (file)
@@ -12,7 +12,7 @@ extern char **environ;
 
 int main(int argc, char **argv)
 {
-    const char * const test_dirs[] = { "basic", "environ", "ps-environ" };
+    const char * const test_dirs[] = { "basic", "environ", "ps-environ", "chain-to" };
     constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]);
 
     int passed = 0;