bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] valgrind-tests: Better option handling.


From: Simon Josefsson
Subject: Re: [PATCH] valgrind-tests: Better option handling.
Date: Fri, 14 May 2021 19:38:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Bruno Haible <bruno@clisp.org> writes:

> Hi Simon,
>
>> +Replace @code{LOG_COMPILER} with @code{TESTS_ENVIRONMENT} if you are
>> +using the old serial test harness.
>
> Assuming I am a GNU package maintainer and I read this paragraph. How do
> I know whether my package uses the "old serial test harness"? Can I
> determine this by looking at configure.ac? Or at the main Makefile.am?

I suspect almost everyone is using the parallel test harness now since
it is the default since automake 1.11.3, however I clarified the manual,
does it look okay? I fixed some more things to make it actual work too.

Another read through the manual section would be welcome to make sure it
is now correct and complete.  Review of the recent changes to
valgrind-tests.m4 is also appreciated - I didn't want to break backwards
compatibility for the VALGRIND variable so it became a bit complicated.
Also I'm not sure what the best names to use for variables are.  If we
want to fix anything, let's do it relatively soon before people start to
use the new version.

/Simon
From 93be8dd0d91d7e547a83ab3a8c498b2a61a17b75 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <simon@josefsson.org>
Date: Fri, 14 May 2021 19:23:23 +0200
Subject: [PATCH] valgrind-tests: Doc fix and introduce AM_VALGRINDFLAGS.

* doc/valgrind-tests.texi (Using valgrind automatically): Clarify
when the parallel vs serial test harness is used, suggested by
Bruno Haible <bruno@clisp.org>.
* m4/valgrind-tests.m4: Add VALGRIND_PROGRAM and AM_VALGRINDFLAGS.
---
 ChangeLog               |  8 ++++++++
 doc/valgrind-tests.texi | 22 +++++++++++++++++-----
 m4/valgrind-tests.m4    | 25 ++++++++++++++++++-------
 3 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 191f4549e..136445e8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-05-14  Simon Josefsson  <simon@josefsson.org>
+
+       valgrind-tests: Doc fix and introduce AM_VALGRINDFLAGS.
+       * doc/valgrind-tests.texi (Using valgrind automatically): Clarify
+       when the parallel vs serial test harness is used, suggested by
+       Bruno Haible <bruno@clisp.org>.
+       * m4/valgrind-tests.m4: Add VALGRIND_PROGRAM and AM_VALGRINDFLAGS.
+
 2021-05-14  Bruno Haible  <bruno@clisp.org>
 
        malloc-gnu, realloc-gnu, calloc-gnu: Ensure errno gets set to ENOMEM.
diff --git a/doc/valgrind-tests.texi b/doc/valgrind-tests.texi
index 9f3b30968..96a6bbbee 100644
--- a/doc/valgrind-tests.texi
+++ b/doc/valgrind-tests.texi
@@ -34,7 +34,11 @@ LOG_COMPILER = $(LOG_VALGRIND)
 This will run all self-checks under valgrind.
 
 Replace @code{LOG_COMPILER} with @code{TESTS_ENVIRONMENT} if you are
-using the old serial test harness.
+using the old serial test harness.  The parallel test harness has been
+the default in automake since version 1.11.3, but if you are using an
+older automake, or put @samp{serial-tests} in
+@samp{AM_INIT_AUTOMAKE}/@samp{AUTOMAKE_OPTIONS} you would still be using
+the serial test harness.
 
 If you desire a project-wide decision that valgrind is not enabled by
 default, but still allow users to enable it with
@@ -54,13 +58,13 @@ that are passed to valgrind using the @samp{VALGRINDFLAGS} 
variable, for
 example:
 
 @smallexample
-./configure 
VALGRINDFLAGS="--suppressions=/your/local/valgrind/suppressions/file.txt"
+./configure VALGRINDFLAGS="--suppressions=~/local.supp"
 @end smallexample
 
 Alternatively during build phase:
 
 @smallexample
-make check 
VALGRINDFLAGS="--suppressions=/your/local/valgrind/suppressions/file.txt"
+make check VALGRINDFLAGS="--suppressions=~/local.supp"
 @end smallexample
 
 This is useful if you have a valgrind suppression files that are needed
@@ -106,6 +110,14 @@ gl_INIT
 Note that any user-supplied @code{VALGRINDFLAGS} value is preserved,
 which is usually what you want.
 
+Finally, as a developer you may want to provide additional per-directory
+options to valgrind and the @code{AM_VALGRINDFLAGS} variable can be used
+for this.  For example:
+
+@smallexample
+AM_VALGRINDFLAGS = --suppressions=$(srcdir)/local-valgrind.supp
+LOG_COMPILER = $(LOG_VALGRIND)
+@end smallexample
 
 @node Using valgrind manually
 @subsection Using valgrind at the developer's discretion
@@ -142,8 +154,8 @@ LOG_COMPILER = $(LOG_VALGRIND)
 
 Then valgrind will only be used for the non-.sh and non-.pl tests.
 
-For old automake, you will need @code{AUTOMAKE_OPTIONS = parallel-tests}
-to enable the parallel test harness.
+For old automake (before 1.11.3), you will need @code{AUTOMAKE_OPTIONS =
+parallel-tests} to enable the parallel test harness.
 
 @item
 You can make use of the @code{build-aux/run-test} script from Gnulib.
diff --git a/m4/valgrind-tests.m4 b/m4/valgrind-tests.m4
index b6b46a496..772737266 100644
--- a/m4/valgrind-tests.m4
+++ b/m4/valgrind-tests.m4
@@ -13,10 +13,10 @@ dnl From Simon Josefsson
 # Sets VALGRIND to command line (including options) to invoke valgrind
 # with, may be used directly in autoconf, makefiles or shell scripts.
 
-# Sets LOG_VALGRIND, suitable for use with LOG_COMPILER, that in a
-# makefile will expand to command line to invoke self-tests with,
+# Sets LOG_VALGRIND, suitable for use with LOG_COMPILER, that in
+# Makefile will expand to command line to invoke self-tests with,
 # i.e., LOG_VALGRIND = $(VALGRIND) $(DEFAULT_VALGRINDFLAGS)
-# $(VALGRINDFLAGS).
+# $(VALGRINDFLAGS) $(AM_VALGRINDFLAGS).
 
 # Whether to look for valgrind and set the variables can be influenced
 # by calling gl_VALGRIND_TESTS_DEFAULT_NO in configure.ac.
@@ -26,7 +26,8 @@ dnl From Simon Josefsson
 # You may modify the VALGRIND, DEFAULT_VALGRINDFLAGS and VALGRINDFLAGS
 # variables before calling this function to override defaults.  Either
 # as developer from configure.ac or user on the ./configure command
-# line.
+# line.  You may set the AM_VALGRINDFLAGS in Makefile.am to provide a
+# per-directory additional flag.
 
 AC_DEFUN([gl_VALGRIND_TESTS_DEFAULT_NO],
 [
@@ -44,6 +45,13 @@ AC_DEFUN_ONCE([gl_VALGRIND_TESTS],
   if test "$opt_valgrind_tests" = "yes" && test "$cross_compiling" = no; then
     AC_CHECK_PROGS([VALGRIND], [valgrind])
 
+    # VALGRIND_PROGRAM contains the tool found by AC_CHECK_PROGS.  For
+    # backwards compatibility, the VALGRIND variable is later modified
+    # to also include all enabled options.  However the new variable
+    # LOG_VALGRIND needs to be able to refer to the valgrind tool
+    # without options, hence it uses this variable.
+    AC_SUBST([VALGRIND_PROGRAM], [$VALGRIND])
+
     AC_SUBST([DEFAULT_VALGRINDFLAGS])
     if test -z "$DEFAULT_VALGRINDFLAGS"; then
       DEFAULT_VALGRINDFLAGS="-q --error-exitcode=1 --leak-check=full"
@@ -81,12 +89,15 @@ AC_DEFUN_ONCE([gl_VALGRIND_TESTS],
         ])
     fi
 
+    AC_SUBST([AM_VALGRINDFLAGS])
+    AC_SUBST([LOG_VALGRIND], ["\$(VALGRIND_PROGRAM) \$(DEFAULT_VALGRINDFLAGS) 
\$(VALGRINDFLAGS) \$(AM_VALGRINDFLAGS)"])
+
     if test "$gl_cv_prog_valgrind_works" != yes; then
+      DEFAULT_VALGRINDFLAGS=
+      LOG_VALGRIND=
       VALGRIND=
       VALGRINDFLAGS=
-      DEFAULT_VALGRINDFLAGS=
+      VALGRIND_PROGRAM=
     fi
-
-   AC_SUBST([LOG_VALGRIND], ["\$(VALGRIND) \$(DEFAULT_VALGRINDFLAGS) 
\$(VALGRINDFLAGS)"])
   fi
 ])
-- 
2.20.1

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]