Add integration test for per-process environment.
authorDavin McCall <davmac@davmac.org>
Sat, 6 Jul 2019 02:53:45 +0000 (03:53 +0100)
committerDavin McCall <davmac@davmac.org>
Sat, 6 Jul 2019 04:06:17 +0000 (14:06 +1000)
src/igr-tests/Makefile
src/igr-tests/igr-runner.cc
src/igr-tests/ps-environ/checkenv.sh [new file with mode: 0755]
src/igr-tests/ps-environ/environment1 [new file with mode: 0644]
src/igr-tests/ps-environ/environment2 [new file with mode: 0644]
src/igr-tests/ps-environ/run-test.sh [new file with mode: 0755]
src/igr-tests/ps-environ/sd/checkenv1 [new file with mode: 0644]
src/igr-tests/ps-environ/sd/checkenv2 [new file with mode: 0644]

index 87719e5a5e571a7fe521e378d560c6c1314ff037..9d6d7a280ad6a7f10744a037f10911200b86b6fc 100644 (file)
@@ -7,4 +7,5 @@ igr-runner: igr-runner.cc
        $(CXX) $(CXXOPTS) igr-runner.cc -o igr-runner
 
 clean:
-       rm -f igr-runner basic/basic-ran environ/env-record
+       rm -f igr-runner basic/basic-ran environ/env-record ps-environ/env-record
+
index d822b41a627e4082ba9e74d2184fe13d76894acd..79a82cfda1735e6f920988bb7fbe2b9327b3bad8 100644 (file)
@@ -12,7 +12,7 @@ extern char **environ;
 
 int main(int argc, char **argv)
 {
-    const char * const test_dirs[] = { "basic", "environ" };
+    const char * const test_dirs[] = { "basic", "environ", "ps-environ" };
     constexpr int num_tests = sizeof(test_dirs) / sizeof(test_dirs[0]);
 
     int passed = 0;
diff --git a/src/igr-tests/ps-environ/checkenv.sh b/src/igr-tests/ps-environ/checkenv.sh
new file mode 100755 (executable)
index 0000000..e73d787
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo "$TEST_VAR_ONE" >> ./env-record
diff --git a/src/igr-tests/ps-environ/environment1 b/src/igr-tests/ps-environ/environment1
new file mode 100644 (file)
index 0000000..a4b22c2
--- /dev/null
@@ -0,0 +1 @@
+TEST_VAR_ONE=hello
diff --git a/src/igr-tests/ps-environ/environment2 b/src/igr-tests/ps-environ/environment2
new file mode 100644 (file)
index 0000000..8f4b8e3
--- /dev/null
@@ -0,0 +1 @@
+TEST_VAR_ONE=goodbye
diff --git a/src/igr-tests/ps-environ/run-test.sh b/src/igr-tests/ps-environ/run-test.sh
new file mode 100755 (executable)
index 0000000..792f743
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+rm -f ./env-record
+
+../../dinit -d sd -u -p socket -q \
+       checkenv1
+
+../../dinit -d sd -u -p socket -q \
+       checkenv2
+
+STATUS=FAIL
+if [ -e env-record ]; then
+   if [ "$(cat env-record)" = "$(echo hello; echo goodbye)" ]; then
+       STATUS=PASS
+   fi
+fi
+
+if [ $STATUS = PASS ]; then exit 0; fi
+exit 1
diff --git a/src/igr-tests/ps-environ/sd/checkenv1 b/src/igr-tests/ps-environ/sd/checkenv1
new file mode 100644 (file)
index 0000000..f10108d
--- /dev/null
@@ -0,0 +1,3 @@
+type = process
+command = ./checkenv.sh
+env-file = ./environment1
diff --git a/src/igr-tests/ps-environ/sd/checkenv2 b/src/igr-tests/ps-environ/sd/checkenv2
new file mode 100644 (file)
index 0000000..661576d
--- /dev/null
@@ -0,0 +1,3 @@
+type = process
+command = ./checkenv.sh
+env-file = ./environment2