install-reloc: Support multi-binary installation.
[gnulib.git] / doc / valgrind-tests.texi
1 @node Running self-tests under valgrind
2 @section Running self-tests under valgrind
3
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}.
9
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:
13
14 @smallexample
15 TESTS_ENVIRONMENT = $(VALGRIND)
16 @end smallexample
17
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:
22
23 @smallexample
24 AUTOMAKE_OPTIONS = parallel-tests
25 TEST_EXTENSIONS = .pl .sh
26 LOG_COMPILER = $(VALGRIND)
27 @end smallexample
28
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:
32
33 @smallexample
34 TESTS_ENVIRONMENT = VALGRIND='$(VALGRIND)'
35 @end smallexample
36
37 And then modify the shell scripts to invoke the binary prefixed with
38 @code{$VALGRIND}.