From cbec9a342bca6ec83d240127a3b608a96260f2f6 Mon Sep 17 00:00:00 2001 From: Noemie Gillet Date: Mon, 4 Nov 2024 17:47:15 +0100 Subject: [PATCH] test: posix: add test_one_shot__SIGEV_SIGNAL testcase increase test coverage for newly added code Signed-off-by: Noemie Gillet --- tests/posix/common/src/timer.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/posix/common/src/timer.c b/tests/posix/common/src/timer.c index e4903839f8d..5f1e788b67f 100644 --- a/tests/posix/common/src/timer.c +++ b/tests/posix/common/src/timer.c @@ -122,6 +122,29 @@ ZTEST(timer, test_timer_overrun) zassert_equal(timer_getoverrun(timerid), 4, "Number of overruns is incorrect"); } +ZTEST(timer, test_one_shot__SIGEV_SIGNAL) +{ + struct sigevent sig = {0}; + struct itimerspec value; + + exp_count = 0; + sig.sigev_notify = SIGEV_SIGNAL; + sig.sigev_notify_function = handler; + sig.sigev_value.sival_int = TEST_SIGNAL_VAL; + + zassert_ok(timer_create(CLOCK_MONOTONIC, &sig, &timerid)); + + /*Set the timer to expire only once*/ + value.it_interval.tv_sec = 0; + value.it_interval.tv_nsec = 0; + value.it_value.tv_sec = 0; + value.it_value.tv_nsec = 100 * NSEC_PER_MSEC; + zassert_ok(timer_settime(timerid, 0, &value, NULL)); + k_sleep(K_MSEC(300)); + + zassert_equal(exp_count, 1, "Number of expiry is incorrect"); +} + static void after(void *arg) { ARG_UNUSED(arg);