Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_runner.py
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | EXTENDED_SCRIPTS = [ | ||||
'invalidateblock.py', | 'invalidateblock.py', | ||||
'p2p-acceptblock.py', | 'p2p-acceptblock.py', | ||||
] | ] | ||||
# Place EXTENDED_SCRIPTS first since it has the 3 longest running tests | # Place EXTENDED_SCRIPTS first since it has the 3 longest running tests | ||||
ALL_SCRIPTS = EXTENDED_SCRIPTS + BASE_SCRIPTS | ALL_SCRIPTS = EXTENDED_SCRIPTS + BASE_SCRIPTS | ||||
NON_SCRIPTS = [ | |||||
# These are python files that live in the functional tests directory, but are not test scripts. | |||||
"combine_logs.py", | |||||
"create_cache.py", | |||||
"test_runner.py", | |||||
] | |||||
def main(): | def main(): | ||||
# Parse arguments and pass through unrecognised args | # Parse arguments and pass through unrecognised args | ||||
parser = argparse.ArgumentParser(add_help=False, | parser = argparse.ArgumentParser(add_help=False, | ||||
usage='%(prog)s [test_runner.py options] [script options] [scripts]', | usage='%(prog)s [test_runner.py options] [script options] [scripts]', | ||||
description=__doc__, | description=__doc__, | ||||
epilog=''' | epilog=''' | ||||
Help text and arguments for individual test script:''', | Help text and arguments for individual test script:''', | ||||
formatter_class=argparse.RawTextHelpFormatter) | formatter_class=argparse.RawTextHelpFormatter) | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | def main(): | ||||
if args.help: | if args.help: | ||||
# Print help for test_runner.py, then print help of the first script | # Print help for test_runner.py, then print help of the first script | ||||
# and exit. | # 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( | check_script_list(config["environment"]["SRCDIR"]) | ||||
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 | ||||
tests_dir = src_dir + '/test/functional/' | tests_dir = src_dir + '/test/functional/' | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | def get_next(self): | ||||
status = "Failed" | status = "Failed" | ||||
self.num_running -= 1 | self.num_running -= 1 | ||||
self.jobs.remove(j) | self.jobs.remove(j) | ||||
return name, stdout, stderr, status, int( | return name, stdout, stderr, status, int( | ||||
time.time() - time0) | time.time() - time0) | ||||
print('.', end='', flush=True) | print('.', end='', flush=True) | ||||
def check_script_list(src_dir): | |||||
"""Check scripts directory. | |||||
Check that there are no scripts in the functional tests directory which are | |||||
not being run by pull-tester.py.""" | |||||
script_dir = src_dir + '/test/functional/' | |||||
python_files = set([t for t in os.listdir(script_dir) if t[-3:] == ".py"]) | |||||
missed_tests = list( | |||||
python_files - set(map(lambda x: x.split()[0], ALL_SCRIPTS + NON_SCRIPTS))) | |||||
if len(missed_tests) != 0: | |||||
print("The following scripts are not being run:" + str(missed_tests)) | |||||
print("Check the test lists in test_runner.py") | |||||
sys.exit(1) | |||||
class RPCCoverage(object): | class RPCCoverage(object): | ||||
""" | """ | ||||
Coverage reporting utilities for test_runner. | Coverage reporting utilities for test_runner. | ||||
Coverage calculation works by having each test script subprocess write | Coverage calculation works by having each test script subprocess write | ||||
coverage files into a particular directory. These files contain the RPC | coverage files into a particular directory. These files contain the RPC | ||||
commands invoked during testing, as well as a complete listing of RPC | commands invoked during testing, as well as a complete listing of RPC | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |