Browse Source

Add integration test for "chain-to" service parameter

Davin McCall 4 years ago
parent
commit
ec6c94e228

+ 6 - 2
.gitignore

@@ -14,7 +14,11 @@
 /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

+ 1 - 2
src/igr-tests/Makefile

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

+ 4 - 0
src/igr-tests/chain-to/record-param.sh

@@ -0,0 +1,4 @@
+#!/bin/sh
+# append parameter to file
+
+echo "$1" >> ./recorded-output

+ 16 - 0
src/igr-tests/chain-to/run-test.sh

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

+ 3 - 0
src/igr-tests/chain-to/sd/part1

@@ -0,0 +1,3 @@
+type = process
+command = ./record-param.sh part1
+chain-to = part2

+ 3 - 0
src/igr-tests/chain-to/sd/part2

@@ -0,0 +1,3 @@
+type = process
+command = ./record-param.sh part2
+chain-to = part3

+ 2 - 0
src/igr-tests/chain-to/sd/part3

@@ -0,0 +1,2 @@
+type = process
+command = ./record-param.sh part3

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

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