Skip to content

Test Coverage

Todd Oliver edited this page Nov 19, 2022 · 2 revisions

As of PR #188, TPS can generate coverage metrics for the test suite.

Dependencies

The coverage metrics are generated by gcov and gcovr. gcov is a standard part of the GCC suite. gcovr is a python package (see https://gcovr.com/en/stable/ and https://github.com/gcovr/gcovr). It is included in the TPS test container or can be installed via pip install gcovr for working outside the container.

Procedure

To generate data for coverage analysis, it is necessary to build using --coverage. To detect the necessary tools and add this flag, the --enable-coverage configure option is provided. To generate coverage information, do the following:

  1. Configure with --enable-coverage
$ mkdir build
$ ./bootstrap
$ cd build
$ ../configure CXXFLAGS="-g -O2 -Wall" --enable-coverage
  1. Build TPS as usual
$ make
  1. Build the coverage target
$ make coverage

The coverage target will run the test suite (via make check) and then run gcovr to generate coverage statistics. If you are interested in examining the coverage from only a subset of the tests, for example just cyl3d.test, use

$ make coverage TESTS="cyl3d.test"
  1. Examine the results, which are available as html in <tps-build-dir>/coverage/html/gcovr-report.html
Clone this wiki locally