af_alg: Pacify --enable-gcc-warnings
[gnulib.git] / doc / valgrind-tests.texi
blobec3720214a60b85be50eac382e40869c7ab3c9a0
1 @node Running self-tests under valgrind
2 @section Running self-tests under valgrind
4 For projects written in C or similar languages, running the self-tests
5 under Valgrind can reveal hard to find memory issues.  The
6 @code{valgrind-tests} module searches for Valgrind and declares the
7 @code{VALGRIND} automake variable for use with automake's
8 @code{TESTS_ENVIRONMENT}.
10 After importing the @code{valgrind-tests} module to your project, you
11 use it by adding the following to the @code{Makefile.am} that runs the
12 self-tests:
14 @smallexample
15 TESTS_ENVIRONMENT = $(VALGRIND)
16 @end smallexample
18 This will run all self-checks under valgrind.  This can be wasteful if
19 you have many shell scripts or other non-binaries.  Using the Automake
20 parallel-tests feature, this can be avoided by using the following
21 instead:
23 @smallexample
24 AUTOMAKE_OPTIONS = parallel-tests
25 TEST_EXTENSIONS = .pl .sh
26 LOG_COMPILER = $(VALGRIND)
27 @end smallexample
29 Then valgrind will only be used for the non-.sh and non-.pl tests.
30 However, this means that binaries invoked through scripts will not be
31 invoked under valgrind, which could be solved by adding the following:
33 @smallexample
34 TESTS_ENVIRONMENT = VALGRIND='$(VALGRIND)'
35 @end smallexample
37 And then modify the shell scripts to invoke the binary prefixed with
38 @code{$VALGRIND}.