CMakeLists.txt raw
1 # Copyright (c) 2023-present The Limenka 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_limenka
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 bech32_tests.cpp
19 bip32_tests.cpp
20 bip324_tests.cpp
21 blockchain_tests.cpp
22 blockencodings_tests.cpp
23 blockfilter_index_tests.cpp
24 blockfilter_tests.cpp
25 blockmanager_tests.cpp
26 bloom_tests.cpp
27 bswap_tests.cpp
28 bulletproof_tests.cpp
29 caches_tests.cpp
30 chainstate_write_tests.cpp
31 checkqueue_tests.cpp
32 cluster_linearize_tests.cpp
33 codex32_tests.cpp
34 coins_tests.cpp
35 coinscachepair_tests.cpp
36 coinstatsindex_tests.cpp
37 common_url_tests.cpp
38 compilerbug_tests.cpp
39 compress_tests.cpp
40 crypto_tests.cpp
41 ct_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 flatfile_tests.cpp
49 fork_block_tests.cpp
50 fork_chain_tests.cpp
51 fork_interval_tests.cpp
52 fork_pid_tests.cpp
53 fs_tests.cpp
54 getarg_tests.cpp
55 hash_tests.cpp
56 headers_sync_chainwork_tests.cpp
57 httpserver_tests.cpp
58 i2p_tests.cpp
59 interfaces_tests.cpp
60 key_io_tests.cpp
61 key_tests.cpp
62 logging_tests.cpp
63 mempool_tests.cpp
64 merkle_tests.cpp
65 merkleblock_tests.cpp
66 miner_tests.cpp
67 miniminer_tests.cpp
68 miniscript_tests.cpp
69 multisig_tests.cpp
70 net_peer_connection_tests.cpp
71 net_peer_eviction_tests.cpp
72 net_tests.cpp
73 netbase_tests.cpp
74 node_warnings_tests.cpp
75 orphanage_tests.cpp
76 p2spkh_tests.cpp
77 pcp_tests.cpp
78 peerman_tests.cpp
79 psbt_tests.cpp
80 pmt_tests.cpp
81 policy_fee_tests.cpp
82 policyestimator_tests.cpp
83 pool_tests.cpp
84 pow_tests.cpp
85 prevector_tests.cpp
86 raii_event_tests.cpp
87 random_tests.cpp
88 rbf_tests.cpp
89 rest_tests.cpp
90 result_tests.cpp
91 reverselock_tests.cpp
92 rpc_tests.cpp
93 sanity_tests.cpp
94 scheduler_tests.cpp
95 script_p2sh_tests.cpp
96 script_parse_tests.cpp
97 script_segwit_tests.cpp
98 script_standard_tests.cpp
99 script_tests.cpp
100 scriptnum_tests.cpp
101 serfloat_tests.cpp
102 serialize_tests.cpp
103 settings_tests.cpp
104 sighash_tests.cpp
105 sigopcount_tests.cpp
106 skiplist_tests.cpp
107 sock_tests.cpp
108 span_tests.cpp
109 streams_tests.cpp
110 sync_tests.cpp
111 system_ram_tests.cpp
112 system_tests.cpp
113 timeoffsets_tests.cpp
114 torcontrol_tests.cpp
115 transaction_tests.cpp
116 translation_tests.cpp
117 txdownload_tests.cpp
118 txindex_tests.cpp
119 txpackage_tests.cpp
120 txreconciliation_tests.cpp
121 txrequest_tests.cpp
122 txvalidation_tests.cpp
123 txvalidationcache_tests.cpp
124 uint256_tests.cpp
125 util_string_tests.cpp
126 util_tests.cpp
127 util_threadnames_tests.cpp
128 util_trace_tests.cpp
129 validation_block_tests.cpp
130 validation_chainstate_tests.cpp
131 validation_chainstatemanager_tests.cpp
132 validation_flush_tests.cpp
133 validation_tests.cpp
134 validationinterface_tests.cpp
135 versionbits_tests.cpp
136 ../stats/test/stats_tests.cpp
137 )
138
139 include(TargetDataSources)
140 target_json_data_sources(test_limenka
141 data/base58_encode_decode.json
142 data/bip341_wallet_vectors.json
143 data/blockfilters.json
144 data/key_io_invalid.json
145 data/key_io_valid.json
146 data/script_tests.json
147 data/sighash.json
148 data/tx_invalid.json
149 data/tx_valid.json
150 )
151 target_raw_data_sources(test_limenka NAMESPACE test::data
152 data/asmap.raw
153 )
154
155 target_link_libraries(test_limenka
156 core_interface
157 test_util
158 $<TARGET_NAME_IF_EXISTS:limenkaconsensus>
159 limenka_cli
160 limenka_node
161 limenka_consensus
162 secp256k1
163 Boost::headers
164 libevent::extra
165 )
166
167 if(ENABLE_WALLET)
168 add_subdirectory(${PROJECT_SOURCE_DIR}/src/wallet/test wallet)
169 endif()
170
171 if(WITH_MULTIPROCESS)
172 target_link_libraries(limenka_ipc_test
173 PRIVATE
174 core_interface
175 univalue
176 )
177
178 target_sources(test_limenka
179 PRIVATE
180 ipc_tests.cpp
181 )
182 target_link_libraries(test_limenka limenka_ipc_test limenka_ipc)
183 endif()
184
185 function(add_boost_test source_file)
186 if(NOT EXISTS ${source_file})
187 return()
188 endif()
189
190 file(READ "${source_file}" source_file_content)
191 string(REGEX
192 MATCH "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(([A-Za-z0-9_]+)"
193 test_suite_macro "${source_file_content}"
194 )
195 string(REGEX
196 REPLACE "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(" ""
197 test_suite_name "${test_suite_macro}"
198 )
199 if(test_suite_name)
200 add_test(NAME ${test_suite_name}
201 COMMAND test_limenka --run_test=${test_suite_name} --catch_system_error=no --log_level=test_suite -- DEBUG_LOG_OUT
202 )
203 set_property(TEST ${test_suite_name} PROPERTY
204 SKIP_REGULAR_EXPRESSION "no test cases matching filter"
205 )
206 endif()
207 endfunction()
208
209 function(add_all_test_targets)
210 get_target_property(test_source_dir test_limenka SOURCE_DIR)
211 get_target_property(test_sources test_limenka SOURCES)
212 foreach(test_source ${test_sources})
213 cmake_path(IS_RELATIVE test_source result)
214 if(result)
215 cmake_path(APPEND test_source_dir ${test_source} OUTPUT_VARIABLE test_source)
216 endif()
217 add_boost_test(${test_source})
218 endforeach()
219 endfunction()
220
221 add_all_test_targets()
222
223 make_liblimenkaconsensus_dll_available(test_limenka)
224 install_binary_component(test_limenka)
225