This document shows how to get the code coverage of OE. The code coverage analysis is based on Gcov, a source-based coverage implementation provided by GNU GCC.
Note: While Gcov works with Clang and GCC, only Clang is currently supported for Linux builds
Install the packages that are necessary for the offline analysis.
sudo apt install lcov python python-pip llvm-7
sudo pip install lcov_cobertura
Variable | Description |
---|---|
CODE_COVERAGE | Enable code coverage when setting to ON. Default is OFF. |
BUILD_LIBGCOV | Build the libgcov only when setting to ON. Note that this option is only effective when CODE_COVERAGE is OFF. |
To get the code coverage of the OE core libraries given the existing test suite, run the following commands from the build subfolder.
cmake .. -DCODE_COVERAGE=ON
make
ctest
make code_coverage
This command parses the runtime Gcov data of the test run and generates the reports.
The exapmle command line output is as follows.
Writing data to cov_filtered.info
Summary coverage rate:
lines......: 63.0% (10318 of 16372 lines)
functions..: 76.8% (774 of 1008 functions)
branches...: 40.3% (4679 of 11603 branches)
Built target code_coverage
The reports can be found in build/coverage/coverage.xml
(cobertura) and build/coverage/cov_filtered.info
(lcov).
After a bors run on a PR, developers can view the code coverage report on the PR.
Click on "Details" to drill into the code coverage report.