| 471 | } |
| 472 | |
| 473 | static void repeat_delay_work_test02(void) |
| 474 | { |
| 475 | struct rt_workqueue *queue; |
| 476 | rt_uint8_t curr_priority; |
| 477 | struct rt_work work; |
| 478 | volatile int work_flag = 0; |
| 479 | rt_err_t err; |
| 480 | |
| 481 | /* 1 lower priority than the current test thread */ |
| 482 | curr_priority = get_test_thread_priority(1); |
| 483 | queue = rt_workqueue_create("test", 2048, curr_priority); |
| 484 | if (queue == RT_NULL) |
| 485 | { |
| 486 | LOG_E("queue create failed, L:%d", __LINE__); |
| 487 | return; |
| 488 | } |
| 489 | work_flag = 0; |
| 490 | rt_work_init(&work, repeat_delay_work_test02_fun, (void *)&work_flag); |
| 491 | |
| 492 | err = rt_workqueue_submit_work(queue, &work, 20); |
| 493 | uassert_int_equal(err, RT_EOK); |
| 494 | |
| 495 | /* Waiting for delayed work execution */ |
| 496 | rt_thread_delay(25); |
| 497 | err = rt_workqueue_submit_work(queue, &work, 20); |
| 498 | uassert_int_equal(err, RT_EOK); |
| 499 | |
| 500 | /* Check if the delayed work has been run only once */ |
| 501 | rt_thread_delay(10); |
| 502 | uassert_int_equal(work_flag, 1); |
| 503 | |
| 504 | rt_thread_delay(25); |
| 505 | /* Check if the delayed work is executed twice */ |
| 506 | uassert_int_equal(work_flag, 2); |
| 507 | |
| 508 | rt_thread_delay(100); |
| 509 | rt_workqueue_destroy(queue); |
| 510 | } |
| 511 | |
| 512 | static void cancel_all_work_test_fun(struct rt_work *work, void *work_data) |
| 513 | { |
nothing calls this directly
no test coverage detected