From e2f76748712decb62ef6a98626e9c4cf6242bea8 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 23 Sep 2025 13:26:39 +0200 Subject: [PATCH] autotools: Make valgrind actually check for leaks Problem with libtools is that it produces shell scripts which then set LD_LIBRARY_PATH and execute actual binary (hidden in .libs dir). Therefore, running 'valgring ./testbinary' doesn't do anything useful (beside checking for memleaks in shell). We want to use `libtool --mode=execute valgrind ./testbinary`. With that fixed, next step is to make valgrind return a non-zero value if a memleak is detected (--error-exitcode=). And to show individual memleaks let's use --leak-check=full. Signed-off-by: Michal Privoznik --- Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index f053b2f04..c51dfd8ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -186,10 +186,12 @@ endif # Compatibility name of the check target runtests: check +VALGRIND = valgrind -q --leak-check=full --error-exitcode=1 + check-valgrind valgrind: @echo '## Running the regression tests under Valgrind' @echo '## Go get a cup of coffee it is gonna take a while ...' - $(MAKE) CHECKER='valgrind -q' check + $(MAKE) check CHECKER="$(LIBTOOL) --mode=execute $(VALGRIND)" dist-hook: (cd $(srcdir) ; tar -cf - --exclude .git win32 test result) | (cd $(distdir); tar xf -)