From e3e3ee261e0d2f8716b5011ca5fcfc88766146f5 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 1 Oct 2012 16:14:12 +0200 Subject: [PATCH] Add configure --enable-valgrind option to run all tests under valgrind. Signed-off-by: Mark Wielaard --- ChangeLog | 5 +++++ Makefile.am | 2 ++ configure.ac | 11 +++++++++++ tests/ChangeLog | 7 +++++++ tests/Makefile.am | 8 +++++++- tests/test-subr.sh | 6 +++--- tests/test-wrapper.sh | 4 ++++ 7 files changed, 39 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 208e4253c..a05ebdf24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-10-01 Mark Wielaard + + * configure.ac: Add --enable-valgrind check. + * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Add --enable-valgrind. + 2012-08-27 Mark Wielaard * configure.ac: Set version to 0.155. diff --git a/Makefile.am b/Makefile.am index 305bbfcb6..e8339898b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,8 +32,10 @@ EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \ # Make sure the test install uses lib64 when $LIB will yield lib64. # Make sure the test build uses the same compiler, which on e.g. ppc64 # determines which platform we are actually testing. +# Run all tests under valgrind. DISTCHECK_CONFIGURE_FLAGS = \ --libdir=`echo $(libdir) | sed "s,^$(exec_prefix),$$dc_install_base,"`\ + --enable-valgrind \ CC="$(CC)" distcheck-hook: diff --git a/configure.ac b/configure.ac index adec1c1d9..52a232211 100644 --- a/configure.ac +++ b/configure.ac @@ -190,6 +190,17 @@ if test "$use_gcov" = yes; then fi AM_CONDITIONAL(GCOV, test "$use_gcov" = yes) +AC_ARG_ENABLE([valgrind], +AS_HELP_STRING([--enable-valgrind],[run all tests under valgrind]), +[use_valgrind=$enableval], [use_valgrind=no]) +if test "$use_valgrind" = yes; then + AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no) + if test "$HAVE_VALGRIND" = "no"; then + AC_MSG_ERROR([valgrind not found]) + fi +fi +AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes) + AM_CONDITIONAL(BUILD_STATIC, [dnl test "$use_mudflap" = yes -o "$use_gprof" = yes -o "$use_gcov" = yes]) diff --git a/tests/ChangeLog b/tests/ChangeLog index 1b5271c92..37e214ef9 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,10 @@ +2012-10-01 Mark Wielaard + + * Makefile.am (TESTS_ENVIRONMENT): Define valgrind_cmd if USE_VALGRIND. + * test-wrapper.sh: Export VALGRIND_CMD if available. + * test-subr.sh (built_testrun): Use VALGRIND_CMD to invoke test prog. + (installed_testrun): Likewise. + 2012-09-24 Petr Machata * testfile63.bz2: New testfile. diff --git a/tests/Makefile.am b/tests/Makefile.am index 6cf098bc9..4775b379e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -181,16 +181,22 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-readelf-vmcoreinfo.sh testfile62.bz2 \ run-readelf-mixed-corenote.sh testfile63.bz2 +if USE_VALGRIND +valgrind_cmd="valgrind -q --trace-children=yes --error-exitcode=1" +endif + installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \ bindir=$(DESTDIR)$(bindir) \ LC_ALL=C LANG=C \ + VALGRIND_CMD=$(valgrind_cmd) \ $(srcdir)/test-wrapper.sh \ installed $(tests_rpath) \ $(program_transform_name) if STANDALONE TESTS_ENVIRONMENT = $(installed_TESTS_ENVIRONMENT) else !STANDALONE -TESTS_ENVIRONMENT = LC_ALL=C LANG=C $(srcdir)/test-wrapper.sh \ +TESTS_ENVIRONMENT = LC_ALL=C LANG=C VALGRIND_CMD=$(valgrind_cmd) \ + $(srcdir)/test-wrapper.sh \ ../libdw:../backends:../libelf:../libasm installcheck-local: diff --git a/tests/test-subr.sh b/tests/test-subr.sh index ff29136fb..19a9836a0 100644 --- a/tests/test-subr.sh +++ b/tests/test-subr.sh @@ -72,7 +72,7 @@ testrun() built_testrun() { LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"\ - "$@" + $VALGRIND_CMD "$@" } installed_testrun() @@ -93,9 +93,9 @@ installed_testrun() if [ "${libdir}" != /usr/lib ] && [ "${libdir}" != /usr/lib64 ]; then LD_LIBRARY_PATH="${libdir}:${libdir}/elfutils\ ${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" \ - $program ${1+"$@"} + $VALGRIND_CMD $program ${1+"$@"} else - $program ${1+"$@"} + $VALGRIND_CMD $program ${1+"$@"} fi } diff --git a/tests/test-wrapper.sh b/tests/test-wrapper.sh index 96ddb7429..09b4d49f6 100755 --- a/tests/test-wrapper.sh +++ b/tests/test-wrapper.sh @@ -58,4 +58,8 @@ case "$1" in ;; esac +if [ "x$VALGRIND_CMD" != "x" ]; then + export VALGRIND_CMD +fi + exec "$@" -- 2.47.2