MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / test_dynamic_timer_control

Function test_dynamic_timer_control

src/utest/timer_tc.c:473–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471}
472
473static void test_dynamic_timer_control(void)
474{
475 rt_err_t result;
476 rt_tick_t set_data;
477 rt_tick_t get_data;
478
479 timer.callbacks = 0;
480 timer.is_static = RT_FALSE;
481
482 timer.dynamic_timer = rt_timer_create("dynamic_timer",
483 timer_control,
484 &timer,
485 5,
486 RT_TIMER_FLAG_PERIODIC);
487
488 /* test set data */
489 set_data = 10;
490 result = rt_timer_control(timer.dynamic_timer, RT_TIMER_CTRL_SET_TIME, &set_data);
491 uassert_true(result == RT_EOK);
492
493 /* test get data */
494 result = rt_timer_control(timer.dynamic_timer, RT_TIMER_CTRL_GET_TIME, &get_data);
495
496 uassert_true(result == RT_EOK);
497 uassert_true(set_data == get_data);
498
499 /* calc expect tick */
500 timer.expect_tick = rt_tick_get() + set_data;
501
502 /* start timer */
503 result = rt_timer_start(timer.dynamic_timer);
504 uassert_true(result == RT_EOK);
505
506 rt_thread_delay(3 * set_data + 1);
507
508 /* detach timer */
509 result = rt_timer_delete(timer.dynamic_timer);
510 uassert_true(result == RT_EOK);
511 uassert_true(timer.callbacks == 1);
512}
513
514static void test_dynamic_timer_start_twice(void)
515{

Callers

nothing calls this directly

Calls 6

rt_timer_createFunction · 0.85
rt_timer_controlFunction · 0.85
rt_tick_getFunction · 0.85
rt_timer_startFunction · 0.85
rt_thread_delayFunction · 0.85
rt_timer_deleteFunction · 0.85

Tested by

no test coverage detected