I suggest you guys check out the parallel-tests driver from recent
Automake. It provides makefile variables for specifying a command
to run specific tests, plus options to that. That can be used for
valgrind.
Quoting the documentation:
For tests that match an extension `.EXT' listed in
`TEST_EXTENSIONS', you can provide a test driver using the variable
`EXT_LOG_COMPILER' (note the upper-case extension) and pass options in
`AM_EXT_LOG_FLAGS' and allow the user to pass options in
`EXT_LOG_FLAGS'. It will cause all tests with this extension to be
called with this driver. For all tests without a registered extension,
the variables `LOG_COMPILER', `AM_LOG_FLAGS', and `LOG_FLAGS' may be
used. For example,
TESTS = foo.pl bar.py baz
TEST_EXTENSIONS = .pl .py
PL_LOG_COMPILER = $(PERL)
AM_PL_LOG_FLAGS = -w
PY_LOG_COMPILER = $(PYTHON)
AM_PY_LOG_FLAGS = -v
LOG_COMPILER = ./wrapper-script
AM_LOG_FLAGS = -d
will invoke `$(PERL) -w foo.pl', `$(PYTHON) -v bar.py', and
`./wrapper-script -d baz' to produce `foo.log', `bar.log', and
`baz.log', respectively. The `TESTS_ENVIRONMENT' variable is still
expanded before the driver, but should be reserved for the user.
Cheers,
Ralf