From e82cc0699082716155cfa403442ab0d7b39a915d Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:35:10 +0000 Subject: [PATCH] cmake: Add `fuzz_coverage` target --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad69ce2e38db8..bb8ee7709b3ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -428,6 +428,20 @@ if(BUILD_FOR_COVERAGE) DEPENDS ${PROJECT_BINARY_DIR}/total.coverage/index.html ) add_dependencies(total_coverage test_bitcoin_coverage) + else() + if(NOT FUZZ_CORPORA_DIR) + set(FUZZ_CORPORA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qa-assets/fuzz_corpora) + endif() + add_custom_command( + OUTPUT ${PROJECT_BINARY_DIR}/fuzz.coverage/index.html + COMMAND Python3::Interpreter test/fuzz/test_runner.py ${FUZZ_CORPORA_DIR} --loglevel DEBUG + COMMAND llvm-profdata merge --instr ${PROFILE_DATA_DIR}/*.profraw --output ${PROFILE_DATA_DIR}/fuzz.profdata + COMMAND llvm-cov show -instr-profile=${PROFILE_DATA_DIR}/fuzz.profdata -object=$ -output-dir=${PROJECT_BINARY_DIR}/fuzz.coverage -format=html ${coverage_ignore_paths} + DEPENDS fuzz + ) + add_custom_target(fuzz_coverage + DEPENDS ${PROJECT_BINARY_DIR}/fuzz.coverage/index.html + ) endif() endif()