From 72000027733f95bae60d14fa8368d44c87c046b8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 28 Sep 2017 13:10:05 +0930 Subject: [PATCH] tests: detect and close leaks in unit tests. Fixes: #288 Signed-off-by: Rusty Russell --- Makefile | 2 +- common/test/test_sphinx.c | 1 + lightningd/test/run-find_my_path.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 24ad5ec85..c5795b2f7 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/common/test/test_sphinx.c b/common/test/test_sphinx.c index 6d9c2f80a..e885abcc4 100644 --- a/common/test/test_sphinx.c +++ b/common/test/test_sphinx.c @@ -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; } diff --git a/lightningd/test/run-find_my_path.c b/lightningd/test/run-find_my_path.c index ff338019c..fe5a627f1 100644 --- a/lightningd/test/run-find_my_path.c +++ b/lightningd/test/run-find_my_path.c @@ -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; }