Skip to content

Commit cbec9a3

Browse files
Noemie Gilletnashif
Noemie Gillet
authored andcommitted
test: posix: add test_one_shot__SIGEV_SIGNAL testcase
increase test coverage for newly added code Signed-off-by: Noemie Gillet <[email protected]>
1 parent a214ddb commit cbec9a3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/posix/common/src/timer.c

+23
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,29 @@ ZTEST(timer, test_timer_overrun)
122122
zassert_equal(timer_getoverrun(timerid), 4, "Number of overruns is incorrect");
123123
}
124124

125+
ZTEST(timer, test_one_shot__SIGEV_SIGNAL)
126+
{
127+
struct sigevent sig = {0};
128+
struct itimerspec value;
129+
130+
exp_count = 0;
131+
sig.sigev_notify = SIGEV_SIGNAL;
132+
sig.sigev_notify_function = handler;
133+
sig.sigev_value.sival_int = TEST_SIGNAL_VAL;
134+
135+
zassert_ok(timer_create(CLOCK_MONOTONIC, &sig, &timerid));
136+
137+
/*Set the timer to expire only once*/
138+
value.it_interval.tv_sec = 0;
139+
value.it_interval.tv_nsec = 0;
140+
value.it_value.tv_sec = 0;
141+
value.it_value.tv_nsec = 100 * NSEC_PER_MSEC;
142+
zassert_ok(timer_settime(timerid, 0, &value, NULL));
143+
k_sleep(K_MSEC(300));
144+
145+
zassert_equal(exp_count, 1, "Number of expiry is incorrect");
146+
}
147+
125148
static void after(void *arg)
126149
{
127150
ARG_UNUSED(arg);

0 commit comments

Comments
 (0)