CMakeLists.txt raw

   1  # Copyright (c) 2023-present The Bitcoin Core developers
   2  # Distributed under the MIT software license, see the accompanying
   3  # file COPYING or https://opensource.org/license/mit/.
   4  
   5  # Do not use generator expressions in test sources because the
   6  # SOURCES property is processed to gather test suite macros.
   7  add_executable(test_bitcoin
   8    main.cpp
   9    addrman_tests.cpp
  10    allocator_tests.cpp
  11    amount_tests.cpp
  12    argsman_tests.cpp
  13    arith_uint256_tests.cpp
  14    banman_tests.cpp
  15    base32_tests.cpp
  16    base58_tests.cpp
  17    base64_tests.cpp
  18    baseindex_tests.cpp
  19    bech32_tests.cpp
  20    bip32_tests.cpp
  21    bip324_tests.cpp
  22    blockchain_tests.cpp
  23    blockencodings_tests.cpp
  24    blockfilter_index_tests.cpp
  25    blockfilter_tests.cpp
  26    blockmanager_tests.cpp
  27    bloom_tests.cpp
  28    bswap_tests.cpp
  29    btcsignals_tests.cpp
  30    caches_tests.cpp
  31    chain_tests.cpp
  32    chainstate_write_tests.cpp
  33    checkqueue_tests.cpp
  34    cluster_linearize_tests.cpp
  35    coins_tests.cpp
  36    coinscachepair_tests.cpp
  37    coinstatsindex_tests.cpp
  38    coinsviewoverlay_tests.cpp
  39    common_url_tests.cpp
  40    compress_tests.cpp
  41    crypto_tests.cpp
  42    cuckoocache_tests.cpp
  43    dbwrapper_tests.cpp
  44    denialofservice_tests.cpp
  45    descriptor_tests.cpp
  46    disconnected_transactions.cpp
  47    feefrac_tests.cpp
  48    feerounder_tests.cpp
  49    flatfile_tests.cpp
  50    fs_tests.cpp
  51    getarg_tests.cpp
  52    hash_tests.cpp
  53    headers_sync_chainwork_tests.cpp
  54    httpserver_tests.cpp
  55    i2p_tests.cpp
  56    interfaces_tests.cpp
  57    key_io_tests.cpp
  58    key_tests.cpp
  59    logging_tests.cpp
  60    mempool_tests.cpp
  61    merkle_tests.cpp
  62    merkleblock_tests.cpp
  63    miner_tests.cpp
  64    miniminer_tests.cpp
  65    miniscript_tests.cpp
  66    minisketch_tests.cpp
  67    multisig_tests.cpp
  68    bip328_tests.cpp
  69    net_peer_connection_tests.cpp
  70    net_peer_eviction_tests.cpp
  71    net_tests.cpp
  72    netbase_tests.cpp
  73    node_init_tests.cpp
  74    node_warnings_tests.cpp
  75    orphanage_tests.cpp
  76    pcp_tests.cpp
  77    peerman_tests.cpp
  78    pmt_tests.cpp
  79    policyestimator_tests.cpp
  80    pool_tests.cpp
  81    pow_tests.cpp
  82    prevector_tests.cpp
  83    private_broadcast_tests.cpp
  84    psbt_tests.cpp
  85    random_tests.cpp
  86    rbf_tests.cpp
  87    rest_tests.cpp
  88    result_tests.cpp
  89    reverselock_tests.cpp
  90    rpc_tests.cpp
  91    sanity_tests.cpp
  92    scheduler_tests.cpp
  93    script_assets_tests.cpp
  94    script_p2sh_tests.cpp
  95    script_parse_tests.cpp
  96    script_segwit_tests.cpp
  97    script_standard_tests.cpp
  98    script_tests.cpp
  99    scriptnum_tests.cpp
 100    serfloat_tests.cpp
 101    serialize_tests.cpp
 102    settings_tests.cpp
 103    sighash_tests.cpp
 104    sigopcount_tests.cpp
 105    skiplist_tests.cpp
 106    sock_tests.cpp
 107    span_tests.cpp
 108    streams_tests.cpp
 109    sync_tests.cpp
 110    system_ram_tests.cpp
 111    system_tests.cpp
 112    testnet4_miner_tests.cpp
 113    threadpool_tests.cpp
 114    timeoffsets_tests.cpp
 115    torcontrol_tests.cpp
 116    transaction_tests.cpp
 117    translation_tests.cpp
 118    txdownload_tests.cpp
 119    txgraph_tests.cpp
 120    txindex_tests.cpp
 121    txospenderindex_tests.cpp
 122    txpackage_tests.cpp
 123    txreconciliation_tests.cpp
 124    txrequest_tests.cpp
 125    txvalidation_tests.cpp
 126    txvalidationcache_tests.cpp
 127    uint256_tests.cpp
 128    util_check_tests.cpp
 129    util_expected_tests.cpp
 130    util_string_tests.cpp
 131    util_tests.cpp
 132    util_threadnames_tests.cpp
 133    util_trace_tests.cpp
 134    validation_block_tests.cpp
 135    validation_chainstate_tests.cpp
 136    validation_chainstatemanager_tests.cpp
 137    validation_flush_tests.cpp
 138    validation_tests.cpp
 139    validationinterface_tests.cpp
 140    versionbits_tests.cpp
 141  )
 142  
 143  include(TargetDataSources)
 144  target_json_data_sources(test_bitcoin
 145    data/base58_encode_decode.json
 146    data/bip341_wallet_vectors.json
 147    data/blockfilters.json
 148    data/key_io_invalid.json
 149    data/key_io_valid.json
 150    data/script_tests.json
 151    data/sighash.json
 152    data/tx_invalid.json
 153    data/tx_valid.json
 154  )
 155  target_raw_data_sources(test_bitcoin NAMESPACE test::data
 156    data/asmap.raw
 157  )
 158  
 159  add_windows_application_manifest(test_bitcoin)
 160  
 161  target_link_libraries(test_bitcoin
 162    core_interface
 163    test_util
 164    bitcoin_cli
 165    bitcoin_node
 166    bitcoin_consensus
 167    minisketch
 168    secp256k1
 169    Boost::headers
 170    $<TARGET_NAME_IF_EXISTS:USDT::headers>
 171  )
 172  
 173  if(ENABLE_WALLET)
 174    add_subdirectory(${PROJECT_SOURCE_DIR}/src/wallet/test wallet)
 175  endif()
 176  
 177  if(ENABLE_IPC)
 178    add_subdirectory(${PROJECT_SOURCE_DIR}/src/ipc/test ipc)
 179  endif()
 180  
 181  function(add_boost_test source_file)
 182    if(NOT EXISTS ${source_file})
 183      return()
 184    endif()
 185  
 186    file(READ "${source_file}" source_file_content)
 187    string(REGEX
 188      MATCHALL "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(([A-Za-z0-9_]+)"
 189      test_suite_macro "${source_file_content}"
 190    )
 191    list(TRANSFORM test_suite_macro
 192      REPLACE "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(" ""
 193    )
 194    foreach(test_suite_name IN LISTS test_suite_macro)
 195      add_test(NAME ${test_suite_name}
 196        COMMAND test_bitcoin --run_test=${test_suite_name} --catch_system_error=no --log_level=test_suite -- -printtoconsole=1
 197      )
 198      set_property(TEST ${test_suite_name} PROPERTY
 199        SKIP_REGULAR_EXPRESSION
 200          "no test cases matching filter"
 201          "skipping script_assets_test"
 202          "skipping total_ram"
 203      )
 204    endforeach()
 205  endfunction()
 206  
 207  function(add_all_test_targets)
 208    get_target_property(test_source_dir test_bitcoin SOURCE_DIR)
 209    get_target_property(test_sources test_bitcoin SOURCES)
 210    foreach(test_source ${test_sources})
 211      cmake_path(IS_RELATIVE test_source result)
 212      if(result)
 213        cmake_path(APPEND test_source_dir ${test_source} OUTPUT_VARIABLE test_source)
 214      endif()
 215      add_boost_test(${test_source})
 216    endforeach()
 217  endfunction()
 218  
 219  add_all_test_targets()
 220  
 221  install_binary_component(test_bitcoin INTERNAL)
 222