valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0302-test-execute-add-tests-for-RuntimeDirectory.patch

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