Browse Source

test: posix: add test_one_shot__SIGEV_SIGNAL testcase

increase test coverage for newly added code

Signed-off-by: Noemie Gillet <ngillet@sequans.com>
pull/81485/head
Noemie Gillet 8 months ago committed by Anas Nashif
parent
commit
cbec9a342b
  1. 23
      tests/posix/common/src/timer.c

23
tests/posix/common/src/timer.c

@ -122,6 +122,29 @@ ZTEST(timer, test_timer_overrun) @@ -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);

Loading…
Cancel
Save