From: Luca Boccassi Date: Tue, 23 Jun 2026 09:39:01 +0000 (+0100) Subject: test-execute: use per-Exec timeout instead of per-service timeout X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1dcd2966a0898c7d48a7390e2db5c84b8823f79b;p=thirdparty%2Fsystemd.git test-execute: use per-Exec timeout instead of per-service timeout The previous x2 was still not enough, and the test is still killed often in slow GHA CI workers, eg: https://github.com/systemd/systemd/actions/runs/28012425459/job/82908555094?pr=42705 This happens in test units with many commands, so reset the timer when a command completes and the test advances. The number of Exec instructions is bounded so this will terminate jobs that are really stuck anyway. Follow-up for 3b00327fe6004b03c4a963de3df51998cf0c79b4 --- diff --git a/src/test/test-execute.c b/src/test/test-execute.c index 171bd495b54..1a832ad2f71 100644 --- a/src/test/test-execute.c +++ b/src/test/test-execute.c @@ -86,12 +86,21 @@ static void wait_for_service_finish(Manager *m, Unit *unit) { printf("%s\n", unit->id); exec_context_dump(&service->exec_context, stdout, "\t"); + /* Use a per-Exec timeout rather than a service timeout, as especially under sanitizers some test + * units running many commands can hit the service timeout. */ _cleanup_(sd_event_source_unrefp) sd_event_source *s = NULL; ASSERT_OK(sd_event_add_time_relative(m->event, &s, CLOCK_MONOTONIC, timeout, 0, time_handler, unit)); /* Here, sd_event_loop() cannot be used, as the sd_event object will be reused in the next test case. */ - while (!IN_SET(service->state, SERVICE_DEAD, SERVICE_FAILED)) + ExecCommand *last_command = service->main_command; + while (!IN_SET(service->state, SERVICE_DEAD, SERVICE_FAILED)) { ASSERT_OK(sd_event_run(m->event, 100 * USEC_PER_MSEC)); + + if (service->main_command != last_command) { + last_command = service->main_command; + ASSERT_OK(sd_event_source_set_time_relative(s, timeout)); + } + } } static void check_main_result(const char *file, unsigned line, const char *func,