]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-execute: add test for EnvironmentFile
authorRonny Chevalier <chevalier.ronny@gmail.com>
Fri, 30 Oct 2015 15:55:44 +0000 (16:55 +0100)
committerRonny Chevalier <chevalier.ronny@gmail.com>
Sat, 31 Oct 2015 14:07:19 +0000 (15:07 +0100)
Makefile.am
src/test/test-execute.c
test/exec-environmentfile.service [new file with mode: 0644]

index cd5ea6f32c19e3a387c66bbd96f50f11d71c3905..64c0ca64f279de6086f59d14880212dcc753510e 100644 (file)
@@ -1567,6 +1567,7 @@ EXTRA_DIST += \
        test/exec-umask-0177.service \
        test/exec-umask-default.service \
        test/exec-privatenetwork-yes.service \
+       test/exec-environmentfile.service \
        test/bus-policy/hello.conf \
        test/bus-policy/methods.conf \
        test/bus-policy/ownerships.conf \
index fb0cb3fdc4149a7e85e96d7f4b786093c53edead..5898b3fb7109707331e8f7cdf41883fe6b7d9f29 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 
+#include "fileio.h"
 #include "fs-util.h"
 #include "macro.h"
 #include "manager.h"
@@ -147,6 +148,26 @@ static void test_exec_environment(Manager *m) {
         test(m, "exec-environment-empty.service", 0, CLD_EXITED);
 }
 
+static void test_exec_environmentfile(Manager *m) {
+        static const char e[] =
+                "VAR1='word1 word2'\n"
+                "VAR2=word3 \n"
+                "# comment1\n"
+                "\n"
+                "; comment2\n"
+                " ; # comment3\n"
+                "line without an equal\n"
+                "VAR3='$word 5 6'\n";
+        int r;
+
+        r = write_string_file("/tmp/test-exec_environmentfile.conf", e, WRITE_STRING_FILE_CREATE);
+        assert_se(r == 0);
+
+        test(m, "exec-environmentfile.service", 0, CLD_EXITED);
+
+        unlink("/tmp/test-exec_environmentfile.conf");
+}
+
 static void test_exec_umask(Manager *m) {
         test(m, "exec-umask-default.service", 0, CLD_EXITED);
         test(m, "exec-umask-0177.service", 0, CLD_EXITED);
@@ -203,6 +224,7 @@ int main(int argc, char *argv[]) {
                 test_exec_user,
                 test_exec_group,
                 test_exec_environment,
+                test_exec_environmentfile,
                 test_exec_umask,
                 test_exec_runtimedirectory,
                 test_exec_capabilityboundingset,
diff --git a/test/exec-environmentfile.service b/test/exec-environmentfile.service
new file mode 100644 (file)
index 0000000..848f2a1
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for EnvironmentFile
+
+[Service]
+ExecStart=/bin/sh -c 'exit $(test "$VAR1" = "word1 word2") && $(test "$VAR2" = word3) && $(test "$VAR3" = \'$word 5 6\')'
+Type=oneshot
+EnvironmentFile=/tmp/test-exec_environmentfile.conf