Re: proposed "should" requirement: clean "make check" run w/valgrind

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jesse Keating <jkeating@xxxxxxxxxx> 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@.
Oh.  Also the suppressions file name.

--
Fedora-packaging mailing list
Fedora-packaging@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-packaging

[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite Forum]     [KDE Users]

  Powered by Linux