| 299 | } |
| 300 | |
| 301 | static 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 | |
| 337 | static void repeat_work_test02_fun(struct rt_work *work, void *work_data) |
| 338 | { |
nothing calls this directly
no test coverage detected