From: Davin McCall Date: Sat, 6 Jul 2019 02:53:45 +0000 (+0100) Subject: Add integration test for per-process environment. X-Git-Tag: v0.6.0~7 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a5c76c391208603b95c21733a74b34ce3a9dd411;p=oweals%2Fdinit.git Add integration test for per-process environment. --- diff --git a/src/igr-tests/Makefile b/src/igr-tests/Makefile index 87719e5..9d6d7a2 100644 --- a/src/igr-tests/Makefile +++ b/src/igr-tests/Makefile @@ -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 + diff --git a/src/igr-tests/igr-runner.cc b/src/igr-tests/igr-runner.cc index d822b41..79a82cf 100644 --- a/src/igr-tests/igr-runner.cc +++ b/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" }; + 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 index 0000000..e73d787 --- /dev/null +++ b/src/igr-tests/ps-environ/checkenv.sh @@ -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 index 0000000..a4b22c2 --- /dev/null +++ b/src/igr-tests/ps-environ/environment1 @@ -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 index 0000000..8f4b8e3 --- /dev/null +++ b/src/igr-tests/ps-environ/environment2 @@ -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 index 0000000..792f743 --- /dev/null +++ b/src/igr-tests/ps-environ/run-test.sh @@ -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 index 0000000..f10108d --- /dev/null +++ b/src/igr-tests/ps-environ/sd/checkenv1 @@ -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 index 0000000..661576d --- /dev/null +++ b/src/igr-tests/ps-environ/sd/checkenv2 @@ -0,0 +1,3 @@ +type = process +command = ./checkenv.sh +env-file = ./environment2