|  | 
|  | 1 | +# Copyright (c) 2023 The Bitcoin Core developers | 
|  | 2 | +# Distributed under the MIT software license, see the accompanying | 
|  | 3 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. | 
|  | 4 | + | 
|  | 5 | +include(CTest) | 
|  | 6 | + | 
|  | 7 | +if(TARGET bitcoin-util AND TARGET bitcoin-tx) | 
|  | 8 | +  add_test(NAME util_test_runner | 
|  | 9 | +    COMMAND ${CMAKE_COMMAND} -E env BITCOINUTIL=$<TARGET_FILE:bitcoin-util> BITCOINTX=$<TARGET_FILE:bitcoin-tx> ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR}/test/util/test_runner.py | 
|  | 10 | +  ) | 
|  | 11 | +endif() | 
|  | 12 | + | 
|  | 13 | +add_test(NAME util_rpcauth_test | 
|  | 14 | +  COMMAND ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR}/test/util/rpcauth-test.py | 
|  | 15 | +) | 
|  | 16 | + | 
|  | 17 | +if(TARGET bench_bitcoin) | 
|  | 18 | +  add_test(NAME bench_sanity_check_high_priority | 
|  | 19 | +    COMMAND bench_bitcoin -sanity-check -priority-level=high | 
|  | 20 | +  ) | 
|  | 21 | +endif() | 
|  | 22 | + | 
|  | 23 | +if(TARGET test_bitcoin) | 
|  | 24 | +  function(add_boost_test source_dir source_file) | 
|  | 25 | +    set(source_file_path ${source_dir}/${source_file}) | 
|  | 26 | +    if(NOT EXISTS ${source_file_path}) | 
|  | 27 | +      return() | 
|  | 28 | +    endif() | 
|  | 29 | + | 
|  | 30 | +    file(READ "${source_file_path}" source_file_content) | 
|  | 31 | +    string(REGEX | 
|  | 32 | +      MATCH "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(([A-Za-z0-9_]+)" | 
|  | 33 | +      test_suite_macro "${source_file_content}" | 
|  | 34 | +    ) | 
|  | 35 | +    string(REGEX | 
|  | 36 | +      REPLACE "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(" "" | 
|  | 37 | +      test_suite_name "${test_suite_macro}" | 
|  | 38 | +    ) | 
|  | 39 | +    if(test_suite_name) | 
|  | 40 | +      add_test(NAME ${test_suite_name}:${source_file} | 
|  | 41 | +        COMMAND test_bitcoin --run_test=${test_suite_name} --catch_system_error=no | 
|  | 42 | +      ) | 
|  | 43 | +    endif() | 
|  | 44 | +  endfunction() | 
|  | 45 | + | 
|  | 46 | +  function(add_all_test_targets) | 
|  | 47 | +    get_target_property(test_source_dir test_bitcoin SOURCE_DIR) | 
|  | 48 | +    get_target_property(test_sources test_bitcoin SOURCES) | 
|  | 49 | +    foreach(test_source ${test_sources}) | 
|  | 50 | +      add_boost_test(${test_source_dir} ${test_source}) | 
|  | 51 | +    endforeach() | 
|  | 52 | +  endfunction() | 
|  | 53 | + | 
|  | 54 | +  add_all_test_targets() | 
|  | 55 | +endif() | 
0 commit comments