mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge bitcoin/bitcoin#32206: doc: Add fuzz based coverage report generation
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Windows native, VS 2022 (push) Waiting to run
CI / Windows native, fuzz, VS 2022 (push) Waiting to run
CI / Linux->Windows cross, no tests (push) Waiting to run
CI / Windows, test cross-built (push) Blocked by required conditions
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Windows native, VS 2022 (push) Waiting to run
CI / Windows native, fuzz, VS 2022 (push) Waiting to run
CI / Linux->Windows cross, no tests (push) Waiting to run
CI / Windows, test cross-built (push) Blocked by required conditions
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
7677fde4c7
Add fuzz test coverage report generation (Prabhat Verma) Pull request description: Followup from [comment 1 31933](https://github.com/bitcoin/bitcoin/pull/31933#pullrequestreview-2685168897) and [comment 2 31933](https://github.com/bitcoin/bitcoin/pull/31933#pullrequestreview-2683653107) , have added the instructions to generate coverage report for fuzz tests. ACKs for top commit: maflcko: lgtm ACK7677fde4c7
mabu44: Tested ACK7677fde4c7
Tree-SHA512: b4883ec41e272443fc9fc97dce3fb0f05871ce5ddc07d97f4cf7e1d28506dc892324b42005387a2f5a844b27827785a68d10881067414fe93fd4fbb9645f765d
This commit is contained in:
commit
bb92bb36f2
1 changed files with 41 additions and 0 deletions
|
@ -575,6 +575,47 @@ llvm-cov show \
|
||||||
|
|
||||||
The generated coverage report can be accessed at `build/coverage_report/index.html`.
|
The generated coverage report can be accessed at `build/coverage_report/index.html`.
|
||||||
|
|
||||||
|
#### Compiling for Fuzz Coverage
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cmake -B build \
|
||||||
|
-DCMAKE_C_COMPILER="clang" \
|
||||||
|
-DCMAKE_CXX_COMPILER="clang++" \
|
||||||
|
-DCMAKE_C_FLAGS="-fprofile-instr-generate -fcoverage-mapping" \
|
||||||
|
-DCMAKE_CXX_FLAGS="-fprofile-instr-generate -fcoverage-mapping" \
|
||||||
|
-DBUILD_FOR_FUZZING=ON
|
||||||
|
cmake --build build # Use "-j N" here for N parallel jobs.
|
||||||
|
```
|
||||||
|
|
||||||
|
Running fuzz tests with one or more targets
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# For single target run with the target of choice
|
||||||
|
LLVM_PROFILE_FILE="$(pwd)/build/raw_profile_data/txorphan.profraw" ./build/test/fuzz/test_runner.py ../qa-assets/fuzz_corpora txorphan
|
||||||
|
# If running for multiple targets
|
||||||
|
LLVM_PROFILE_FILE="$(pwd)/build/raw_profile_data/%m_%p.profraw" ./build/test/fuzz/test_runner.py ../qa-assets/fuzz_corpora
|
||||||
|
# Merge profiles
|
||||||
|
llvm-profdata merge build/raw_profile_data/*.profraw -o build/coverage.profdata
|
||||||
|
```
|
||||||
|
|
||||||
|
Generate report:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
llvm-cov show \
|
||||||
|
--object=build/bin/fuzz \
|
||||||
|
-Xdemangler=llvm-cxxfilt \
|
||||||
|
--instr-profile=build/coverage.profdata \
|
||||||
|
--ignore-filename-regex="src/crc32c/|src/leveldb/|src/minisketch/|src/secp256k1/|src/test/" \
|
||||||
|
--format=html \
|
||||||
|
--show-instantiation-summary \
|
||||||
|
--show-line-counts-or-regions \
|
||||||
|
--show-expansions \
|
||||||
|
--output-dir=build/coverage_report \
|
||||||
|
--project-title="Bitcoin Core Fuzz Coverage Report"
|
||||||
|
```
|
||||||
|
|
||||||
|
The generated coverage report can be accessed at `build/coverage_report/index.html`.
|
||||||
|
|
||||||
### Performance profiling with perf
|
### Performance profiling with perf
|
||||||
|
|
||||||
Profiling is a good way to get a precise idea of where time is being spent in
|
Profiling is a good way to get a precise idea of where time is being spent in
|
||||||
|
|
Loading…
Add table
Reference in a new issue