Skip to content

Commit

Permalink
Merge #226: cmake, test: Enable running individual functional tests
Browse files Browse the repository at this point in the history
7e94254 qa: Do not assume running `feature_asmap.py` from source directory (Hennadii Stepanov)
1ec9926 qa: Consider `cache` and `config.ini` relative to invocation directory (Hennadii Stepanov)
ca1f7b8 fixup! cmake: Add test config and runners (Hennadii Stepanov)

Pull request description:

  Resolves #146.

  > It should be possible to run all functional tests directly.

  Done.

  > Furthermore, these should be symlinked as making changes to the test in the source directory should result in the executed test also changing without needing a rebuild.

  Done.

  > For example, trying to run `test/functional/wallet_basic.py` from the build dir is not possible.

  Works as expected now.

Top commit has no ACKs.

Tree-SHA512: 624fbfe5a5892c60c044e05694c53cd6727e412846a4f6950eb90eb4769de3fc671ca235dca65fa4b9478c7eea3864bcb419b23c239a2eb980f6f098d357d197
  • Loading branch information
hebasto committed Jun 11, 2024
2 parents 8ce80b9 + 7e94254 commit 8975005
Show file tree
Hide file tree
Showing 247 changed files with 260 additions and 260 deletions.
15 changes: 7 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/functional)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fuzz)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/util)

function(create_test_script script)
if(MSVC)
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/${script} ${CMAKE_CURRENT_BINARY_DIR}/${script} COPY_ON_ERROR)
file(GLOB_RECURSE functional_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} functional/*)
foreach(script ${functional_tests} fuzz/test_runner.py util/rpcauth-test.py util/test_runner.py)
if(CMAKE_HOST_WIN32)
set(symlink)
else()
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/${script} ${CMAKE_CURRENT_BINARY_DIR}/${script} COPY_ON_ERROR SYMBOLIC)
set(symlink SYMBOLIC)
endif()
endfunction()

foreach(script functional/test_runner.py fuzz/test_runner.py util/rpcauth-test.py util/test_runner.py)
create_test_script(${script})
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/${script} ${CMAKE_CURRENT_BINARY_DIR}/${script} COPY_ON_ERROR ${symlink})
endforeach()
unset(functional_tests)
2 changes: 1 addition & 1 deletion test/functional/create_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def run_test(self):
pass

if __name__ == '__main__':
CreateCache().main()
CreateCache(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/example_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,4 @@ def run_test(self):


if __name__ == '__main__':
ExampleTest().main()
ExampleTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_abortnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def run_test(self):


if __name__ == '__main__':
AbortNodeTest().main()
AbortNodeTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_addrman.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ def run_test(self):


if __name__ == "__main__":
AddrmanTest().main()
AddrmanTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_anchors.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ def run_test(self):


if __name__ == "__main__":
AnchorsTest().main()
AnchorsTest(__file__).main()
7 changes: 4 additions & 3 deletions test/functional/feature_asmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from test_framework.util import assert_equal

DEFAULT_ASMAP_FILENAME = 'ip_asn.map' # defined in src/init.cpp
ASMAP = '../../src/test/data/asmap.raw' # path to unit test skeleton asmap
ASMAP = 'src/test/data/asmap.raw' # path to unit test skeleton asmap
VERSION = 'fec61fa21a9f46f3b17bdcd660d7f4cd90b966aad3aec593c99b35f0aca15853'

def expected_messages(filename):
Expand Down Expand Up @@ -133,7 +133,8 @@ def run_test(self):
self.node = self.nodes[0]
self.datadir = self.node.chain_path
self.default_asmap = os.path.join(self.datadir, DEFAULT_ASMAP_FILENAME)
self.asmap_raw = os.path.join(os.path.dirname(os.path.realpath(__file__)), ASMAP)
base_dir = self.config["environment"]["SRCDIR"]
self.asmap_raw = os.path.join(base_dir, ASMAP)

self.test_without_asmap_arg()
self.test_asmap_with_absolute_path()
Expand All @@ -146,4 +147,4 @@ def run_test(self):


if __name__ == '__main__':
AsmapTest().main()
AsmapTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,4 @@ class Block:
chain_tx: int

if __name__ == '__main__':
AssumeutxoTest().main()
AssumeutxoTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_assumevalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ def run_test(self):


if __name__ == '__main__':
AssumeValidTest().main()
AssumeValidTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_bind_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ def run_test(self):
self.log.info(f"Stopped node {i}")

if __name__ == '__main__':
BindExtraTest().main()
BindExtraTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_bind_port_discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ def run_test(self):
assert found_addr1

if __name__ == '__main__':
BindPortDiscoverTest().main()
BindPortDiscoverTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_bind_port_externalip.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ def run_test(self):
assert found

if __name__ == '__main__':
BindPortExternalIPTest().main()
BindPortExternalIPTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_bip68_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,4 @@ def test_version2_relay(self):


if __name__ == '__main__':
BIP68Test().main()
BIP68Test(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,4 +1435,4 @@ def send_blocks(self, blocks, success=True, reject_reason=None, force_send=False


if __name__ == '__main__':
FullBlockTest().main()
FullBlockTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_blocksdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ def run_test(self):


if __name__ == '__main__':
BlocksdirTest().main()
BlocksdirTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_cltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ def run_test(self):


if __name__ == '__main__':
BIP65Test().main()
BIP65Test(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_coinstatsindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,4 @@ def _test_init_index_after_reorg(self):


if __name__ == '__main__':
CoinStatsIndexTest().main()
CoinStatsIndexTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_config_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,4 @@ def run_test(self):


if __name__ == '__main__':
ConfArgsTest().main()
ConfArgsTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_csv_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,4 @@ def run_test(self):


if __name__ == '__main__':
BIP68_112_113Test().main()
BIP68_112_113Test(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_dbcrash.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,4 @@ def run_test(self):


if __name__ == "__main__":
ChainstateWriteCrashTest().main()
ChainstateWriteCrashTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_dersig.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ def run_test(self):


if __name__ == '__main__':
BIP66Test().main()
BIP66Test(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_dirsymlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def run_test(self):


if __name__ == "__main__":
SymlinkTest().main()
SymlinkTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ def run_test(self):


if __name__ == '__main__':
DiscoverTest().main()
DiscoverTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_fastprune.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def run_test(self):


if __name__ == '__main__':
FeatureFastpruneTest().main()
FeatureFastpruneTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_fee_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,4 @@ def run_test(self):


if __name__ == "__main__":
EstimateFeeTest().main()
EstimateFeeTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ def check_wallet_filelock(descriptors):
check_wallet_filelock(True)

if __name__ == '__main__':
FilelockTest().main()
FilelockTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ def run_test(self):


if __name__ == '__main__':
HelpTest().main()
HelpTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_includeconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ def run_test(self):
assert subversion.endswith("main; relative; relative2)/")

if __name__ == '__main__':
IncludeConfTest().main()
IncludeConfTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_index_prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ def run_test(self):


if __name__ == '__main__':
FeatureIndexPruneTest().main()
FeatureIndexPruneTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ def check_clean_start():


if __name__ == '__main__':
InitStressTest().main()
InitStressTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_loadblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ def run_test(self):


if __name__ == '__main__':
LoadblockTest().main()
LoadblockTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ def run_test(self):


if __name__ == '__main__':
LoggingTest().main()
LoggingTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_maxtipage.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ def run_test(self):


if __name__ == '__main__':
MaxTipAgeTest().main()
MaxTipAgeTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_maxuploadtarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,4 @@ def run_test(self):
self.nodes[0].assert_start_raises_init_error(extra_args=["-maxuploadtarget=abc"], expected_msg="Error: Unable to parse -maxuploadtarget: 'abc'")

if __name__ == '__main__':
MaxUploadTest().main()
MaxUploadTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_minchainwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ def run_test(self):


if __name__ == '__main__':
MinimumChainWorkTest().main()
MinimumChainWorkTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ def expect_wallet_notify(self, tx_details):


if __name__ == '__main__':
NotificationsTest().main()
NotificationsTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_nulldummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ def block_submit(self, node, txs, *, with_witness=False, accept):


if __name__ == '__main__':
NULLDUMMYTest().main()
NULLDUMMYTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_posix_fs_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def run_test(self):


if __name__ == '__main__':
PosixFsPermissionsTest().main()
PosixFsPermissionsTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_presegwit_node_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ def run_test(self):


if __name__ == '__main__':
SegwitUpgradeTest().main()
SegwitUpgradeTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,4 @@ def networks_dict(d):
os.unlink(socket_path)

if __name__ == '__main__':
ProxyTest().main()
ProxyTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_pruning.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,4 @@ def test_scanblocks_pruned(self):
"start", [{"desc": f"raw({false_positive_spk.hex()})"}], 0, 0, "basic", {"filter_false_positives": True})

if __name__ == '__main__':
PruneTest().main()
PruneTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_rbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,4 +727,4 @@ def test_fullrbf(self):
assert conflicting_tx['txid'] in self.nodes[0].getrawmempool()

if __name__ == '__main__':
ReplaceByFeeTest().main()
ReplaceByFeeTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ def run_test(self):


if __name__ == '__main__':
ReindexTest().main()
ReindexTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_reindex_readonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ def run_test(self):


if __name__ == '__main__':
BlockstoreReindexTest().main()
BlockstoreReindexTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_remove_pruned_files_on_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ def run_test(self):
assert not os.path.exists(rev1)

if __name__ == '__main__':
FeatureRemovePrunedFilesOnStartupTest().main()
FeatureRemovePrunedFilesOnStartupTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_segwit.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,4 +657,4 @@ def create_and_mine_tx_from_txids(self, txids, success=True):


if __name__ == '__main__':
SegWitTest().main()
SegWitTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ def run_test(self):


if __name__ == '__main__':
SettingsTest().main()
SettingsTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def run_test(self):
self.stop_node(0, wait=1000)

if __name__ == '__main__':
ShutdownTest().main()
ShutdownTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_signet.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ def run_test(self):


if __name__ == '__main__':
SignetBasicTest().main()
SignetBasicTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_startupnotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ def get_count():


if __name__ == '__main__':
StartupNotifyTest().main()
StartupNotifyTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_taproot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,4 +1766,4 @@ def run_test(self):


if __name__ == '__main__':
TaprootTest().main()
TaprootTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_uacomment.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def run_test(self):


if __name__ == '__main__':
UacommentTest().main()
UacommentTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_unsupported_utxo_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ def run_test(self):


if __name__ == "__main__":
UnsupportedUtxoDbTest().main()
UnsupportedUtxoDbTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_utxo_set_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ def run_test(self):


if __name__ == '__main__':
UTXOSetHashTest().main()
UTXOSetHashTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/feature_versionbits_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def run_test(self):
self.wait_until(lambda: self.versionbits_in_alert_file())

if __name__ == '__main__':
VersionBitsWarningTest().main()
VersionBitsWarningTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/interface_bitcoin_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,4 @@ def run_test(self):


if __name__ == '__main__':
TestBitcoinCli().main()
TestBitcoinCli(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/interface_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ def run_test(self):


if __name__ == '__main__':
HTTPBasicsTest ().main ()
HTTPBasicsTest(__file__).main ()
2 changes: 1 addition & 1 deletion test/functional/interface_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,4 @@ def run_test(self):
assert_equal(resp.read().decode('utf-8').rstrip(), f"Invalid hash: {INVALID_PARAM}")

if __name__ == '__main__':
RESTTest().main()
RESTTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/interface_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,4 @@ def run_test(self):


if __name__ == '__main__':
RPCInterfaceTest().main()
RPCInterfaceTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/interface_usdt_coinselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,4 @@ def run_test(self):


if __name__ == '__main__':
CoinSelectionTracepointTest().main()
CoinSelectionTracepointTest(__file__).main()
Loading

0 comments on commit 8975005

Please sign in to comment.