The gcov
-based code coverage does not work with Clang (please refer to #31047 for more details).
This PR employs the LLVM’s Source-based Code Coverage.
Here are some examples of usage:
0cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_FOR_COVERAGE=ON
1cmake --build build --target total_coverage
2firefox build/test_bitcoin.coverage/index.html
or
0cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_FOR_COVERAGE=ON
1cmake --build build --target total_coverage
2firefox build/total.coverage/index.html
or
0cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_FOR_COVERAGE=ON -DBUILD_FOR_FUZZING=ON
1cmake --build build --target fuzz_coverage
2firefox 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:
0warning: 502 functions have mismatched data
are quite concerning.
Also see a discussion in https://github.com/hebasto/bitcoin/pull/233.