diff --git a/src/test/fuzz/CMakeLists.txt b/src/test/fuzz/CMakeLists.txt index d11aa70b8..5715e3c66 100644 --- a/src/test/fuzz/CMakeLists.txt +++ b/src/test/fuzz/CMakeLists.txt @@ -1,146 +1,155 @@ # Fuzzer test harness add_custom_target(bitcoin-fuzzers) +define_property(GLOBAL + PROPERTY FUZZ_TARGETS + BRIEF_DOCS "List of fuzz targets" + FULL_DOCS "A list of the fuzz targets" +) +set_property(GLOBAL APPEND PROPERTY FUZZ_TARGETS bitcoin-fuzzers) + macro(add_fuzz_target TARGET EXE_NAME) add_executable(${TARGET} EXCLUDE_FROM_ALL fuzz.cpp ${ARGN} ) set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${EXE_NAME}) target_link_libraries(${TARGET} server testutil) add_dependencies(bitcoin-fuzzers ${TARGET}) + + set_property(GLOBAL APPEND PROPERTY FUZZ_TARGETS ${TARGET}) endmacro() function(add_regular_fuzz_targets) foreach(_fuzz_test_name ${ARGN}) sanitize_target_name("fuzz-" ${_fuzz_test_name} _fuzz_target_name) add_fuzz_target( ${_fuzz_target_name} ${_fuzz_test_name} # Sources "${_fuzz_test_name}.cpp" ) endforeach() endfunction() include(SanitizeHelper) function(add_deserialize_fuzz_targets) foreach(_fuzz_test_name ${ARGN}) sanitize_target_name("fuzz-" ${_fuzz_test_name} _fuzz_target_name) add_fuzz_target( ${_fuzz_target_name} ${_fuzz_test_name} # Sources deserialize.cpp ) sanitize_c_cxx_definition("" ${_fuzz_test_name} _target_definition) string(TOUPPER ${_target_definition} _target_definition) target_compile_definitions(${_fuzz_target_name} PRIVATE ${_target_definition}) endforeach() endfunction() function(add_process_message_fuzz_targets) foreach(_fuzz_test_name ${ARGN}) sanitize_target_name("fuzz-process_message_" ${_fuzz_test_name} _fuzz_target_name) add_fuzz_target( ${_fuzz_target_name} process_message_${_fuzz_test_name} # Sources process_message.cpp ) target_compile_definitions(${_fuzz_target_name} PRIVATE MESSAGE_TYPE=${_fuzz_test_name}) endforeach() endfunction() add_regular_fuzz_targets( addrdb bloom_filter rolling_bloom_filter cashaddr descriptor_parse eval_script net_permissions parse_iso8601 process_message psbt script script_flags spanparsing strprintf timedata transaction ) add_deserialize_fuzz_targets( addr_info_deserialize address_deserialize addrman_deserialize banentry_deserialize block_deserialize block_file_info_deserialize block_filter_deserialize block_header_and_short_txids_deserialize blockheader_deserialize blocklocator_deserialize blockmerkleroot blocktransactions_deserialize blocktransactionsrequest_deserialize blockundo_deserialize bloomfilter_deserialize coins_deserialize diskblockindex_deserialize fee_rate_deserialize flat_file_pos_deserialize inv_deserialize key_origin_info_deserialize merkle_block_deserialize messageheader_deserialize netaddr_deserialize out_point_deserialize partial_merkle_tree_deserialize partially_signed_transaction_deserialize prefilled_transaction_deserialize psbt_input_deserialize psbt_output_deserialize pub_key_deserialize script_deserialize service_deserialize sub_net_deserialize tx_in_deserialize txoutcompressor_deserialize txundo_deserialize ) add_process_message_fuzz_targets( addr block blocktxn cmpctblock feefilter filteradd filterclear filterload getaddr getblocks getblocktxn getdata getheaders headers inv mempool notfound ping pong sendcmpct sendheaders tx verack version ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5db925899..f8e346a05 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,137 +1,145 @@ ### # Create config.ini file for tests ### if("fuzzer" IN_LIST ENABLE_SANITIZERS) set(ENABLE_FUZZ ON) else() set(ENABLE_FUZZ OFF) endif() # Create build ini file configure_file(config.ini.cmake.in config.ini) ### # Setup symlinks for testing ### include(SanitizeHelper) function(make_link file) set(src "${CMAKE_CURRENT_SOURCE_DIR}/${file}") set(dest "${CMAKE_CURRENT_BINARY_DIR}/${file}") # Create the target directory and parents if needed. get_filename_component(dest_dir "${dest}" DIRECTORY) file(MAKE_DIRECTORY "${dest_dir}") add_custom_command( OUTPUT "${dest}" COMMAND ${CMAKE_COMMAND} -E create_symlink "${src}" "${dest}" COMMENT "link ${file}" MAIN_DEPENDENCY "${src}" ) # Add a phony target to make sure the files are linked by default. sanitize_target_name("link-" "${file}" NAME) add_custom_target(${NAME} ALL DEPENDS "${dest}") + + foreach(PARENT_TARGET ${ARGN}) + if(TARGET ${PARENT_TARGET}) + add_dependencies(${PARENT_TARGET} ${NAME}) + endif() + endforeach() endfunction() make_link(functional/test_runner.py) make_link(util/bitcoin-util-test.py) make_link(util/rpcauth-test.py) -make_link(fuzz/test_runner.py) + +get_property(FUZZ_TARGETS GLOBAL PROPERTY FUZZ_TARGETS) +make_link(fuzz/test_runner.py ${FUZZ_TARGETS}) include(Coverage) include(TestSuite) set(_TEST_TARGET_DEPENDS "") if(BUILD_BITCOIN_CLI) list(APPEND _TEST_TARGET_DEPENDS bitcoin-cli) endif() if(BUILD_BITCOIN_WALLET) list(APPEND _TEST_TARGET_DEPENDS bitcoin-wallet) endif() function(add_functional_test_check TARGET DESCRIPTION) if(ENABLE_JUNIT_REPORT) string(REGEX REPLACE " " "_" JUNIT_FILE "${DESCRIPTION}.xml") set(JUNIT_OUTPUT "--junitoutput=${JUNIT_REPORT_DIRECTORY}/${JUNIT_FILE}") endif() add_test_custom_target(${TARGET} TEST_COMMAND "${Python_EXECUTABLE}" ./functional/test_runner.py "--testsuitename=Bitcoin ABC ${DESCRIPTION}" ${JUNIT_OUTPUT} ${ARGN} CUSTOM_TARGET_ARGS COMMENT "Running ${DESCRIPTION}" DEPENDS bitcoind ${_TEST_TARGET_DEPENDS} ${CMAKE_CURRENT_BINARY_DIR}/functional/test_runner.py USES_TERMINAL VERBATIM ) add_custom_target_coverage(${TARGET}) endfunction() add_functional_test_check(check-functional "functional tests" ) add_dependencies(check-all check-functional) add_functional_test_check(check-functional-extended "extended functional tests" --extended ) add_dependencies(check-extended check-functional-extended) add_functional_test_check(check-functional-upgrade-activated "functional tests with the next upgrade activated" --with-axionactivation ) add_dependencies(check-upgrade-activated check-functional-upgrade-activated) add_functional_test_check(check-functional-upgrade-activated-extended "extended functional tests with the next upgrade activated" --extended --with-axionactivation ) add_dependencies(check-upgrade-activated-extended check-functional-upgrade-activated-extended) if(BUILD_BITCOIN_TX) add_test_custom_target(check-bitcoin-util TEST_COMMAND "${Python_EXECUTABLE}" ./util/bitcoin-util-test.py CUSTOM_TARGET_ARGS COMMENT "Test Bitcoin utilities..." DEPENDS bitcoin-tx ${CMAKE_CURRENT_BINARY_DIR}/util/bitcoin-util-test.py ) add_dependencies(check check-bitcoin-util) endif() add_custom_target(check-rpcauth COMMENT "Test Bitcoin RPC authentication..." COMMAND "${Python_EXECUTABLE}" ./util/rpcauth-test.py DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/util/rpcauth-test.py ) add_dependencies(check check-rpcauth) include(PackageHelper) exclude_from_source_package( # Subdirectories "cache/" "lint/" "sanitizer_suppressions/" ) set_property(DIRECTORY "${CMAKE_SOURCE_DIR}" APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/cache")