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

Function test_MultiAbort

tests/unit/test_cron.c:311–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311static void test_MultiAbort() {
312 // reset X = 1
313 // issue a task X += 2
314 // abort task multiple times
315 // validate X = 1
316
317 X = 1;
318 int Y = 2;
319 AddTaskData data = _AddTaskData_New(add_task, (void *)&Y);
320
321 // issue task X += 2
322 CronTaskHandle task_handle = Cron_AddTask(15, _AddTaskData_Execute, NULL,
323 &data);
324
325 // abort task multiple times, should not crash or hang
326 for(int i = 0; i < 20; i++) {
327 Cron_AbortTask(task_handle);
328 }
329
330 if (_AddTaskData_HasStarted(data)) {
331 _AddTaskData_WaitForCompletion(data);
332 }
333
334 _AddTaskData_Free(data);
335
336 // task should have been aborted prior to its execution
337 // expecting X = 1
338 TEST_ASSERT(X == 1);
339}
340
341static void test_abortNoneExistingTask() {
342 // reset X = 1

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected