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

Function do_delay_work_test

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

Source from the content-addressed store, hash-verified

81}
82
83static void do_delay_work_test(void)
84{
85 struct rt_workqueue *queue;
86 rt_uint8_t curr_priority;
87 struct rt_work work;
88 volatile rt_tick_t work_start = 0;
89 volatile rt_tick_t work_end = 0;
90 rt_err_t err;
91
92 /* 1 higher priority than the current test thread */
93 curr_priority = get_test_thread_priority(-1);
94 queue = rt_workqueue_create("test", 2048, curr_priority);
95 if (queue == RT_NULL)
96 {
97 LOG_E("queue create failed, L:%d", __LINE__);
98 return;
99 }
100 rt_work_init(&work, do_delay_work_test_fun, (void *)&work_end);
101 work_start = rt_tick_get();
102 /* Normal delayed work submission test */
103 err = rt_workqueue_submit_work(queue, &work, 10);
104 uassert_int_equal(err, RT_EOK);
105
106 /* Ensure that the delayed work has been executed */
107 rt_thread_delay(15);
108 /* Check if the delayed task is executed after 10 ticks */
109 if (work_end < work_start || work_end - work_start < 10)
110 {
111 uassert_false(1);
112 }
113 rt_thread_delay(100);
114 rt_workqueue_destroy(queue);
115}
116
117static void cancle_work_test01_fun(struct rt_work *work, void *work_data)
118{

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected