Created
May 9, 2025 14:04
-
-
Save Crypt-iQ/da15d24d5a6a05264bd24268199c89c3 to your computer and use it in GitHub Desktop.
fuzz coverage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Copy this file to the root of the bitcoin core folder, it accepts one argument that tells us what fuzz test to measure coverage for. | |
| # Configure the build directory, note that -fuse-ld=lld isn't needed here | |
| rm -rf build | |
| cmake -B build -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DAPPEND_CFLAGS="-fprofile-instr-generate -fcoverage-mapping" -DAPPEND_CXXFLAGS="-fprofile-instr-generate -fcoverage-mapping" -DAPPEND_LDFLAGS="-fprofile-instr-generate -fcoverage-mapping" -DBUILD_FOR_FUZZING=ON | |
| cmake --build build -j8 | |
| mkdir -p build/raw_profile_data | |
| # Copy over the file from qa-assets. TODO: Make this configurable. | |
| mkdir -p corpus-qa | |
| cp -r ../qa-assets/fuzz_corpora/"$1"/ corpus-qa/ | |
| LLVM_PROFILE_FILE="$(pwd)/build/raw_profile_data/%m_%p.profraw" FUZZ="$1" build/bin/fuzz corpus-qa | |
| find build/raw_profile_data -name "*.profraw" | xargs /opt/homebrew/Cellar/llvm@18/18.1.8/bin/llvm-profdata merge -o build/coverage.profdata | |
| /opt/homebrew/Cellar/llvm@18/18.1.8/bin/llvm-cov show --object=build/bin/fuzz -Xdemangler=/opt/homebrew/Cellar/llvm@18/18.1.8/bin/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="fuzzcov" | |
| open build/coverage_report/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment