fuzzing.yml: Start producing code coverage report

This commit is contained in:
Sebastian Pipping 2025-02-14 18:32:02 +01:00
parent deb5af9954
commit 39d2ebb467

View file

@ -87,7 +87,7 @@ jobs:
# Tune compilation of fuzzers to use Clang with ASan and UBSan
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_{C,CXX}_FLAGS='-Wall -Wextra -pedantic -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -fno-common'
-DCMAKE_{C,CXX}_FLAGS='-Wall -Wextra -pedantic -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -fno-common -fprofile-instr-generate -fcoverage-mapping'
-DCMAKE_{EXE,MODULE,SHARED}_LINKER_FLAGS='-g -fsanitize=address,undefined'
-DEXPAT_WARNINGS_AS_ERRORS=ON
)
@ -119,6 +119,9 @@ jobs:
set -x -o pipefail
cd expat/build/
mkdir coverage/
export LLVM_PROFILE_FILE=coverage/expat-%p.profraw
# vvvvv
find corpus_UTF-8/ -type f | sort | xargs \
fuzz/xml_parse_fuzzer_UTF-8 "${fuzz_args[@]}"
@ -134,3 +137,25 @@ jobs:
name: expat_fuzzing_logs_${{ github.sha }}
path: expat/build/fuzz-*.log
if-no-files-found: error
- name: Render coverage report
run: |
fuzzer=xml_parse_fuzzer_UTF-8 # could be any of them
set -x -o pipefail
cd expat/build/
# Merged and convert to a single indexed profile data file
llvm-profdata merge -sparse -o coverage/expat.profdata coverage/expat-*.profraw
# Render report
llvm-cov show fuzz/${fuzzer} -instr-profile=coverage/expat.profdata -show-branches=count -format=html -output-dir=coverage/html/
llvm-cov report fuzz/${fuzzer} -instr-profile=coverage/expat.profdata -show-functions -sources ../lib/ | tee coverage/report_functions.txt
llvm-cov report fuzz/${fuzzer} -instr-profile=coverage/expat.profdata -sources ../lib/ | tee coverage/report_files.txt
- name: Store coverage report
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: expat_fuzzing_coverage_${{ github.sha }}
path: expat/build/coverage/
if-no-files-found: error