[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: coreutils test coverage
From: |
Daniel Dunbar |
Subject: |
Re: coreutils test coverage |
Date: |
Tue, 29 Apr 2008 15:26:45 -0700 (PDT) |
Hi,
> How cool!
>
> That's a really useful tool. I wonder if it might be possible to
> include some instructions for producing a coverage report like that in
> the project somewhere... maybe in the HACKING file?
It is fairly straightforward, although lcov has some quirks resolving path
names which I haven't really looked into. I have also noticed it get very
unhappy
if stray .gcov files are lying around, but haven't debugged this issue.
Here is the process I use for generating those results. First, generate the
coverage information:
--
# configure with coverage information
./configure CFLAGS="-g -fprofile-arcs -ftest-coverage"
make
# run whatever tests you want, i.e.:
make check
--
Second, generate lcov output. I use the following unpolished script, which
takes an
optional argument for keeping separate .info files (lcov's internal parsing of
the gcov data)
and output -html directories. The script expects to be run from the top level
coreutils
directory so that the lcov genhtml script resolves pathnames appropriately.
--
#!/bin/sh
if [ address@hidden -eq 0 ]; then
PREFIX="lcov"
elif [ address@hidden -eq 1 ]; then
PREFIX="$1"
else
echo "Usage: $0 [prefix]"
exit 1
fi
# prevent stray gcov files
find . -name '*.gcov' | xargs rm -f
rm -rf $PREFIX-*.info $PREFIX-html
if (! lcov -t coreutils -q -d lib -b lib -o $PREFIX-lib.info -c); then
echo "ERROR: lcov failed"
exit 1
fi
if (! lcov -t coreutils -q -d src -b src -o $PREFIX-src.info -c); then
echo "ERROR: lcov failed"
exit 1
fi
genhtml -p `pwd` -t coreutils -q --output-directory $PREFIX-html
$PREFIX-lib.info $PREFIX-src.info
--
I also have an additional script which munges the lcov output to make the tables
sortable but this is pretty gross. When I get a chance I would prefer to push
this
back to lcov as an extra option, although if you really want it I can pass it
on.
- Daniel