[Fedora-packaging] proposed "should" requirement: clean "make check" run w/valgrind

Jim Meyering meyering at redhat.com
Sat Nov 4 12:49:55 UTC 2006


Jesse Keating <jkeating at redhat.com> wrote:
> On Friday 03 November 2006 15:22, Jim Meyering wrote:
>> It is not onerous to require this, because it is so easy to automate.
>> In addition to running tests via "make check", each package can also
>> run its tests via e.g.,
>>
>>   env "PATH=/some/new/temp/dir:$PATH" make check 3> log
>>
>> where the temporary directory, /some/new/temp/dir, contains one or
>> more tiny wrapper scripts, each arranging to run a tested application
>> via valgrind.  Here's one named "rm" that I've used in testing that
>> program for the GNU coreutils:
>>
>> #!/bin/sh
>> export PATH=/cu/src:/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 -- rm "$@"
>
> Is there any way to make this easier?  A wrapper around everything perhaps?
> Something that could be done in mock?

Yes, I think so.
The idea is to create this temporary directory,
populate it with a 4-line script (like the above) for each
binary that is built by the package under test.
That's the easy part, since in mock, you'll know the build
dir, which needs to be first in PATH, above.

The harder part is to arrange for that temporary directory to
be at the front of the PATH used for "make check".
In coreutils, I ended up changing e.g., tests/rm/Makefile.am from this

    TESTS_ENVIRONMENT = \
      PATH="`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
      ...

to this:

    TESTS_ENVIRONMENT = \
      PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
      ...

so I can build normally, or set VG_PATH_PREFIX=/tmp/T:
to run things through  valgrind:  (where /tmp/T is the
temp. directory containing all of those just-generated scripts)

    VG_PATH_PREFIX=/tmp/T: make check

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:

    #!/bin/sh
    export PATH=@BUILD_DIR@:/sbin:/usr/sbin:/bin
    prog=${0##*/}
    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.




More information about the Fedora-packaging mailing list