From: Richard W.M. Jones Date: Sat, 26 Apr 2014 18:38:22 +0000 (+0100) Subject: tests: Add 'make check-valgrind' to run test suite under valgrind. X-Git-Tag: v1.1~19 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=0fe43b4d2de5ac336c2f1635b9a8f60b3ae00370;p=miniexpect.git tests: Add 'make check-valgrind' to run test suite under valgrind. --- diff --git a/Makefile.am b/Makefile.am index b2ac4b3..4d3f91f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,6 +51,15 @@ test_ls_version_SOURCES = test-ls-version.c tests.h miniexpect.h test_ls_version_CFLAGS = $(PCRE_CFLAGS) -Wall test_ls_version_LDADD = libminiexpect.la +# parallel-tests breaks the ability to put 'valgrind' into +# TESTS_ENVIRONMENT. Hence we have to work around it: +check-valgrind: + for t in $(TESTS); do \ + $(LIBTOOL) --mode=execute $(VG) ./$$t; \ + r=$$?; \ + if [ $$r -ne 0 ]; then exit $$r; fi; \ + done + # Clean. CLEANFILES = *~ diff --git a/configure.ac b/configure.ac index e84650a..4343686 100644 --- a/configure.ac +++ b/configure.ac @@ -49,6 +49,17 @@ dnl Optional for building the manual page. This is part of Perl. AC_CHECK_PROG([POD2MAN], [pod2man], [pod2man], [no]) AM_CONDITIONAL([HAVE_POD2MAN], [test "x$POD2MAN" != "xno"]) +dnl Optional for checking for memory errors. +AC_CHECK_PROG([VALGRIND], [valgrind], [valgrind], [no]) +AS_IF([test "x$VALGRIND" != "xno"],[ + VG='$(VALGRIND) --leak-check=full --show-leak-kinds=all --error-exitcode=119 --trace-children=no' +],[ + dnl Valgrind is not installed, so give a clear error if + dnl the user tries 'make check-valgrind'. + VG=ERROR_VALGRIND_IS_NOT_INSTALLED +]) +AC_SUBST([VG]) + dnl Produce output files. AC_CONFIG_HEADERS([config.h])