richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
1abbee
From fb798a267d2bad8df98f49c2a4a309efa5569759 Mon Sep 17 00:00:00 2001
1abbee
From: Ronny Chevalier <chevalier.ronny@gmail.com>
1abbee
Date: Mon, 21 Sep 2015 15:36:07 +0200
1abbee
Subject: [PATCH] test-execute: add tests for RuntimeDirectory
1abbee
1abbee
Cherry-picked from: cc3ddc851fbe5adf9dfc7e4a702a8b5b6a1186d6
1abbee
Resolves: #1324826
1abbee
---
1abbee
 src/test/test-execute.c                 | 7 +++++++
1abbee
 test/exec-runtimedirectory-mode.service | 8 ++++++++
1abbee
 test/exec-runtimedirectory.service      | 7 +++++++
1abbee
 3 files changed, 22 insertions(+)
1abbee
 create mode 100644 test/exec-runtimedirectory-mode.service
1abbee
 create mode 100644 test/exec-runtimedirectory.service
1abbee
1abbee
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
Pablo Greco 48fc63
index 00f3607b49..90b1c871cc 100644
1abbee
--- a/src/test/test-execute.c
1abbee
+++ b/src/test/test-execute.c
1abbee
@@ -141,6 +141,11 @@ static void test_exec_umask(Manager *m) {
1abbee
         test(m, "exec-umask-0177.service", 0, CLD_EXITED);
1abbee
 }
1abbee
 
1abbee
+static void test_exec_runtimedirectory(Manager *m) {
1abbee
+        test(m, "exec-runtimedirectory.service", 0, CLD_EXITED);
1abbee
+        test(m, "exec-runtimedirectory-mode.service", 0, CLD_EXITED);
1abbee
+}
1abbee
+
1abbee
 int main(int argc, char *argv[]) {
1abbee
         test_function_t tests[] = {
1abbee
                 test_exec_workingdirectory,
1abbee
@@ -154,6 +159,7 @@ int main(int argc, char *argv[]) {
1abbee
                 test_exec_group,
1abbee
                 test_exec_environment,
1abbee
                 test_exec_umask,
1abbee
+                test_exec_runtimedirectory,
1abbee
                 NULL,
1abbee
         };
1abbee
         test_function_t *test = NULL;
1abbee
@@ -169,6 +175,7 @@ int main(int argc, char *argv[]) {
1abbee
                 return EXIT_TEST_SKIP;
1abbee
         }
1abbee
 
1abbee
+        assert_se(setenv("XDG_RUNTIME_DIR", "/tmp/", 1) == 0);
1abbee
         assert_se(set_unit_path(TEST_DIR ":") >= 0);
1abbee
 
1abbee
         r = manager_new(SYSTEMD_USER, true, &m);
1abbee
diff --git a/test/exec-runtimedirectory-mode.service b/test/exec-runtimedirectory-mode.service
1abbee
new file mode 100644
Pablo Greco 48fc63
index 0000000000..ba6d7ee39f
1abbee
--- /dev/null
1abbee
+++ b/test/exec-runtimedirectory-mode.service
1abbee
@@ -0,0 +1,8 @@
1abbee
+[Unit]
1abbee
+Description=Test for RuntimeDirectoryMode
1abbee
+
1abbee
+[Service]
1abbee
+ExecStart=/bin/sh -c 's=$(stat -c %a /tmp/test-exec_runtimedirectory-mode); echo $s; exit $(test $s = "750")'
1abbee
+Type=oneshot
1abbee
+RuntimeDirectory=test-exec_runtimedirectory-mode
1abbee
+RuntimeDirectoryMode=0750
1abbee
diff --git a/test/exec-runtimedirectory.service b/test/exec-runtimedirectory.service
1abbee
new file mode 100644
Pablo Greco 48fc63
index 0000000000..c12a6c63d6
1abbee
--- /dev/null
1abbee
+++ b/test/exec-runtimedirectory.service
1abbee
@@ -0,0 +1,7 @@
1abbee
+[Unit]
1abbee
+Description=Test for RuntimeDirectory
1abbee
+
1abbee
+[Service]
1abbee
+ExecStart=/bin/sh -c 'exit $(test -d /tmp/test-exec_runtimedirectory)'
1abbee
+Type=oneshot
1abbee
+RuntimeDirectory=test-exec_runtimedirectory