daandemeyer / rpms / systemd

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