Arm a SIGEV_NONE timer for 100 seconds, disarm it and check that timer_gettime() reports a zero it_value.
Run the test for CLOCK_MONOTONIC, where it fails without the previous patch, and for CLOCK_PROCESS_CPUTIME_ID, where it passes with and without it. Assisted-by: LLM Signed-off-by: Shashank Mohan Jain <[email protected]> --- Prepared with Claude Code (Anthropic), model Claude Opus 5.5 (claude-opus-5-5). tools/testing/selftests/timers/posix_timers.c | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c index a92d4b9577..b6e56c08ba 100644 --- a/tools/testing/selftests/timers/posix_timers.c +++ b/tools/testing/selftests/timers/posix_timers.c @@ -495,6 +495,40 @@ static void check_sigev_none(int which) "check_sigev_none %s\n", name); } +static void check_sigev_none_disarm(int which) +{ + const char *name = clock_name(which); + struct itimerspec its; + struct sigevent sev; + timer_t timerid; + + memset(&sev, 0, sizeof(sev)); + sev.sigev_notify = SIGEV_NONE; + + if (timer_create(which, &sev, &timerid)) + fatal_error(name, "timer_create()"); + + /* Arm the timer to expire in 100 seconds and disarm it again */ + memset(&its, 0, sizeof(its)); + its.it_value.tv_sec = 100; + if (timer_settime(timerid, 0, &its, NULL)) + fatal_error(name, "timer_settime()"); + + memset(&its, 0, sizeof(its)); + if (timer_settime(timerid, 0, &its, NULL)) + fatal_error(name, "timer_settime()"); + + /* A disarmed timer must report a zero it_value */ + if (timer_gettime(timerid, &its)) + fatal_error(name, "timer_gettime()"); + + if (timer_delete(timerid)) + fatal_error(name, "timer_delete()"); + + ksft_test_result(!its.it_value.tv_sec && !its.it_value.tv_nsec, + "check_sigev_none_disarm %s\n", name); +} + static void check_gettime(int which) { const char *name = clock_name(which); @@ -680,7 +714,7 @@ int main(int argc, char **argv) ksft_print_header(); if (run_sig_ign_tests) { - ksft_set_plan(19); + ksft_set_plan(21); } else { ksft_set_plan(10); } @@ -714,6 +748,8 @@ int main(int argc, char **argv) check_delete(); check_sigev_none(CLOCK_MONOTONIC); check_sigev_none(CLOCK_PROCESS_CPUTIME_ID); + check_sigev_none_disarm(CLOCK_MONOTONIC); + check_sigev_none_disarm(CLOCK_PROCESS_CPUTIME_ID); check_gettime(CLOCK_MONOTONIC); check_gettime(CLOCK_PROCESS_CPUTIME_ID); check_gettime(CLOCK_THREAD_CPUTIME_ID); -- 2.43.0

