# HG changeset patch # User Akos Ladanyi # Date 1258569441 0 # Node ID 7c0ad6bd6a6336ddb5582870837d1a02b6a73a0a # Parent a2d5fd4c309a4c4431d3c2377cff197ebe0bf476 Optionally use valgrind when running tests + other build system fixes diff -r a2d5fd4c309a -r 7c0ad6bd6a63 Makefile.am --- a/Makefile.am Wed Nov 18 14:38:38 2009 +0100 +++ b/Makefile.am Wed Nov 18 18:37:21 2009 +0000 @@ -44,6 +44,7 @@ include test/Makefile.am include doc/Makefile.am include tools/Makefile.am +include scripts/Makefile.am DIST_SUBDIRS = demo diff -r a2d5fd4c309a -r 7c0ad6bd6a63 configure.ac --- a/configure.ac Wed Nov 18 14:38:38 2009 +0100 +++ b/configure.ac Wed Nov 18 18:37:21 2009 +0000 @@ -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 -r a2d5fd4c309a -r 7c0ad6bd6a63 scripts/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/Makefile.am Wed Nov 18 18:37:21 2009 +0000 @@ -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 -r a2d5fd4c309a -r 7c0ad6bd6a63 scripts/valgrind-wrapper.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/valgrind-wrapper.sh Wed Nov 18 18:37:21 2009 +0000 @@ -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 -r a2d5fd4c309a -r 7c0ad6bd6a63 test/Makefile.am --- a/test/Makefile.am Wed Nov 18 14:38:38 2009 +0100 +++ b/test/Makefile.am Wed Nov 18 18:37:21 2009 +0000 @@ -1,3 +1,7 @@ +if USE_VALGRIND +TESTS_ENVIRONMENT=$(top_srcdir)/scripts/valgrind-wrapper.sh +endif + EXTRA_DIST += \ test/CMakeLists.txt