Skip to content

[POC] cmake: Introduce LLVM's Source-based Code Coverage reports

The gcov-based code coverage does not work with Clang (please refer to https://github.com/bitcoin/bitcoin/issues/31047 for more details).

This PR employs the LLVM's Source-based Code Coverage.

Here are some examples of usage:

cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_FOR_COVERAGE=ON
cmake --build build --target total_coverage
firefox build/test_bitcoin.coverage/index.html

or

cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_FOR_COVERAGE=ON
cmake --build build --target total_coverage
firefox build/total.coverage/index.html

or

cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_FOR_COVERAGE=ON -DBUILD_FOR_FUZZING=ON
cmake --build build --target fuzz_coverage
firefox build/fuzz.coverage/index.html

As a proof of concept, the new targets still lack the ability to customize llvm-cov options.

I haven't yet assessed the quality of the resulting coverage reports. However, messages like this:

warning: 502 functions have mismatched data

are quite concerning.


Also see a discussion in https://github.com/hebasto/bitcoin/pull/233.

Merge request reports

Loading