MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_AbortRunningTask

Function test_AbortRunningTask

tests/unit/test_cron.c:367–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365}
366
367static 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
395TEST_LIST = {
396 {"cronExec", test_cronExec},

Callers

nothing calls this directly

Calls 5

_AddTaskData_NewFunction · 0.85
Cron_AddTaskFunction · 0.85
Cron_AbortTaskFunction · 0.85
_AddTaskData_FreeFunction · 0.85

Tested by

no test coverage detected