]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add test case for UnsetEnvironment=
authorLennart Poettering <lennart@poettering.net>
Mon, 11 Sep 2017 17:10:06 +0000 (19:10 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 14 Sep 2017 13:17:40 +0000 (15:17 +0200)
src/test/test-execute.c
test/meson.build
test/test-execute/exec-unset-environment.service [new file with mode: 0644]

index ac2cdd50ed9ca49c0ee67c670a661b1c68324b01..9d1dcfc58ecedf0f733e313a82700ccb849cbced 100644 (file)
@@ -453,6 +453,10 @@ static void test_exec_read_only_path_suceed(Manager *m) {
         test(m, "exec-read-only-path-succeed.service", 0, CLD_EXITED);
 }
 
+static void test_exec_unset_environment(Manager *m) {
+        test(m, "exec-unset-environment.service", 0, CLD_EXITED);
+}
+
 static int run_tests(UnitFileScope scope, const test_function_t *tests) {
         const test_function_t *test = NULL;
         Manager *m = NULL;
@@ -508,6 +512,7 @@ int main(int argc, char *argv[]) {
                 test_exec_ioschedulingclass,
                 test_exec_spec_interpolation,
                 test_exec_read_only_path_suceed,
+                test_exec_unset_environment,
                 NULL,
         };
         static const test_function_t system_tests[] = {
index c16ca92702491a7d008a792537de94a14028d8ca..bddeeb62b44ba929b13ca12b57c76d75dde2a384 100644 (file)
@@ -94,6 +94,7 @@ test_data_files = '''
         test-execute/exec-systemcallfilter-not-failing.service
         test-execute/exec-systemcallfilter-system-user.service
         test-execute/exec-systemcallfilter-system-user-nfsnobody.service
+        test-execute/exec-unset-environment.service
         test-execute/exec-user.service
         test-execute/exec-user-nfsnobody.service
         test-execute/exec-workingdirectory.service
diff --git a/test/test-execute/exec-unset-environment.service b/test/test-execute/exec-unset-environment.service
new file mode 100644 (file)
index 0000000..5b0123b
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=Test for UnsetEnvironment
+
+[Service]
+ExecStart=/bin/sh -x -c 'test "$$FOO" = "bar" && test "$${QUUX-X}" = "X" && test "$$VAR3" = "value3" && test "$${VAR4-X}" = "X" && test "$$VAR5" = "value5" && test "$${X%b-X}" = "X"'
+Type=oneshot
+Environment=FOO=bar QUUX=waldo VAR3=value3 VAR4=value4 VAR5=value5 X%b=%U
+UnsetEnvironment=QUUX=waldo VAR3=somethingelse VAR4 X%b=%U