bug-gnulib
[Top][All Lists]
Advanced

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

Re: valgrind-tests.m4


From: Bruno Haible
Subject: Re: valgrind-tests.m4
Date: Tue, 18 May 2010 11:16:51 +0200
User-agent: KMail/1.9.9

Ben Pfaff wrote:
>         * In GNU PSPP, which mostly uses the built-in Automake
>           test framework, the invocations of the test programs
>           are all through shell scripts.  Each invocation of a
>           test program is preceded by $SUPERVISOR,
>           e.g. "$SUPERVISOR pspp ...".  Then running "make check"
>           runs without valgrind; running "make check
>           SUPERVISOR='libtool --mode=execute valgrind'" runs with
>           valgrind; and so on.  (Sometimes 'libtool
>           --mode=execute gdb --args' is handy.)

The approach I use in GNU gettext is similar: Makefile.am has this:

# For debugging memory leaks and memory allocation bugs.
# You should build with --disable-shared when using valgrind.
CHECKER =
#CHECKER = valgrind --tool=memcheck 
--suppressions=$(srcdir)/../gnulib-lib/malloca.valgrind --num-callers=20 
--leak-check=yes --leak-resolution=high --show-reachable=yes
#CHECKER = valgrind --tool=massif --format=html --depth=10 --alloc-fn=xmalloc 
--alloc-fn=xrealloc --stacks=no

TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) \
                    
PATH=.:../src:../../gettext-runtime/src:$(top_srcdir)/../gettext-runtime/src:$$PATH
 \
                    GETTEXT="$(CHECKER) tstgettext" \
                    NGETTEXT="$(CHECKER) tstngettext" \
                    XGETTEXT="$(CHECKER) xgettext" \
                    MSGATTRIB="$(CHECKER) msgattrib" \
                    MSGCAT="$(CHECKER) msgcat" \
                    MSGCMP="$(CHECKER) msgcmp" \
                    MSGCOMM="$(CHECKER) msgcomm" \
                    MSGCONV="$(CHECKER) msgconv" \
                    MSGEN="$(CHECKER) msgen" \
                    MSGEXEC="$(CHECKER) msgexec" \
                    MSGFILTER="$(CHECKER) msgfilter" \
                    MSGFMT="$(CHECKER) msgfmt" \
                    MSGGREP="$(CHECKER) msggrep" \
                    MSGINIT="$(CHECKER) msginit" \
                    MSGMERGE="$(CHECKER) msgmerge" \
                    MSGUNFMT="$(CHECKER) msgunfmt" \
                    MSGUNIQ="$(CHECKER) msguniq" \
                    ...

This idiom has the effect that:
  - Use of valgrind is turned off by default.
    I think that's the right setting, because
      1. tests running with valgrind consume much more time that without.
      2. some tests may fail due to bugs in valgrind. For example, valgrind
         built for 32-bit failed miserably when run with 64-bit binaries on
         x86 bi-arch systems.
  - The user can enable it by changing 2 characters in the Makefile.
  - The user does not have to remember the recommended options
    (--alloc-fn=xmalloc etc.).
  - The user has the choice among multiple valgrind tools.
  - Shell invocations are not checked by valgrind, only the invocations
    of the programs that are meant to be tested.

Bruno



reply via email to

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