cmake: Add Coverage and CoverageFuzz scripts

This commit is contained in:
Hennadii Stepanov
2024-08-05 13:16:58 +01:00
parent 65bdbc1ff2
commit 8b6f1c4353
7 changed files with 212 additions and 7 deletions

View File

@ -476,25 +476,34 @@ $ ./test/functional/test_runner.py --valgrind
### Compiling for test coverage
LCOV can be used to generate a test coverage report based upon `make check`
LCOV can be used to generate a test coverage report based upon `ctest`
execution. LCOV must be installed on your system (e.g. the `lcov` package
on Debian/Ubuntu).
To enable LCOV report generation during test runs:
```shell
./configure --enable-lcov
make
make cov
cmake -B build -DCMAKE_BUILD_TYPE=Coverage
cmake --build build
cmake -P build/Coverage.cmake
# A coverage report will now be accessible at `./test_bitcoin.coverage/index.html`,
# which covers unit tests, and `./total.coverage/index.html`, which covers
# A coverage report will now be accessible at `./build/test_bitcoin.coverage/index.html`,
# which covers unit tests, and `./build/total.coverage/index.html`, which covers
# unit and functional tests.
```
Additional LCOV options can be specified using `LCOV_OPTS`, but may be dependent
on the version of LCOV. For example, when using LCOV `2.x`, branch coverage can be
enabled by setting `LCOV_OPTS="--rc branch_coverage=1"`, when configuring.
enabled by setting `LCOV_OPTS="--rc branch_coverage=1"`:
```
cmake -DLCOV_OPTS="--rc branch_coverage=1" -P build/Coverage.cmake
```
To enable test parallelism:
```
cmake -DJOBS=$(nproc) -P build/Coverage.cmake
```
### Performance profiling with perf