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

Function repeat_delay_work_test01

components/drivers/ipc/utest/workqueue_tc.c:428–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426}
427
428static void repeat_delay_work_test01(void)
429{
430 struct rt_workqueue *queue;
431 rt_uint8_t curr_priority;
432 struct rt_work work;
433 volatile int work_flag = 0;
434 rt_err_t err;
435
436 /* 1 lower priority than the current test thread */
437 curr_priority = get_test_thread_priority(1);
438 queue = rt_workqueue_create("test", 2048, curr_priority);
439 if (queue == RT_NULL)
440 {
441 LOG_E("queue create failed, L:%d", __LINE__);
442 return;
443 }
444 work_flag = 0;
445 rt_work_init(&work, repeat_delay_work_test01_fun, (void *)&work_flag);
446
447 err = rt_workqueue_submit_work(queue, &work, 20);
448 uassert_int_equal(err, RT_EOK);
449
450 /* At this point the delayed work has not been executed */
451 rt_thread_delay(10);
452 /* Re-submission of time-delayed work */
453 err = rt_workqueue_submit_work(queue, &work, 20);
454 uassert_int_equal(err, RT_EOK);
455
456 rt_thread_delay(15);
457 uassert_int_equal(work_flag, 0);
458
459 /* Waiting for delayed task execution */
460 rt_thread_delay(15);
461 uassert_int_equal(work_flag, 1);
462
463 rt_thread_delay(100);
464 rt_workqueue_destroy(queue);
465}
466
467static void repeat_delay_work_test02_fun(struct rt_work *work, void *work_data)
468{

Callers

nothing calls this directly

Calls 6

get_test_thread_priorityFunction · 0.85
rt_workqueue_createFunction · 0.85
rt_work_initFunction · 0.85
rt_workqueue_submit_workFunction · 0.85
rt_thread_delayFunction · 0.85
rt_workqueue_destroyFunction · 0.85

Tested by

no test coverage detected