!strextend_with_separator(&joined, ":", strempty(old)))
return -ENOMEM;
- assert_se(set_unit_path(joined) >= 0);
+ assert_se(setenv_unit_path(joined) >= 0);
return 0;
}
return unit_add_two_dependencies(u, d, e, other, add_reference, mask);
}
-int set_unit_path(const char *p) {
+int setenv_unit_path(const char *p) {
+ assert(p);
+
/* This is mostly for debug purposes */
- return RET_NERRNO(setenv("SYSTEMD_UNIT_PATH", p, 1));
+ return RET_NERRNO(setenv("SYSTEMD_UNIT_PATH", p, /* overwrite = */ true));
}
char* unit_dbus_path(Unit *u) {
bool unit_job_is_applicable(Unit *u, JobType j);
-int set_unit_path(const char *p);
+int setenv_unit_path(const char *p);
char* unit_dbus_path(Unit *u);
char* unit_dbus_path_invocation_id(Unit *u);
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = bpf_program_new(BPF_PROG_TYPE_CGROUP_SKB, "sd_trivial", &p);
return log_tests_skipped("cgroupfs not available");
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
ASSERT_OK(manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m));
return log_tests_skipped("cgroupfs not available");
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
ASSERT_OK(manager_new(RUNTIME_SCOPE_SYSTEM, MANAGER_TEST_RUN_BASIC, &m));
/* Prepare the manager. */
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);
if (IN_SET(r, -EPERM, -EACCES)) {
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);
if (IN_SET(r, -EPERM, -EACCES)) {
/* prepare the test */
_cleanup_free_ char *unit_dir = NULL;
- assert_se(get_testdata_dir("units", &unit_dir) >= 0);
- assert_se(set_unit_path(unit_dir) >= 0);
+ ASSERT_OK(get_testdata_dir("units", &unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);
ASSERT_NOT_NULL(runtime_dir = setup_fake_runtime_dir());
ASSERT_NOT_NULL(user_runtime_unit_dir = path_join(runtime_dir, "systemd/user"));
ASSERT_NOT_NULL(unit_paths = strjoin(PRIVATE_UNIT_DIR, ":", user_runtime_unit_dir));
- ASSERT_OK(set_unit_path(unit_paths));
+ ASSERT_OK(setenv_unit_path(unit_paths));
r = manager_new(scope, MANAGER_TEST_RUN_BASIC, &m);
if (manager_errno_skip_test(r))
test_setup_logging(LOG_INFO);
- assert_se(get_testdata_dir("test-path", &test_path) >= 0);
- assert_se(set_unit_path(test_path) >= 0);
+ ASSERT_OK(get_testdata_dir("test-path", &test_path));
+ ASSERT_OK(setenv_unit_path(test_path));
assert_se(runtime_dir = setup_fake_runtime_dir());
for (const test_function_t *test = tests; *test; test++) {
/* prepare the test */
_cleanup_free_ char *unit_dir = NULL;
- assert_se(get_testdata_dir("units", &unit_dir) >= 0);
- assert_se(set_unit_path(unit_dir) >= 0);
+ ASSERT_OK(get_testdata_dir("units", &unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
- assert_se(get_testdata_dir("units", &unit_dir) >= 0);
- assert_se(set_unit_path(unit_dir) >= 0);
+ ASSERT_OK(get_testdata_dir("units", &unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
assert_se(manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m) >= 0);
return log_tests_skipped("cgroupfs not available");
_cleanup_free_ char *unit_dir = NULL;
- assert_se(get_testdata_dir("units/", &unit_dir) >= 0);
- assert_se(set_unit_path(unit_dir) >= 0);
+ ASSERT_OK(get_testdata_dir("units/", &unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());