54 #include <sys/signalfd.h>
67 #include <amxc/amxc.h>
68 #include <amxc/amxc_timestamp.h>
73 #include <amxc/amxc_macros.h>
90 check_expected(timer);
93 assert_ptr_not_equal(timer, NULL);
99 struct signalfd_siginfo fdsi;
103 sigaddset(&
mask, SIGALRM);
105 sigprocmask(SIG_BLOCK, &
mask, NULL);
107 sfd = signalfd(-1, &
mask, 0);
108 s = read(sfd, &fdsi,
sizeof(
struct signalfd_siginfo));
109 assert_int_equal(s,
sizeof(
struct signalfd_siginfo));
110 if(fdsi.ssi_signo == SIGALRM) {
111 printf(
"Got SIGALRM\n");
113 printf(
"Read unexpected signal\n");
124 assert_ptr_not_equal(timer, NULL);
126 assert_ptr_equal(timer->
cb, NULL);
127 assert_ptr_equal(timer->
priv, NULL);
132 assert_ptr_equal(timer, NULL);
143 assert_ptr_not_equal(timer1, NULL);
145 assert_ptr_not_equal(timer2, NULL);
163 assert_int_equal(ts2.sec - ts1.sec, 1);
171 assert_int_equal(ts2.sec - ts1.sec, 3);
185 assert_ptr_not_equal(timer1, NULL);
208 assert_ptr_not_equal(timer1, NULL);
210 assert_ptr_not_equal(timer2, NULL);
230 assert_true((remaining / 1000) <= (
count - 1));
234 assert_int_equal(
count, 0);
249 amxc_ts_t start_time;
256 amxc_ts_now(&start_time);
259 amxc_ts_now(&end_time);
260 assert_int_equal(end_time.sec - start_time.sec, 3);
266 amxc_ts_t start_time;
281 amxc_ts_now(&start_time);
283 amxc_ts_now(&end_time);
288 assert_int_equal(end_time.sec - start_time.sec, 0);
295 amxc_ts_t start_time;
310 amxc_ts_now(&start_time);
312 amxc_ts_now(&end_time);
317 assert_int_equal(end_time.sec - start_time.sec, 0);
Ambiorix timer API header file.
int amxp_timer_start(amxp_timer_t *timer, unsigned int timeout_msec)
Starts or resets a timer.
unsigned int amxp_timer_remaining_time(amxp_timer_t *timer)
Get the remaining time of the timer.
amxp_timer_state_t amxp_timer_get_state(amxp_timer_t *timer)
Get the timer's state.
void amxp_timers_check(void)
Check all timers and call the callback function when the timer is in Timer expired state.
int amxp_timer_stop(amxp_timer_t *timer)
Stops the timer.
void amxp_timers_calculate(void)
Caclulates the remaining time of all timers.
void amxp_timer_delete(amxp_timer_t **timer)
Deletes a timer.
int amxp_timer_new(amxp_timer_t **timer, amxp_timer_cb_t cb, void *priv)
Allocate and initializes a new timer.
int amxp_timer_set_interval(amxp_timer_t *timer, unsigned int msec)
Sets the interval of a timer in milli seconds.
void test_timer_callback_is_called(UNUSED void **state)
void test_timer_can_delete_timers_in_callback(UNUSED void **state)
void test_timer_can_delete_add_timers_in_callback(UNUSED void **state)
void test_can_start_timers(UNUSED void **state)
static void timer_delete_timers_cb(UNUSED amxp_timer_t *timer, UNUSED void *priv)
void test_timer_with_0_timeout_test2(UNUSED void **state)
static void timer_delete_add_timers_cb(UNUSED amxp_timer_t *timer, UNUSED void *priv)
static void read_sigalrm(void)
void test_can_start_interval_timer(UNUSED void **state)
void test_can_create_timer(UNUSED void **state)
static void timer_callback(amxp_timer_t *timer, void *priv)
void test_can_restart_timer(UNUSED void **state)
void test_timer_with_0_timeout_test1(UNUSED void **state)