diff --git a/test/functional/abc-p2p-compactblocks.py b/test/functional/abc-p2p-compactblocks.py --- a/test/functional/abc-p2p-compactblocks.py +++ b/test/functional/abc-p2p-compactblocks.py @@ -13,6 +13,7 @@ from test_framework.test_framework import ComparisonTestFramework from test_framework.util import * +from test_framework.decorators import * from test_framework.comptool import TestManager, TestInstance, RejectResult from test_framework.blocktools import * import time @@ -60,6 +61,7 @@ self.last_cmpctblock = None +@extended class FullBlockTest(ComparisonTestFramework): # Can either run this test as 1 node with expected answers, or two and compare them. diff --git a/test/functional/abc-p2p-fullblocktest.py b/test/functional/abc-p2p-fullblocktest.py --- a/test/functional/abc-p2p-fullblocktest.py +++ b/test/functional/abc-p2p-fullblocktest.py @@ -12,6 +12,7 @@ """ from test_framework.test_framework import ComparisonTestFramework +from test_framework.decorators import * from test_framework.util import assert_equal, assert_raises_rpc_error from test_framework.comptool import TestManager, TestInstance, RejectResult from test_framework.blocktools import * @@ -32,6 +33,7 @@ self.n = n # the output we're spending +@extended class FullBlockTest(ComparisonTestFramework): # Can either run this test as 1 node with expected answers, or two and compare them. diff --git a/test/functional/dbcrash.py b/test/functional/dbcrash.py --- a/test/functional/dbcrash.py +++ b/test/functional/dbcrash.py @@ -34,6 +34,7 @@ from test_framework.mininode import * from test_framework.script import * from test_framework.test_framework import BitcoinTestFramework +from test_framework.decorators import * from test_framework.util import * from test_framework.blocktools import create_confirmed_utxos @@ -44,6 +45,7 @@ pass +@extended class ChainstateWriteCrashTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 4 diff --git a/test/functional/getblocktemplate_longpoll.py b/test/functional/getblocktemplate_longpoll.py --- a/test/functional/getblocktemplate_longpoll.py +++ b/test/functional/getblocktemplate_longpoll.py @@ -4,6 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. from test_framework.test_framework import BitcoinTestFramework +from test_framework.decorators import * from test_framework.util import * import threading @@ -25,6 +26,7 @@ self.node.getblocktemplate({'longpollid': self.longpollid}) +@extended class GetBlockTemplateLPTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 diff --git a/test/functional/p2p-fullblocktest.py b/test/functional/p2p-fullblocktest.py --- a/test/functional/p2p-fullblocktest.py +++ b/test/functional/p2p-fullblocktest.py @@ -5,6 +5,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. from test_framework.test_framework import ComparisonTestFramework +from test_framework.decorators import * from test_framework.util import * from test_framework.comptool import TestManager, TestInstance, RejectResult from test_framework.blocktools import * @@ -56,6 +57,7 @@ return r +@extended class FullBlockTest(ComparisonTestFramework): # Can either run this test as 1 node with expected answers, or two and compare them. # Change the "outcome" variable from each TestInstance object to only do the comparison. diff --git a/test/functional/p2p-timeouts.py b/test/functional/p2p-timeouts.py --- a/test/functional/p2p-timeouts.py +++ b/test/functional/p2p-timeouts.py @@ -25,6 +25,7 @@ from test_framework.mininode import * from test_framework.test_framework import BitcoinTestFramework +from test_framework.decorators import * from test_framework.util import * @@ -34,6 +35,7 @@ pass +@extended class TimeoutsTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True diff --git a/test/functional/pruning.py b/test/functional/pruning.py --- a/test/functional/pruning.py +++ b/test/functional/pruning.py @@ -12,6 +12,7 @@ # ******** from test_framework.test_framework import BitcoinTestFramework +from test_framework.decorators import * from test_framework.util import * from test_framework.blocktools import mine_big_block @@ -30,6 +31,7 @@ return sum(os.path.getsize(blockdir + f) for f in os.listdir(blockdir) if os.path.isfile(blockdir + f)) / (1024. * 1024.) +@extended class PruneTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True diff --git a/test/functional/test_framework/decorators.py b/test/functional/test_framework/decorators.py new file mode 100644 --- /dev/null +++ b/test/functional/test_framework/decorators.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +# Copyright (c) 2015-2018 The Bitcoin developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +""" +Python test decorators to provide various attributes the test_runner can +examine +""" + + +def extended(cls): + cls.extended = True + return cls diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -103,7 +103,7 @@ self.test_num = test_num self.flags = flags - def run(self, portseed_offset): + def run(self, portseed_offset, run_extended): t = self.test_case portseed = self.test_num * 10 + portseed_offset portseed_arg = ["--portseed={}".format(portseed)] @@ -137,8 +137,13 @@ for prop in dir(test_module): obj = getattr(test_module, prop) if inspect.isclass(obj) and issubclass(obj, BitcoinTestFramework) and obj is not BitcoinTestFramework and obj is not ComparisonTestFramework: - exit_code = obj().main( - test_argv[1:] + self.flags + portseed_arg + tmpdir) + test_instance = obj() + is_extended = hasattr(test_instance, 'extended') + if (is_extended and run_extended) or not is_extended: + exit_code = obj().main( + test_argv[1:] + self.flags + portseed_arg + tmpdir) + else: + exit_code = TestStatus.SKIPPED except Exception as e: print(e) finally: @@ -301,10 +306,10 @@ "cache"), ignore_errors=True) run_tests(test_list, build_dir, tests_dir, args.junitouput, - config["environment"]["EXEEXT"], tmpdir, args.jobs, args.coverage, passon_args, build_timings) + config["environment"]["EXEEXT"], tmpdir, args.jobs, args.coverage, passon_args, build_timings, args.extended) -def run_tests(test_list, build_dir, tests_dir, junitouput, exeext, tmpdir, num_jobs, enable_coverage=False, args=[], build_timings=None): +def run_tests(test_list, build_dir, tests_dir, junitouput, exeext, tmpdir, num_jobs, enable_coverage=False, args=[], build_timings=None, run_extended=None): # Warn if bitcoind is already running (unix only) try: pidofOutput = subprocess.check_output(["pidof", "bitcoind"]) @@ -345,7 +350,7 @@ # Run Tests time0 = time.time() test_results = execute_test_processes( - num_jobs, test_list, tests_dir, tmpdir, flags) + num_jobs, test_list, tests_dir, tmpdir, flags, run_extended) runtime = int(time.time() - time0) max_len_name = len(max(test_list, key=len)) @@ -434,7 +439,7 @@ printed_status = True -def handle_test_cases(job_queue, update_queue): +def handle_test_cases(job_queue, update_queue, run_extended): """ job_runner represents a single thread that is part of a worker pool. It waits for a test, then executes that test. It also reports start @@ -452,12 +457,12 @@ # Signal that the test is starting to inform the poor waiting # programmer update_queue.put(test) - result = test.run(portseed_offset) + result = test.run(portseed_offset, run_extended) update_queue.put(result) job_queue.task_done() -def execute_test_processes(num_jobs, test_list, tests_dir, tmpdir, flags): +def execute_test_processes(num_jobs, test_list, tests_dir, tmpdir, flags, run_extended): ctx = mp.get_context('spawn') update_queue = ctx.JoinableQueue() job_queue = ctx.JoinableQueue() @@ -476,7 +481,7 @@ # Start some worker threads for j in range(num_jobs): t = ctx.Process(target=handle_test_cases, - args=(job_queue, update_queue,)) + args=(job_queue, update_queue, run_extended,)) t.start() # Push all our test cases into the job queue. diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -5,6 +5,7 @@ """Test Hierarchical Deterministic wallet function.""" from test_framework.test_framework import BitcoinTestFramework +from test_framework.decorators import * from test_framework.util import ( assert_equal, connect_nodes_bi, @@ -13,6 +14,7 @@ import os +@extended class WalletHDTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True diff --git a/test/functional/walletbackup.py b/test/functional/walletbackup.py --- a/test/functional/walletbackup.py +++ b/test/functional/walletbackup.py @@ -34,9 +34,11 @@ import shutil from test_framework.test_framework import BitcoinTestFramework +from test_framework.decorators import * from test_framework.util import * +@extended class WalletBackupTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 4