forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: Build
test_bitcoin
executable
- Loading branch information
Showing
6 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) 2023 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
function(generate_header_from_json json_source_relpath) | ||
add_custom_command( | ||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${json_source_relpath}.h | ||
COMMAND ${CMAKE_COMMAND} -DJSON_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${json_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR}/${json_source_relpath}.h -P ${CMAKE_SOURCE_DIR}/cmake/script/GenerateHeaderFromJson.cmake | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${json_source_relpath} | ||
VERBATIM | ||
) | ||
endfunction() | ||
|
||
function(generate_header_from_raw raw_source_relpath) | ||
add_custom_command( | ||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${raw_source_relpath}.h | ||
COMMAND ${CMAKE_COMMAND} -DRAW_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${raw_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR}/${raw_source_relpath}.h -P ${CMAKE_SOURCE_DIR}/cmake/script/GenerateHeaderFromRaw.cmake | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${raw_source_relpath} | ||
VERBATIM | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) 2023 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
file(READ ${JSON_SOURCE_PATH} hex_content HEX) | ||
string(REGEX MATCHALL "([A-Za-z0-9][A-Za-z0-9])" bytes "${hex_content}") | ||
|
||
file(WRITE ${HEADER_PATH} "namespace json_tests{\n") | ||
get_filename_component(json_source_basename ${JSON_SOURCE_PATH} NAME_WE) | ||
file(APPEND ${HEADER_PATH} "static unsigned const char ${json_source_basename}[] = {\n") | ||
|
||
set(i 0) | ||
foreach(byte ${bytes}) | ||
math(EXPR i "${i} + 1") | ||
math(EXPR remainder "${i} % 8") | ||
if(remainder EQUAL 0) | ||
file(APPEND ${HEADER_PATH} "0x${byte},\n") | ||
else() | ||
file(APPEND ${HEADER_PATH} "0x${byte}, ") | ||
endif() | ||
endforeach() | ||
|
||
file(APPEND ${HEADER_PATH} "\n};};") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) 2023 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
file(READ ${RAW_SOURCE_PATH} hex_content HEX) | ||
string(REGEX MATCHALL "([A-Za-z0-9][A-Za-z0-9])" bytes "${hex_content}") | ||
|
||
get_filename_component(raw_source_basename ${RAW_SOURCE_PATH} NAME_WE) | ||
file(WRITE ${HEADER_PATH} "static unsigned const char ${raw_source_basename}_raw[] = {\n") | ||
|
||
set(i 0) | ||
foreach(byte ${bytes}) | ||
math(EXPR i "${i} + 1") | ||
math(EXPR remainder "${i} % 8") | ||
if(remainder EQUAL 0) | ||
file(APPEND ${HEADER_PATH} "0x${byte},\n") | ||
else() | ||
file(APPEND ${HEADER_PATH} "0x${byte}, ") | ||
endif() | ||
endforeach() | ||
|
||
file(APPEND ${HEADER_PATH} "\n};") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
# Copyright (c) 2023 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
include(GenerateHeaders) | ||
generate_header_from_json(data/base58_encode_decode.json) | ||
generate_header_from_json(data/bip341_wallet_vectors.json) | ||
generate_header_from_json(data/blockfilters.json) | ||
generate_header_from_json(data/key_io_invalid.json) | ||
generate_header_from_json(data/key_io_valid.json) | ||
generate_header_from_json(data/script_tests.json) | ||
generate_header_from_json(data/sighash.json) | ||
generate_header_from_json(data/tx_invalid.json) | ||
generate_header_from_json(data/tx_valid.json) | ||
generate_header_from_raw(data/asmap.raw) | ||
|
||
add_executable(test_bitcoin | ||
main.cpp | ||
$<TARGET_OBJECTS:bitcoin_consensus> | ||
${CMAKE_CURRENT_BINARY_DIR}/data/asmap.raw.h | ||
${CMAKE_CURRENT_BINARY_DIR}/data/base58_encode_decode.json.h | ||
${CMAKE_CURRENT_BINARY_DIR}/data/bip341_wallet_vectors.json.h | ||
${CMAKE_CURRENT_BINARY_DIR}/data/blockfilters.json.h | ||
${CMAKE_CURRENT_BINARY_DIR}/data/key_io_invalid.json.h | ||
${CMAKE_CURRENT_BINARY_DIR}/data/key_io_valid.json.h | ||
${CMAKE_CURRENT_BINARY_DIR}/data/script_tests.json.h | ||
${CMAKE_CURRENT_BINARY_DIR}/data/sighash.json.h | ||
${CMAKE_CURRENT_BINARY_DIR}/data/tx_invalid.json.h | ||
${CMAKE_CURRENT_BINARY_DIR}/data/tx_valid.json.h | ||
# Tests: | ||
addrman_tests.cpp | ||
allocator_tests.cpp | ||
amount_tests.cpp | ||
argsman_tests.cpp | ||
arith_uint256_tests.cpp | ||
banman_tests.cpp | ||
base32_tests.cpp | ||
base58_tests.cpp | ||
base64_tests.cpp | ||
bech32_tests.cpp | ||
bip32_tests.cpp | ||
blockchain_tests.cpp | ||
blockencodings_tests.cpp | ||
blockfilter_index_tests.cpp | ||
blockfilter_tests.cpp | ||
blockmanager_tests.cpp | ||
bloom_tests.cpp | ||
bswap_tests.cpp | ||
checkqueue_tests.cpp | ||
coins_tests.cpp | ||
coinstatsindex_tests.cpp | ||
compress_tests.cpp | ||
compilerbug_tests.cpp | ||
crypto_tests.cpp | ||
cuckoocache_tests.cpp | ||
dbwrapper_tests.cpp | ||
denialofservice_tests.cpp | ||
descriptor_tests.cpp | ||
flatfile_tests.cpp | ||
fs_tests.cpp | ||
getarg_tests.cpp | ||
hash_tests.cpp | ||
headers_sync_chainwork_tests.cpp | ||
httpserver_tests.cpp | ||
i2p_tests.cpp | ||
interfaces_tests.cpp | ||
key_io_tests.cpp | ||
key_tests.cpp | ||
logging_tests.cpp | ||
mempool_tests.cpp | ||
merkleblock_tests.cpp | ||
merkle_tests.cpp | ||
miner_tests.cpp | ||
miniscript_tests.cpp | ||
minisketch_tests.cpp | ||
multisig_tests.cpp | ||
netbase_tests.cpp | ||
net_peer_eviction_tests.cpp | ||
net_tests.cpp | ||
orphanage_tests.cpp | ||
pmt_tests.cpp | ||
policy_fee_tests.cpp | ||
policyestimator_tests.cpp | ||
pool_tests.cpp | ||
pow_tests.cpp | ||
prevector_tests.cpp | ||
raii_event_tests.cpp | ||
random_tests.cpp | ||
rbf_tests.cpp | ||
rest_tests.cpp | ||
result_tests.cpp | ||
reverselock_tests.cpp | ||
rpc_tests.cpp | ||
sanity_tests.cpp | ||
scheduler_tests.cpp | ||
scriptnum_tests.cpp | ||
script_p2sh_tests.cpp | ||
script_parse_tests.cpp | ||
script_segwit_tests.cpp | ||
script_standard_tests.cpp | ||
script_tests.cpp | ||
serfloat_tests.cpp | ||
serialize_tests.cpp | ||
settings_tests.cpp | ||
sighash_tests.cpp | ||
sigopcount_tests.cpp | ||
skiplist_tests.cpp | ||
sock_tests.cpp | ||
streams_tests.cpp | ||
sync_tests.cpp | ||
system_tests.cpp | ||
timedata_tests.cpp | ||
torcontrol_tests.cpp | ||
transaction_tests.cpp | ||
translation_tests.cpp | ||
txindex_tests.cpp | ||
txpackage_tests.cpp | ||
txreconciliation_tests.cpp | ||
txrequest_tests.cpp | ||
txvalidationcache_tests.cpp | ||
txvalidation_tests.cpp | ||
uint256_tests.cpp | ||
util_tests.cpp | ||
util_threadnames_tests.cpp | ||
validation_block_tests.cpp | ||
validation_chainstate_tests.cpp | ||
validation_chainstatemanager_tests.cpp | ||
validation_flush_tests.cpp | ||
validation_tests.cpp | ||
validationinterface_tests.cpp | ||
versionbits_tests.cpp | ||
xoroshiro128plusplus_tests.cpp | ||
) | ||
|
||
target_link_libraries(test_bitcoin | ||
test_util | ||
bitcoin_cli | ||
bitcoin_node | ||
bitcoin_common | ||
bitcoin_util | ||
minisketch | ||
leveldb | ||
univalue | ||
Boost::headers | ||
libevent::libevent | ||
) | ||
|
||
if(ENABLE_WALLET) | ||
target_sources(test_bitcoin | ||
PRIVATE | ||
../wallet/test/coinselector_tests.cpp | ||
../wallet/test/init_test_fixture.cpp | ||
../wallet/test/init_tests.cpp | ||
../wallet/test/ismine_tests.cpp | ||
../wallet/test/psbt_wallet_tests.cpp | ||
../wallet/test/rpc_util_tests.cpp | ||
../wallet/test/scriptpubkeyman_tests.cpp | ||
../wallet/test/spend_tests.cpp | ||
../wallet/test/wallet_crypto_tests.cpp | ||
../wallet/test/wallet_test_fixture.cpp | ||
../wallet/test/wallet_tests.cpp | ||
../wallet/test/wallet_transaction_tests.cpp | ||
../wallet/test/walletdb_tests.cpp | ||
../wallet/test/walletload_tests.cpp | ||
) | ||
target_link_libraries(test_bitcoin bitcoin_wallet) | ||
if(USE_BDB) | ||
target_sources(test_bitcoin PRIVATE ../wallet/test/db_tests.cpp) | ||
endif() | ||
endif() |