Skip to content

Commit

Permalink
Merge bitcoin#30463: qa: Functional test improvements
Browse files Browse the repository at this point in the history
a8e3af1 qa: Do not assume running `feature_asmap.py` from source directory (Hennadii Stepanov)
9bf7ca6 qa: Consider `cache` and `config.ini` relative to invocation directory (Hennadii Stepanov)
a047344 scripted-diff: Add `__file__` argument to `BitcoinTestFramework.init()` (Hennadii Stepanov)

Pull request description:

  This PR includes changes split from bitcoin#30454. They improve the functional test framework, allowing users to [run individual functional tests](hebasto#146) from the build directory in the new CMake-based build system.

  This functionality is not available for out-of-source builds using the current Autotools-based build system, which always requires write permissions for the source directory. Nevertheless, this PR can be tested as suggested in bitcoin#30463 (comment):
  1. Make an out-of-source build:
  ```
  $ ./autogen.sh
  $ mkdir ../build && cd ../build
  $ ../bitcoin/configure
  $ make
  ```
  2. Create a symlink in the build directory to a functional test:
  ```
  $ ln --symbolic ../../../bitcoin/test/functional/wallet_disable.py ./test/functional/
  ```
  3. Run this symlink:
  ```
  $ ./test/functional/wallet_disable.py
  ```
  The last command fails on the master branch:
  ```
  Traceback (most recent call last):
    File "/home/hebasto/git/build/./test/functional/wallet_disable.py", line 31, in <module>
      DisableWalletTest().main()
      ^^^^^^^^^^^^^^^^^^^
    File "/home/hebasto/git/bitcoin/test/functional/test_framework/test_framework.py", line 106, in __init__
      self.parse_args()
    File "/home/hebasto/git/bitcoin/test/functional/test_framework/test_framework.py", line 210, in parse_args
      config.read_file(open(self.options.configfile))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  FileNotFoundError: [Errno 2] No such file or directory: '/home/hebasto/git/bitcoin/test/config.ini'

  ```
  and succeeds with this PR.

ACKs for top commit:
  maflcko:
    tested ACK a8e3af1 🎨
  glozow:
    ACK a8e3af1, tested with the steps in op
  stickies-v:
    ACK a8e3af1

Tree-SHA512: 899e4efc09edec13ea3f5b47825d03173fb21d3569c360deda7fa6a56b99b4d24e09ad4f0883bad1ee926b1c706e47ba07c6a6160c63c07c82b3cf4ae5816e91
  • Loading branch information
glozow committed Jul 22, 2024
2 parents a1b8a91 + a8e3af1 commit 3a29ff5
Show file tree
Hide file tree
Showing 247 changed files with 254 additions and 253 deletions.
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 @@ -160,4 +160,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 @@ -581,4 +581,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 @@ -88,4 +88,4 @@ def run_test(self):
assert_equal(binds, set(expected_services))

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 @@ -1434,4 +1434,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 @@ -324,4 +324,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_framework_miniwallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def run_test(self):


if __name__ == '__main__':
FeatureFrameworkMiniWalletTest().main()
FeatureFrameworkMiniWalletTest(__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 @@ -513,4 +513,4 @@ def test_pruneheight_undo_presence(self):
assert_equal(pruneheight, new_pruneheight)

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 @@ -103,4 +103,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 @@ -383,4 +383,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 @@ -439,4 +439,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 @@ -246,4 +246,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()
2 changes: 1 addition & 1 deletion test/functional/interface_usdt_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,4 @@ def run_test(self):


if __name__ == "__main__":
MempoolTracepointTest().main()
MempoolTracepointTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/interface_usdt_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ def handle_outbound(_, data, __):


if __name__ == '__main__':
NetTracepointTest().main()
NetTracepointTest(__file__).main()
2 changes: 1 addition & 1 deletion test/functional/interface_usdt_utxocache.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,4 @@ def handle_utxocache_flush(_, data, __):


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

0 comments on commit 3a29ff5

Please sign in to comment.