1
0
mirror of https://github.com/systemd/systemd synced 2025-10-05 19:54:46 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Mike Yuan
879ed340a1 core/service: drop job done messages identical to generic ones
Prompted by #38263
2025-07-20 00:56:21 +09:00
Yu Watanabe
0021f7fdf4 test: add test case for getenv_for_pid() 2025-07-19 13:35:27 +01:00
2 changed files with 34 additions and 7 deletions

View File

@ -5810,13 +5810,6 @@ const UnitVTable service_vtable = {
.status_text = service_status_text,
.status_message_formats = {
.finished_start_job = {
[JOB_FAILED] = "Failed to start %s.",
},
.finished_stop_job = {
[JOB_DONE] = "Stopped %s.",
[JOB_FAILED] = "Stopped (with error) %s.",
},
.finished_job = service_finished_job,
},

View File

@ -1096,6 +1096,40 @@ TEST(pidfd_get_inode_id_self_cached) {
}
}
TEST(getenv_for_pid) {
_cleanup_strv_free_ char **copy_env = NULL;
pid_t pid = getpid_cached();
int r;
ASSERT_NOT_NULL(copy_env = strv_copy(environ));
ASSERT_OK(r = pidref_safe_fork("(getenv_for_pid)", FORK_WAIT, NULL));
if (r == 0) {
STRV_FOREACH(e, copy_env) {
const char *v = strchr(*e, '=');
if (!v)
continue;
_cleanup_free_ char *k = NULL;
ASSERT_NOT_NULL(k = strndup(*e, v - *e));
v++;
_cleanup_free_ char *value = NULL;
ASSERT_OK_POSITIVE(getenv_for_pid(pid, k, &value));
ASSERT_STREQ(value, v);
}
if (!strv_find_startswith(copy_env, "HOGEHOGE")) {
char *value = POINTER_MAX;
ASSERT_OK_ZERO(getenv_for_pid(pid, "HOGEHOGE", &value));
ASSERT_NULL(value);
}
_exit(EXIT_SUCCESS);
}
}
static int intro(void) {
log_show_color(true);
return EXIT_SUCCESS;