belle_sip_tester.c: fix memory leaks detector

parent 961f13f4
......@@ -137,16 +137,20 @@ int belle_sip_tester_after_each() {
belle_sip_error("%s", format);
all_leaks_buffer = all_leaks_buffer ? belle_sip_strcat_printf(all_leaks_buffer, "\n%s", format) : belle_sip_strdup_printf("\n%s", format);
}
{
//prevent any future leaks
const char **tags = bc_tester_current_test_tags();
// if the test is NOT marked as leaking memory and it actually is, we should make it fail
if ( tags &&
!((tags[0] && strcmp(tags[0], "LeakingMemory")) || (tags[1] && strcmp(tags[1], "LeakingMemory")))) {
BC_FAIL("This test is leaking memory!");
return 1;
}
// prevent any future leaks
{
const char **tags = bc_tester_current_test_tags();
int leaks_expected =
(tags && ((tags[0] && !strcmp(tags[0], "LeaksMemory")) || (tags[1] && !strcmp(tags[1], "LeaksMemory"))));
// if the test is NOT marked as leaking memory and it actually is, we should make it fail
if (!leaks_expected && leaked_objects > 0) {
BC_FAIL("This test is leaking memory!");
// and reciprocally
} else if (leaks_expected && leaked_objects == 0) {
BC_FAIL("This test is not leaking anymore, please remove LeaksMemory tag!");
return 1;
}
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment