[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] suggestion enhancement valgrind_tests.m4
From: |
Bernd Becker |
Subject: |
[PATCH] suggestion enhancement valgrind_tests.m4 |
Date: |
Sat, 11 Sep 2010 13:00:19 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6 ThunderBrowse/3.3.2 |
Hi,
I tried this a few weeks ago, but didn't get a response, yet.
So maybe this time I have more luck
Bernd
Here is the patch generated from git:
diff --git a/m4/valgrind-tests.m4 b/m4/valgrind-tests.m4
index e2434c6..f11ca3e 100644
--- a/m4/valgrind-tests.m4
+++ b/m4/valgrind-tests.m4
@@ -6,6 +6,70 @@ dnl with or without modifications, as long as this
notice is preserved.
dnl From Simon Josefsson
+AC_ARG_VAR([VALGRIND_MEMLEAK_OPTS],
+ [use this variable to override command line options of
valgrind for memory leak checking. Run 'valgrind --help' or 'man
valgrind' for valid options])
+
+# gl_VALGRIND_TREAT_LEAKS_AS_ERRORS()
+# -----------------------------------
+# Configuration parameter to treat memory leaks as errors if they
+# occur in a module test
+AC_DEFUN([gl_VALGRIND_MEMLEAKS_ARE_ERRORS],
+[
+ AC_ARG_ENABLE(valgrind-memleaks-are-errors,
+ AS_HELP_STRING([--enable-valgrind-memleaks-are-errors],
+ [treat module tests with memory leaks as errors]),
+ [opt_valgrind_memleaks_are_errors=$enableval],
+ [opt_valgrind_memleaks_are_errors=no])
+
+ if test -z "$VALGRIND_MEMLEAK_OPTS"; then
+ if test "$opt_valgrind_memleaks_are_errors" = "yes"; then
+ opt_valgrind_memleaks_are_errors=yes
+ VALGRIND_MEMLEAK_OPTS="-q --error-exitcode=1 --leak-check=full"
+ else
+ opt_valgrind_memleaks_are_errors=no
+ VALGRIND_MEMLEAK_OPTS="-q"
+ fi
+ else
+ opt_valgrind_memleaks_are_errors="$VALGRIND_MEMLEAK_OPTS"
+ fi
+
+ AC_SUBST([VALGRIND_MEMLEAK_OPTS],[$VALGRIND_MEMLEAK_OPTS])
+ AC_MSG_CHECKING([whether valgrind treats memory leaks as errors])
+ AC_MSG_RESULT($opt_valgrind_memleaks_are_errors)
+])
+
++AC_DEFUN([gl_VALGRIND_CONSISTENCY],
+[
+ if test "$opt_valgrind_tests" = "no" && test
"$opt_valgrind_memleaks_are_errors" != "no"; then
+ AC_MSG_WARN(
+ [
+ *******************************************************************
+ *** ***
+ *** Memory leak checking with Valgrind is disabled. ***
+ *** ***
+ *** Ignoring: --enable-valgrind-tests ***
+ *** Ignoring: settings in \$VALGRIND_MEMLEAK_OPTS ***
+ *** ***
+ *******************************************************************
+ ])
+ fi
+])
+
+AC_DEFUN([gl_VALGRIND_SUMMARY],
+[
+ valgrind_options=""
+ if test "$opt_valgrind_tests" = "yes"; then
+ if test "$opt_valgrind_memleaks_are_errors" = "yes" ||
+ test "$opt_valgrind_memleaks_are_errors" = "no";
+ then
+ valgrind_options="Memleaks are errors:
${opt_valgrind_memleaks_are_errors}"
+ else
+ valgrind_options="Valgrind options:
${opt_valgrind_memleaks_are_errors}"
+ fi
+ fi
+])
+
# gl_VALGRIND_TESTS()
# -------------------
# Check if valgrind is available, and set VALGRIND to it if available.
@@ -14,21 +78,27 @@ AC_DEFUN([gl_VALGRIND_TESTS],
AC_ARG_ENABLE(valgrind-tests,
AS_HELP_STRING([--enable-valgrind-tests],
[run self tests under valgrind]),
- [opt_valgrind_tests=$enableval], [opt_valgrind_tests=yes])
+ [opt_valgrind_tests=$enableval], [opt_valgrind_tests=no])
# Run self-tests under valgrind?
if test "$opt_valgrind_tests" = "yes" && test "$cross_compiling" =
no; then
AC_CHECK_PROGS(VALGRIND, valgrind)
fi
- if test -n "$VALGRIND" && $VALGRIND -q true > /dev/null 2>&1; then
+ if test -n "$VALGRIND" && $VALGRIND true > /dev/null 2>&1; then
opt_valgrind_tests=yes
- VALGRIND="$VALGRIND -q"
+ VALGRIND="libtool --mode=execute $VALGRIND \$(VALGRIND_MEMLEAK_OPTS)"
else
opt_valgrind_tests=no
VALGRIND=
fi
+ gl_VALGRIND_MEMLEAKS_ARE_ERRORS
+ gl_VALGRIND_CONSISTENCY
+ gl_VALGRIND_SUMMARY
+
AC_MSG_CHECKING([whether self tests are run under valgrind])
AC_MSG_RESULT($opt_valgrind_tests)
])
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] suggestion enhancement valgrind_tests.m4,
Bernd Becker <=