[Lemon-commits] Akos Ladanyi: Optionally use valgrind when runni...
Lemon HG
hg at lemon.cs.elte.hu
Thu Nov 19 15:55:08 CET 2009
details: http://lemon.cs.elte.hu/hg/lemon/rev/afe8a393b050
changeset: 857:afe8a393b050
user: Akos Ladanyi <ladanyi [at] tmit.bme.hu>
date: Wed Nov 18 18:37:21 2009 +0000
description:
Optionally use valgrind when running tests + other build system
fixes
diffstat:
Makefile.am | 1 +
configure.ac | 16 ++++++++++++++++
scripts/bib2dox.py |
scripts/valgrind-wrapper.sh | 22 ++++++++++++++++++++++
test/Makefile.am | 4 ++++
5 files changed, 43 insertions(+), 0 deletions(-)
diffs (85 lines):
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/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
More information about the Lemon-commits
mailing list