Optionally use valgrind when running tests + other build system fixes
authorAkos Ladanyi <ladanyi@tmit.bme.hu>
Wed, 18 Nov 2009 18:37:21 +0000
changeset 7937c0ad6bd6a63
parent 792 a2d5fd4c309a
child 794 313d58f9e544
Optionally use valgrind when running tests + other build system fixes
Makefile.am
configure.ac
scripts/Makefile.am
scripts/bib2dox.py
scripts/valgrind-wrapper.sh
test/Makefile.am
     1.1 --- a/Makefile.am	Wed Nov 18 14:38:38 2009 +0100
     1.2 +++ b/Makefile.am	Wed Nov 18 18:37:21 2009 +0000
     1.3 @@ -44,6 +44,7 @@
     1.4  include test/Makefile.am
     1.5  include doc/Makefile.am
     1.6  include tools/Makefile.am
     1.7 +include scripts/Makefile.am
     1.8  
     1.9  DIST_SUBDIRS = demo
    1.10  
     2.1 --- a/configure.ac	Wed Nov 18 14:38:38 2009 +0100
     2.2 +++ b/configure.ac	Wed Nov 18 18:37:21 2009 +0000
     2.3 @@ -83,6 +83,21 @@
     2.4  fi
     2.5  AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"])
     2.6  
     2.7 +dnl Support for running test cases using valgrind.
     2.8 +use_valgrind=no
     2.9 +AC_ARG_ENABLE([valgrind],
    2.10 +AS_HELP_STRING([--enable-valgrind], [use valgrind when running tests]),
    2.11 +              [use_valgrind=yes])
    2.12 +
    2.13 +if [[ "$use_valgrind" = "yes" ]]; then
    2.14 +  AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
    2.15 +
    2.16 +  if [[ "$HAVE_VALGRIND" = "no" ]]; then
    2.17 +    AC_MSG_ERROR([Valgrind not found in PATH.])
    2.18 +  fi
    2.19 +fi
    2.20 +AM_CONDITIONAL(USE_VALGRIND, [test "$use_valgrind" = "yes"])
    2.21 +
    2.22  dnl Checks for header files.
    2.23  AC_CHECK_HEADERS(limits.h sys/time.h sys/times.h unistd.h)
    2.24  
    2.25 @@ -128,6 +143,7 @@
    2.26  echo CBC support................... : $lx_cbc_found
    2.27  echo
    2.28  echo Build additional tools........ : $enable_tools
    2.29 +echo Use valgrind for tests........ : $use_valgrind
    2.30  echo
    2.31  echo The packace will be installed in
    2.32  echo -n '  '
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/scripts/Makefile.am	Wed Nov 18 18:37:21 2009 +0000
     3.3 @@ -0,0 +1,7 @@
     3.4 +EXTRA_DIST += \
     3.5 +	scripts/bib2dox.py \
     3.6 +	scripts/bootstrap.sh \
     3.7 +	scripts/chg-len.py \
     3.8 +	scripts/mk-release.sh \
     3.9 +	scripts/unify-sources.sh \
    3.10 +	scripts/valgrind-wrapper.sh
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/scripts/valgrind-wrapper.sh	Wed Nov 18 18:37:21 2009 +0000
     4.3 @@ -0,0 +1,22 @@
     4.4 +#!/bin/sh
     4.5 +
     4.6 +# Run in valgrind, with leak checking enabled
     4.7 +
     4.8 +valgrind -q --leak-check=full "$@" 2> .valgrind-log
     4.9 +
    4.10 +# Save the test result
    4.11 +
    4.12 +result="$?"
    4.13 +
    4.14 +# Valgrind should generate no error messages
    4.15 +
    4.16 +log_contents="`cat .valgrind-log`"
    4.17 +
    4.18 +if [ "$log_contents" != "" ]; then
    4.19 +        cat .valgrind-log >&2
    4.20 +        result=1
    4.21 +fi
    4.22 +
    4.23 +rm -f .valgrind-log
    4.24 +
    4.25 +exit $result
     5.1 --- a/test/Makefile.am	Wed Nov 18 14:38:38 2009 +0100
     5.2 +++ b/test/Makefile.am	Wed Nov 18 18:37:21 2009 +0000
     5.3 @@ -1,3 +1,7 @@
     5.4 +if USE_VALGRIND
     5.5 +TESTS_ENVIRONMENT=$(top_srcdir)/scripts/valgrind-wrapper.sh
     5.6 +endif
     5.7 +
     5.8  EXTRA_DIST += \
     5.9  	test/CMakeLists.txt
    5.10