diff --git a/Makefile.am b/Makefile.am --- a/Makefile.am +++ b/Makefile.am @@ -44,6 +44,7 @@ include test/Makefile.am include doc/Makefile.am include tools/Makefile.am +include scripts/Makefile.am DIST_SUBDIRS = demo diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,21 @@ fi AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"]) +dnl Support for running test cases using valgrind. +use_valgrind=no +AC_ARG_ENABLE([valgrind], +AS_HELP_STRING([--enable-valgrind], [use valgrind when running tests]), + [use_valgrind=yes]) + +if [[ "$use_valgrind" = "yes" ]]; then + AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no) + + if [[ "$HAVE_VALGRIND" = "no" ]]; then + AC_MSG_ERROR([Valgrind not found in PATH.]) + fi +fi +AM_CONDITIONAL(USE_VALGRIND, [test "$use_valgrind" = "yes"]) + dnl Checks for header files. AC_CHECK_HEADERS(limits.h sys/time.h sys/times.h unistd.h) @@ -128,6 +143,7 @@ echo CBC support................... : $lx_cbc_found echo echo Build additional tools........ : $enable_tools +echo Use valgrind for tests........ : $use_valgrind echo echo The packace will be installed in echo -n ' ' diff --git a/scripts/Makefile.am b/scripts/Makefile.am new file mode 100644 --- /dev/null +++ b/scripts/Makefile.am @@ -0,0 +1,7 @@ +EXTRA_DIST += \ + scripts/bib2dox.py \ + scripts/bootstrap.sh \ + scripts/chg-len.py \ + scripts/mk-release.sh \ + scripts/unify-sources.sh \ + scripts/valgrind-wrapper.sh diff --git a/scripts/bib2dox.py b/scripts/bib2dox.py old mode 100644 new mode 100755 diff --git a/scripts/valgrind-wrapper.sh b/scripts/valgrind-wrapper.sh new file mode 100755 --- /dev/null +++ b/scripts/valgrind-wrapper.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Run in valgrind, with leak checking enabled + +valgrind -q --leak-check=full "$@" 2> .valgrind-log + +# Save the test result + +result="$?" + +# Valgrind should generate no error messages + +log_contents="`cat .valgrind-log`" + +if [ "$log_contents" != "" ]; then + cat .valgrind-log >&2 + result=1 +fi + +rm -f .valgrind-log + +exit $result diff --git a/test/Makefile.am b/test/Makefile.am --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,3 +1,7 @@ +if USE_VALGRIND +TESTS_ENVIRONMENT=$(top_srcdir)/scripts/valgrind-wrapper.sh +endif + EXTRA_DIST += \ test/CMakeLists.txt