mirror of
https://github.com/systemd/systemd.git
synced 2025-01-17 06:04:07 +03:00
core: Adjust ExecDirectory-Stdout test to use DynamicUser
For test environments that set e.g. $RUNTIME_DIRECTORY to /run/fake-runtime-dir, the test service file can't properly define the StandardOutput path, as it must be absolute. Instead, try using DynamicUser & StateDirectory, which should result in an appropriate directory always seen at /var/lib/foo
This commit is contained in:
parent
a2872389e3
commit
353f417f48
@ -1128,9 +1128,21 @@ static void test_exec_runtimedirectory(Manager *m) {
|
||||
test(m, "exec-runtimedirectory-owner-" NOBODY_GROUP_NAME ".service", MANAGER_IS_SYSTEM(m) ? 0 : EXIT_GROUP, CLD_EXITED);
|
||||
}
|
||||
|
||||
static void test_exec_runtimedirectory_stdoutput(Manager *m) {
|
||||
(void) rm_rf("/run/test-exec_runtimedirectory_standardoutput", REMOVE_ROOT|REMOVE_PHYSICAL);
|
||||
test(m, "exec-runtimedirectory-stdoutput.service", 0, CLD_EXITED);
|
||||
static void test_exec_statedirectory_stdoutput(Manager *m) {
|
||||
if (MANAGER_IS_USER(m)) {
|
||||
log_notice("Skipping %s for user manager", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
_cleanup_free_ char *bad = private_directory_bad(m);
|
||||
if (bad) {
|
||||
log_warning("%s: %s has bad permissions, skipping test.", __func__, bad);
|
||||
return;
|
||||
}
|
||||
|
||||
int status = can_unshare ? 0 : EXIT_NAMESPACE;
|
||||
|
||||
test(m, "exec-statedirectory-stdoutput.service", status, CLD_EXITED);
|
||||
}
|
||||
|
||||
static void test_exec_capabilityboundingset(Manager *m) {
|
||||
@ -1364,7 +1376,7 @@ static void run_tests(RuntimeScope scope, char **patterns) {
|
||||
entry(test_exec_readwritepaths),
|
||||
entry(test_exec_restrictnamespaces),
|
||||
entry(test_exec_runtimedirectory),
|
||||
entry(test_exec_runtimedirectory_stdoutput),
|
||||
entry(test_exec_statedirectory_stdoutput),
|
||||
entry(test_exec_specifier),
|
||||
entry(test_exec_standardinput),
|
||||
entry(test_exec_standardoutput),
|
||||
|
@ -1,9 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Unit]
|
||||
Description=Test for RuntimeDirectory used by StandardOutput
|
||||
|
||||
[Service]
|
||||
ExecStart=sh -c 'printf "hello\nhello\n"'
|
||||
Type=oneshot
|
||||
RuntimeDirectory=test-exec_runtimedirectory_standardoutput
|
||||
StandardOutput=file:/run/test-exec_runtimedirectory_standardoutput/test-exec-runtimedirectory_standardoutput-output
|
10
test/test-execute/exec-statedirectory-stdoutput.service
Normal file
10
test/test-execute/exec-statedirectory-stdoutput.service
Normal file
@ -0,0 +1,10 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Unit]
|
||||
Description=Test for StateDirectory used by StandardOutput
|
||||
|
||||
[Service]
|
||||
ExecStart=sh -c 'printf "hello\nhello\n"'
|
||||
Type=oneshot
|
||||
DynamicUser=true
|
||||
StateDirectory=test-exec_statedirectory_standardoutput
|
||||
StandardOutput=file:/var/lib/test-exec_statedirectory_standardoutput/test-exec-statedirectory_standardoutput-output
|
Loading…
x
Reference in New Issue
Block a user