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

Function repeat_work_test01

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

Source from the content-addressed store, hash-verified

299}
300
301static void repeat_work_test01(void)
302{
303 struct rt_workqueue *queue;
304 rt_uint8_t curr_priority;
305 struct rt_work work;
306 volatile int work_flag = 0;
307 rt_err_t err;
308
309 /* 1 lower priority than the current test thread */
310 curr_priority = get_test_thread_priority(1);
311 queue = rt_workqueue_create("test01", 2048, curr_priority);
312 if (queue == RT_NULL)
313 {
314 LOG_E("queue create failed, L:%d", __LINE__);
315 return;
316 }
317 work_flag = 0;
318 rt_work_init(&work, repeat_work_test01_fun, (void *)&work_flag);
319 /* Multiple submissions of the same work */
320 err = rt_workqueue_submit_work(queue, &work, 0);
321 uassert_int_equal(err, RT_EOK);
322
323 /* The same work, before it is executed, can be submitted repeatedly and executed only once */
324 err = rt_workqueue_submit_work(queue, &work, 0);
325 if (err != RT_EOK)
326 {
327 LOG_E("L:%d err. %d", __LINE__, err);
328 }
329 rt_thread_delay(10);
330 /* Check if it was executed only once */
331 uassert_int_equal(work_flag, 1);
332
333 rt_thread_delay(100);
334 rt_workqueue_destroy(queue);
335}
336
337static void repeat_work_test02_fun(struct rt_work *work, void *work_data)
338{

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