tests: detect and close leaks in unit tests.

Fixes: #288
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-09-28 13:10:05 +09:30
parent 5029f95066
commit 7200002773
3 changed files with 4 additions and 1 deletions

View File

@ -13,7 +13,7 @@ BOLTVERSION := master
ifneq ($(NO_VALGRIND),1)
VALGRIND=valgrind -q --error-exitcode=7
VALGRIND_TEST_ARGS = --track-origins=yes --leak-check=full --show-reachable=yes
VALGRIND_TEST_ARGS = --track-origins=yes --leak-check=full --show-reachable=yes --errors-for-leak-kinds=all
endif
ifeq ($(COVERAGE),1)

View File

@ -268,6 +268,7 @@ int main(int argc, char **argv)
printf("%s\n", hextemp);
}
secp256k1_context_destroy(secp256k1_ctx);
opt_free_table();
tal_free(ctx);
return 0;
}

View File

@ -114,6 +114,8 @@ int main(int argc, char *argv[])
setenv("PATH", tal_strjoin(tmpctx, pathelems, ":", STR_NO_TRAIL), 1);
assert(streq(find_my_path(tmpctx, argv0), answer));
assert(!taken_any());
take_cleanup();
tal_free(tmpctx);
return 0;
}