Skip to content

Commit e0b1912

Browse files
committed
testsuite: fix memory leaks in planner tests
Problem: the current planner tests do not destroy the planners created during the tests, resulting in memory leaks that will pollute Valgrind test output. Add calls to destroy the planners to eliminate the memory leaks.
1 parent 0638380 commit e0b1912

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

resource/planner/test/planner_test01.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ static int test_resource_service_flow ()
569569
}
570570
ok (!bo, "reserve %d jobs for global/local planners", depth);
571571

572+
for (auto &type : global_types)
573+
free ((void *)type);
574+
572575
planner_destroy (&global1);
573576
planner_destroy (&global2);
574577
planner_destroy (&global3);
@@ -639,6 +642,8 @@ static int test_more_add_remove ()
639642
bo = (bo || span6 == -1);
640643

641644
ok (!bo, "more add-remove-add test works");
645+
646+
planner_destroy (&ctx);
642647
return 0;
643648
}
644649

resource/planner/test/planner_test02.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ static int test_multi_strictly_larger ()
295295
ok ((t == -1 && errno == ENOENT), "avail_time_next for (%s)",
296296
ss.str ().c_str ());
297297

298+
planner_multi_destroy (&ctx);
298299
return 0;
299300
}
300301

@@ -405,6 +406,7 @@ static int test_multi_partially_larger ()
405406
ok ((t == -1 && errno == ENOENT), "avail_time_next for (%s)",
406407
ss.str ().c_str ());
407408

409+
planner_multi_destroy (&ctx);
408410
return 0;
409411
}
410412

@@ -483,6 +485,8 @@ static int test_multi_many_spans ()
483485
t = planner_multi_avail_time_next (ctx);
484486
bo = (bo || !(t == -1 && errno == ENOENT));
485487
ok (!bo, "avail_time_next for (%s)", ss.str ().c_str ());
488+
489+
planner_multi_destroy (&ctx);
486490
return 0;
487491
}
488492

@@ -535,6 +539,7 @@ static int test_multi_add_remove ()
535539
size = planner_multi_span_size (ctx);
536540
ok ((size == 2), "planner_multi_span_size works");
537541

542+
planner_multi_destroy (&ctx);
538543
return 0;
539544

540545
}

0 commit comments

Comments
 (0)