The latest auto-generated LCOV report for trunk is at <>. This is for the C++ unit tests using the googletest framework.

The latest py-coverage report for trunk for the Python tests is at <>.

TODO: auto-generate the lcov reports for the higher level tests


LCOV is a front-end around gcov, the GCC code coverage tool. It collects the gcov data and creates HTML webpages showing coverage rates using bar graphs and specific colors. It can also create webpages for browsing the source code.

LCOV is available at

gcov is the test coverage program included with GCC.

LCOV Steps

The following are example steps for using gcov/lcov.

First build using GCC's gcov support. The .gcno files will be generated at compile time. For example:

./configure CPPFLAGS="-fprofile-arcs -ftest-coverage" LIBS="-lgcov"


Then use LCOV to generate the code coverage report. The .gcda files will be created when the binaries built with gcc code coverage support are ran.

# Removes the old gcov data files (.gcda)
lcov --directory . --zerocounters

# Run the code so the gcov data files (.gcda) are generated. For example:
make check

# Make empty .gcda files for each existing .gcno file.
# This is so report will show 0.0% for missing tests.
# This step is not needed.
find . -name "*.gcno" | while read line ; do
  gcda=`echo $line | sed 's/\.gcno$/.gcda/'` ;
  if [ \! -e $gcda ]  ; then
    touch $gcda && echo created empty $gcda;
  fi ;

# Generate the lcov trace file.
lcov --capture --directory . --output-file

# Remove old generate webpages.
rm -rf coverage/

# Remove files not needed in the report.
# Adjust this as needed.
lcov  --remove /usr/pkg/include/gtest/* /usr/pkg/include/gtest/internal/gtest-* \
 /usr/pkg/gcc44/include/c++/4.4.1/backward/binders.h /usr/pkg/gcc44/include/c++/4.4.1/bits/* \
 /usr/pkg/gcc44/include/c++/4.4.1/ext/*.h \
 /usr/pkg/gcc44/include/c++/4.4.1/x86_64-unknown-netbsd4.99.62/bits/gthr-default.h \
 /usr/include/machine/byte_swap.h /usr/pkg/gcc44/include/c++/4.4.1/* \

# Generate the HTML webpages from the final lcov trace file.
genhtml -o coverage 

Use --gcov-tool /path/to/bin/gcov for lcov if gcc used to build has different gcov.

Last modified 6 years ago Last modified on Jul 14, 2011, 4:58:08 PM