Next: , Previous: manywarnings, Up: Particular Modules


13.19 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 valgrind-tests module searches for Valgrind and declares the VALGRIND automake variable for use with automake's TESTS_ENVIRONMENT.

After importing the valgrind-tests module to your project, you use it by adding the following to the Makefile.am that runs the self-tests:

     TESTS_ENVIRONMENT = $(VALGRIND)

This will run all self-checks under valgrind. This can be wasteful if you have many shell scripts or other non-binaries. Using the Automake parallel-tests feature, this can be avoided by using the following instead:

     AUTOMAKE_OPTIONS = parallel-tests
     TEST_EXTENSIONS = .pl .sh
     LOG_COMPILER = $(VALGRIND)

Then valgrind will only be used for the non-.sh and non-.pl tests. However, this means that binaries invoked through scripts will not be invoked under valgrind, which could be solved by adding the following:

     TESTS_ENVIRONMENT = VALGRIND='$(VALGRIND)'

And then modify the shell scripts to invoke the binary prefixed with $VALGRIND.