[PATCH libksba 6/7] Enable optional valgrind for testsuite
Dmitry Eremin-Solenikov
dbaryshkov at gmail.com
Sat Jul 12 13:11:18 CEST 2014
* configure.ac: Enable gnulib valgrind module.
* gl/m4/gnulib.m4: Enable valgrind module.
* tests/Makefile.am: Enable valgrind as LOG_COMPILER.
* gl/m4/valgrind-tests.m4: New
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
---
configure.ac | 2 +-
gl/Makefile.am | 2 +-
gl/m4/gnulib.m4 | 1 +
gl/m4/valgrind-tests.m4 | 37 +++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 2 ++
5 files changed, 42 insertions(+), 2 deletions(-)
create mode 100644 gl/m4/valgrind-tests.m4
diff --git a/configure.ac b/configure.ac
index cc24bbf..372c20c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -362,7 +362,7 @@ AC_CHECK_FUNCS([memmove strchr strtol strtoul stpcpy gmtime_r getenv])
# GNUlib checks
gl_SOURCE_BASE(gl)
gl_M4_BASE(gl/m4)
-gl_MODULES(alloca)
+gl_MODULES(alloca valgrind-tests)
gl_INIT
# To be used in ksba-config
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 3e407d1..f3b46e0 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -9,7 +9,7 @@
#
# Generated by gnulib-tool.
# Invoked as: gnulib-tool --import
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --libtool alloca alloca-opt
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --libtool alloca alloca-opt valgrind-tests
AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
diff --git a/gl/m4/gnulib.m4 b/gl/m4/gnulib.m4
index 074e76e..7a975be 100644
--- a/gl/m4/gnulib.m4
+++ b/gl/m4/gnulib.m4
@@ -21,6 +21,7 @@ LTALLOCA=`echo "$ALLOCA" | sed 's/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'`
changequote([, ])dnl
AC_SUBST(LTALLOCA)
gl_FUNC_ALLOCA
+ gl_VALGRIND_TESTS
])
dnl Usage: gl_MODULES(module1 module2 ...)
diff --git a/gl/m4/valgrind-tests.m4 b/gl/m4/valgrind-tests.m4
new file mode 100644
index 0000000..66f81fb
--- /dev/null
+++ b/gl/m4/valgrind-tests.m4
@@ -0,0 +1,37 @@
+# valgrind-tests.m4 serial 3
+dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson
+
+# gl_VALGRIND_TESTS()
+# -------------------
+# Check if valgrind is available, and set VALGRIND to it if available.
+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])
+
+ # Run self-tests under valgrind?
+ if test "$opt_valgrind_tests" = "yes" && test "$cross_compiling" = no; then
+ AC_CHECK_PROGS(VALGRIND, valgrind)
+ fi
+
+ OPTS="-q --error-exitcode=1 --leak-check=full"
+
+ if test -n "$VALGRIND" \
+ && $VALGRIND $OPTS $SHELL -c 'exit 0' > /dev/null 2>&1; then
+ opt_valgrind_tests=yes
+ VALGRIND="$VALGRIND $OPTS"
+ else
+ opt_valgrind_tests=no
+ VALGRIND=
+ fi
+
+ AC_MSG_CHECKING([whether self tests are run under valgrind])
+ AC_MSG_RESULT($opt_valgrind_tests)
+])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 013fb84..ae2ad4e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -60,3 +60,5 @@ oidtranstbl.h: Makefile mkoidtbl.awk
/usr/share ; do \
if test -f $$i/dumpasn1.cfg; then f=$$i/dumpasn1.cfg; break; fi; \
done; $(AWK) -f $(srcdir)/mkoidtbl.awk $$f >$@
+
+LOG_COMPILER = $(VALGRIND)
--
2.0.0
More information about the Gnupg-devel
mailing list