[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
valgrind-tests.m4
From: |
Simon Josefsson |
Subject: |
valgrind-tests.m4 |
Date: |
Mon, 17 May 2010 12:15:51 +0200 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux) |
I'm running self-tests under valgrind in several projects, and it seems
like a general useful thing, so how about putting the macro for this in
gnulib?
/Simon
>From 1ec8622b3a4efed0ebaaa4eb19d440fab1708b4e Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
Date: Mon, 17 May 2010 12:15:03 +0200
Subject: [PATCH] valgrind-tests: New module.
---
ChangeLog | 8 ++++++++
doc/gnulib.texi | 3 +++
doc/valgrind-tests.texi | 16 ++++++++++++++++
m4/valgrind-tests.m4 | 34 ++++++++++++++++++++++++++++++++++
modules/valgrind-tests | 11 +++++++++++
5 files changed, 72 insertions(+), 0 deletions(-)
create mode 100644 doc/valgrind-tests.texi
create mode 100644 m4/valgrind-tests.m4
create mode 100644 modules/valgrind-tests
diff --git a/ChangeLog b/ChangeLog
index c556076..d01227c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-05-17 Simon Josefsson <address@hidden>
+
+ * modules/valgrind-tests: New file.
+ * m4/valgrind-tests.m4: New file.
+ * doc/valgrind-tests.texi: New file.
+ * doc/gnulib.texi (Running self-tests under valgrind): New
+ section.
+
2010-05-16 Bruno Haible <address@hidden>
Avoid autoconf warnings about AM_ICONV.
diff --git a/doc/gnulib.texi b/doc/gnulib.texi
index 62f969e..4cbc9e7 100644
--- a/doc/gnulib.texi
+++ b/doc/gnulib.texi
@@ -6416,6 +6416,7 @@ This list of functions is sorted according to the header
that declares them.
* func::
* warnings::
* manywarnings::
+* Running self-tests under valgrind::
@end menu
@node alloca
@@ -6514,6 +6515,8 @@ generated automatically.
@include manywarnings.texi
address@hidden valgrind-tests.texi
+
@node GNU Free Documentation License
@appendix GNU Free Documentation License
diff --git a/doc/valgrind-tests.texi b/doc/valgrind-tests.texi
new file mode 100644
index 0000000..713e7c9
--- /dev/null
+++ b/doc/valgrind-tests.texi
@@ -0,0 +1,16 @@
address@hidden Running self-tests under valgrind
address@hidden Running self-tests under valgrind
+
+For projects written in C or similar languages, running the self-tests
+under Valgrind can reveal hard to find memory issues. The
address@hidden module searches for Valgrind and declares the
address@hidden automake variable for use with automake's
address@hidden
+
+After importing the @code{valgrind-tests} module to your project, you
+use it by adding the following to the @code{Makefile.am} that runs the
+self-tests:
+
address@hidden
+TESTS_ENVIRONMENT = $(VALGRIND)
address@hidden smallexample
diff --git a/m4/valgrind-tests.m4 b/m4/valgrind-tests.m4
new file mode 100644
index 0000000..0cb8c9b
--- /dev/null
+++ b/m4/valgrind-tests.m4
@@ -0,0 +1,34 @@
+# valgrind-tests.m4 serial 1
+dnl Copyright (C) 2008, 2009, 2010 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
+
+ if test -n "$VALGRIND" && $VALGRIND -q true > /dev/null 2>&1; then
+ opt_valgrind_tests=yes
+ VALGRIND="$VALGRIND -q"
+ 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/modules/valgrind-tests b/modules/valgrind-tests
new file mode 100644
index 0000000..b9f5682
--- /dev/null
+++ b/modules/valgrind-tests
@@ -0,0 +1,11 @@
+Description:
+Macro to search for valgrind, for self-tests.
+
+Files:
+m4/valgrind-tests.m4
+
+License:
+unlimited
+
+Maintainer:
+Simon Josefsson
--
1.7.1