Hi. We're trying to use LCOV to analyze test coverage in our packages,
which make heavy use of GNU autotools, but I'm having some problems.
We usually keep our source files in $srcdir/src, and build from
$srcdir/build. The loop we run in $builddir for lcov looks like this:
for test in $TESTS; do
lcov --zerocounters --directory . --quiet ./$test
lcov --capture --directory . --output-file $test-info.lcov \
--test-name "$test (check)" --quiet
genhtml *.lcov --output-directory=$LCOVOUT
But it gives the following problem:
../src/base64.c:cannot open source file
../src/md5.c:cannot open source file
../src/aux.c:cannot open source file
And so on, but all these files exist and the path is correct.
ERROR: cannot open [path]/package/build/src/base64.c
There is no "package/build/src". The source is at "package/src", and
it's compiled at "package/build". I tried the following workaround in
-e "/^SF:/s;$abs_builddir;$abs_srcdir;" # removes build/
-e "/^SF:/s;[^/]*/\.\./\?;;g" # removes '..' from path
This fixes SF:[path]/package/build/src to SF:[path]/package/src. But
it still says the "cannot open source file", and another problem
ERROR: checksum mismatch at [path]/package/src/base64.c:67
None of these problems appear if we call lcov from a build directory
outside package/, but this would be too cumbersome for us. I can't find
out what's happening, since I don't know perl. Any ideas? What am I
doing wrong? :)
From: Peter Oberparleiter <oberpapr@so...> - 2005-01-21 10:14:40
it seems that the build setup you are using is confusing the GCOV tool.
Leonardo Boiko wrote:
> ../src/base64.c:cannot open source file
> ../src/md5.c:cannot open source file
> ../src/aux.c:cannot open source file
These error messages are generated by the GCOV tool which is the basis
for LCOV. For debugging purposes, please run the test loop once
- go to the build directory (don't change it afterwards)
- perform the lcov --zerocounters statement
- perform a test
- use the gcov tool on one of the executables, i.e. gcov test
If this fails, then it means that the current working directory during
compilation is not the same as the current working directory during the
call to GCOV. In that case, it's not possible for GCOV to find the
correct place for the source files specified through a relative path.
As a workaround, you would need to specify absolute paths wherever possible.
> ERROR: checksum mismatch at [path]/package/src/base64.c:67
This is due to the fact that GCOV didn't find the source for this file.
You could hack the process by specifying --no-checksum as option to the
lcov --capture line.
Hope this helps.