]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: use setup_fake_runtime_dir() in test-execute
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 22 Feb 2018 12:34:54 +0000 (21:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 26 Feb 2018 03:50:03 +0000 (12:50 +0900)
src/test/test-execute.c
test/test-execute/exec-runtimedirectory-mode.service
test/test-execute/exec-runtimedirectory-owner-nfsnobody.service
test/test-execute/exec-runtimedirectory-owner.service
test/test-execute/exec-runtimedirectory.service

index f2223e1d3abf3f2bdcd6ab4515c785ad024f07ef..7bdb80e89a8d782e945301f2028fe5f2fbc3b751 100644 (file)
@@ -551,6 +551,7 @@ static int run_tests(UnitFileScope scope, const test_function_t *tests) {
 }
 
 int main(int argc, char *argv[]) {
+        _cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL;
         static const test_function_t user_tests[] = {
                 test_exec_bindpaths,
                 test_exec_capabilityambientset,
@@ -611,7 +612,7 @@ int main(int argc, char *argv[]) {
                 return EXIT_TEST_SKIP;
         }
 
-        assert_se(setenv("XDG_RUNTIME_DIR", "/tmp/", 1) == 0);
+        assert_se(runtime_dir = setup_fake_runtime_dir());
         assert_se(set_unit_path(get_testdata_dir("/test-execute")) >= 0);
 
         /* Unset VAR1, VAR2 and VAR3 which are used in the PassEnvironment test
index 842721d5c2e0a051b8acee70e151f77792ed27f3..480f904155c98f2681e254af6db2f1c4211f77b4 100644 (file)
@@ -2,7 +2,7 @@
 Description=Test for RuntimeDirectoryMode
 
 [Service]
-ExecStart=/bin/sh -x -c 'mode=$$(stat -c %%a /tmp/test-exec_runtimedirectory-mode); test "$$mode" = "750"'
+ExecStart=/bin/sh -x -c 'mode=$$(stat -c %%a %t/test-exec_runtimedirectory-mode); test "$$mode" = "750"'
 Type=oneshot
 RuntimeDirectory=test-exec_runtimedirectory-mode
 RuntimeDirectoryMode=0750
index e962af8a4bd209bb0002461346adab8ed94f9c79..1e3b6b4151739f9c2163e17d8c8142ee0b941528 100644 (file)
@@ -2,7 +2,7 @@
 Description=Test for RuntimeDirectory owner (must not be the default group of the user if Group is set)
 
 [Service]
-ExecStart=/bin/sh -x -c 'group=$$(stat -c %%G /tmp/test-exec_runtimedirectory-owner); test "$$group" = "nfsnobody"'
+ExecStart=/bin/sh -x -c 'group=$$(stat -c %%G %t/test-exec_runtimedirectory-owner); test "$$group" = "nfsnobody"'
 Type=oneshot
 Group=nfsnobody
 User=root
index 1f438c182e83cc28ecd9412df9c6b2d719a58067..54782f9bbddb2e7c93eb179f01e1ba0dcfe27084 100644 (file)
@@ -2,7 +2,7 @@
 Description=Test for RuntimeDirectory owner (must not be the default group of the user if Group is set)
 
 [Service]
-ExecStart=/bin/sh -x -c 'group=$$(stat -c %%G /tmp/test-exec_runtimedirectory-owner); test "$$group" = "nobody"'
+ExecStart=/bin/sh -x -c 'group=$$(stat -c %%G %t/test-exec_runtimedirectory-owner); test "$$group" = "nobody"'
 Type=oneshot
 Group=nobody
 User=root
index ec46c9d49b2bbf22d40aa51f300e492142270117..d8f242fde2a04824cc6fa0b8aeb8e84ae475ebec 100644 (file)
@@ -2,6 +2,6 @@
 Description=Test for RuntimeDirectory
 
 [Service]
-ExecStart=/bin/sh -x -c 'test -d /tmp/test-exec_runtimedirectory'
+ExecStart=/bin/sh -x -c 'test -d %t/test-exec_runtimedirectory'
 Type=oneshot
 RuntimeDirectory=test-exec_runtimedirectory