| 365 | } |
| 366 | |
| 367 | static void test_AbortRunningTask() { |
| 368 | // issue a long running task ~100ms |
| 369 | // issue abort 20ms into execution |
| 370 | // validate call to Cron_AbortTask returns after task compelted |
| 371 | |
| 372 | int ms = 100; |
| 373 | AddTaskData data = _AddTaskData_New(long_running_task, (void*)&ms); |
| 374 | // issue a long running task, task will sleep for 100 'ms' |
| 375 | CronTaskHandle task_handle = Cron_AddTask(0, _AddTaskData_Execute, NULL, |
| 376 | &data); |
| 377 | |
| 378 | _AddTaskData_WaitForRunning(data); |
| 379 | |
| 380 | clock_t t = clock(); // start timer |
| 381 | |
| 382 | // the task should be already running |
| 383 | // abort the task, call should return until the task completed. |
| 384 | Cron_AbortTask(task_handle); |
| 385 | |
| 386 | t = clock() - t; // stop timer |
| 387 | double time_taken_sec = ((double)t)/CLOCKS_PER_SEC; |
| 388 | |
| 389 | // expecting Cron_AbortTask to return after task completed |
| 390 | TEST_ASSERT(time_taken_sec >= 0.1); |
| 391 | |
| 392 | _AddTaskData_Free(data); |
| 393 | } |
| 394 | |
| 395 | TEST_LIST = { |
| 396 | {"cronExec", test_cronExec}, |
nothing calls this directly
no test coverage detected