Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_runner.py
Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | def main(): | ||||
if config["environment"]["EXEEXT"] == ".exe" and not args.force: | if config["environment"]["EXEEXT"] == ".exe" and not args.force: | ||||
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9 | # https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9 | ||||
# https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964 | # https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964 | ||||
print( | print( | ||||
"Tests currently disabled on Windows by default. Use --force option to enable") | "Tests currently disabled on Windows by default. Use --force option to enable") | ||||
sys.exit(0) | sys.exit(0) | ||||
if not (enable_wallet and enable_utils and enable_bitcoind): | if not (enable_wallet and enable_utils and enable_bitcoind): | ||||
print("No functional tests to run. Wallet, utils, and bitcoind must all be enabled") | print( | ||||
print("Rerun `configure` with -enable-wallet, -with-utils and -with-daemon and rerun make") | "No functional tests to run. Wallet, utils, and bitcoind must all be enabled") | ||||
print( | |||||
"Rerun `configure` with -enable-wallet, -with-utils and -with-daemon and rerun make") | |||||
sys.exit(0) | sys.exit(0) | ||||
# python3-zmq may not be installed. Handle this gracefully and with some helpful info | # python3-zmq may not be installed. Handle this gracefully and with some | ||||
# helpful info | |||||
if enable_zmq: | if enable_zmq: | ||||
try: | try: | ||||
import zmq | import zmq | ||||
except ImportError: | except ImportError: | ||||
print("ERROR: \"import zmq\" failed. Use -nozmq to run without the ZMQ tests." | print("ERROR: \"import zmq\" failed. Use -nozmq to run without the ZMQ tests." | ||||
"To run zmq tests, see dependency info in /test/README.md.") | "To run zmq tests, see dependency info in /test/README.md.") | ||||
raise | raise | ||||
# Build list of tests | # Build list of tests | ||||
if tests: | if tests: | ||||
# Individual tests have been specified. Run specified tests that exist | # Individual tests have been specified. Run specified tests that exist | ||||
# in the ALL_SCRIPTS list. Accept the name with or without .py extension. | # in the ALL_SCRIPTS list. Accept the name with or without .py | ||||
# extension. | |||||
test_list = [t for t in ALL_SCRIPTS if | test_list = [t for t in ALL_SCRIPTS if | ||||
(t in tests or re.sub(".py$", "", t) in tests)] | (t in tests or re.sub(".py$", "", t) in tests)] | ||||
else: | else: | ||||
# No individual tests have been specified. Run base tests, and | # No individual tests have been specified. Run base tests, and | ||||
# optionally ZMQ tests and extended tests. | # optionally ZMQ tests and extended tests. | ||||
test_list = BASE_SCRIPTS | test_list = BASE_SCRIPTS | ||||
if enable_zmq: | if enable_zmq: | ||||
test_list += ZMQ_SCRIPTS | test_list += ZMQ_SCRIPTS | ||||
Show All 10 Lines | if args.exclude: | ||||
test_list.remove(exclude_test + ".py") | test_list.remove(exclude_test + ".py") | ||||
if not test_list: | if not test_list: | ||||
print("No valid test scripts specified. Check that your test is in one " | print("No valid test scripts specified. Check that your test is in one " | ||||
"of the test lists in test_runner.py, or run test_runner.py with no arguments to run all tests") | "of the test lists in test_runner.py, or run test_runner.py with no arguments to run all tests") | ||||
sys.exit(0) | sys.exit(0) | ||||
if args.help: | if args.help: | ||||
# Print help for test_runner.py, then print help of the first script and exit. | # Print help for test_runner.py, then print help of the first script | ||||
# and exit. | |||||
parser.print_help() | parser.print_help() | ||||
subprocess.check_call( | subprocess.check_call( | ||||
(config["environment"]["SRCDIR"] + '/test/functional/' + test_list[0]).split() + ['-h']) | (config["environment"]["SRCDIR"] + '/test/functional/' + test_list[0]).split() + ['-h']) | ||||
sys.exit(0) | sys.exit(0) | ||||
run_tests(test_list, config["environment"]["SRCDIR"], config["environment"]["BUILDDIR"], | run_tests( | ||||
test_list, config["environment"][ | |||||
"SRCDIR"], config["environment"]["BUILDDIR"], | |||||
config["environment"]["EXEEXT"], args.jobs, args.coverage, passon_args) | config["environment"]["EXEEXT"], args.jobs, args.coverage, passon_args) | ||||
def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=False, args=[]): | def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=False, args=[]): | ||||
# Set env vars | # Set env vars | ||||
if "BITCOIND" not in os.environ: | if "BITCOIND" not in os.environ: | ||||
os.environ["BITCOIND"] = build_dir + '/src/bitcoind' + exeext | os.environ["BITCOIND"] = build_dir + '/src/bitcoind' + exeext | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if coverage: | ||||
print("Cleaning up coverage data") | print("Cleaning up coverage data") | ||||
coverage.cleanup() | coverage.cleanup() | ||||
sys.exit(not all_passed) | sys.exit(not all_passed) | ||||
class TestHandler: | class TestHandler: | ||||
""" | """ | ||||
Trigger the testscrips passed in via the list. | Trigger the testscrips passed in via the list. | ||||
""" | """ | ||||
def __init__(self, num_tests_parallel, tests_dir, test_list=None, flags=None): | def __init__(self, num_tests_parallel, tests_dir, test_list=None, flags=None): | ||||
assert(num_tests_parallel >= 1) | assert(num_tests_parallel >= 1) | ||||
self.num_jobs = num_tests_parallel | self.num_jobs = num_tests_parallel | ||||
self.tests_dir = tests_dir | self.tests_dir = tests_dir | ||||
Show All 12 Lines | def get_next(self): | ||||
self.num_running += 1 | self.num_running += 1 | ||||
t = self.test_list.pop(0) | t = self.test_list.pop(0) | ||||
port_seed = ["--portseed={}".format( | port_seed = ["--portseed={}".format( | ||||
len(self.test_list) + self.portseed_offset)] | len(self.test_list) + self.portseed_offset)] | ||||
log_stdout = tempfile.SpooledTemporaryFile(max_size=2**16) | log_stdout = tempfile.SpooledTemporaryFile(max_size=2**16) | ||||
log_stderr = tempfile.SpooledTemporaryFile(max_size=2**16) | log_stderr = tempfile.SpooledTemporaryFile(max_size=2**16) | ||||
self.jobs.append((t, | self.jobs.append((t, | ||||
time.time(), | time.time(), | ||||
subprocess.Popen((self.tests_dir + t).split() + self.flags + port_seed, | subprocess.Popen( | ||||
(self.tests_dir + t).split() + | |||||
self.flags + port_seed, | |||||
universal_newlines=True, | universal_newlines=True, | ||||
stdout=log_stdout, | stdout=log_stdout, | ||||
stderr=log_stderr), | stderr=log_stderr), | ||||
log_stdout, | log_stdout, | ||||
log_stderr)) | log_stderr)) | ||||
if not self.jobs: | if not self.jobs: | ||||
raise IndexError('pop from empty list') | raise IndexError('pop from empty list') | ||||
while True: | while True: | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |