[Fedora-packaging] proposed "should" requirement: clean "make check" run w/valgrind
meyering at redhat.com
Sat Nov 4 14:38:52 UTC 2006
Jesse Keating <jkeating at redhat.com> wrote:
> On Saturday 04 November 2006 07:49, Jim Meyering wrote:
>> I've just realized there's a better way to write the script above.
>> Just compute the name of the program under test from the name of
>> the script:
>> export PATH=@BUILD_DIR@:/sbin:/usr/sbin:/bin
>> exec /usr/bin/valgrind -v --suppressions=/tmp/cu-vg --log-fd=3 \
>> --leak-check=full --track-fds=yes --num-callers=15 -- "$prog" "$@"
>> Now, the only variable is the part marked with @BUILD_DIR at .
>> Oh. Also the suppressions file name.
> Wouldn't the reviewer/packager still have to know every binary name produced
> and write a script for each? Is there no easier way?
In automake-based packages, the list of binary program names
is often in the $(bin_PROGRAMS) makefile variable.
Knowing that, it should be easy to create the temporary
directory and populate it with one copy of the above script
for each name. IMHO, that part is not hard.
Here's a Bourne shell snippet to extract the names of programs from a
coreutils build directory in which you've already run configure:
coreutils=$(echo 'spy:;@echo $(all_programs)' | (cd src; make -f Makefile -f - spy | tr -s '\n ' ' '))
The part that will usually require manual intervention is
the one where you arrange for the PATH used by "make check"
(or whatever else runs their test suite) to have that temporary
directory first. This part is probably manual by definition,
since any test suite must first ensure that PATH has the build
directory before any other -- so it can test what's just been
built. Now, we want some other directory to be first, so
have to make that PATH setting be conditional on whether we're
trying to test via valgrind or not.
Hey! Maybe there *is* an easier way.
Instead of presuming we have to leave just-built binaries
where the build process put them, we could replace each
with the little valgrind-invoking wrapper script, and
move the original binary into a subdirectory.
The only drawback is that once you've replaced the binary
with the wrapper script, any attempt to do e.g., "make install"
will do the wrong thing. But even that isn't a problem: just
be sure to run "make clean" after the tests -- or simply remove
all of those scripts.
For example, move each binary "down" one level, into say, .vg-tmp,
then put a copy of this script in its place:
exec /usr/bin/valgrind -v --suppressions=/tmp/cu-vg \
--leak-check=full --track-fds=yes --num-callers=15 -- "$prog" "$@"
Then, there's no need to modify Makefiles at all.
I've changed to --log-file-exactly=/tmp/vg-log above, so that
you don't have to redirect fd-3 -- that would have been too easy
to forget, and when you do, the diagnostic is too cryptic.
More information about the Fedora-packaging