Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | class BitcoinTestFramework(): | ||||
def main(self): | def main(self): | ||||
"""Main function. This should not be overridden by the subclass test scripts.""" | """Main function. This should not be overridden by the subclass test scripts.""" | ||||
parser = argparse.ArgumentParser(usage="%(prog)s [options]") | parser = argparse.ArgumentParser(usage="%(prog)s [options]") | ||||
parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true", | parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true", | ||||
help="Leave bitcoinds and test.* datadir on exit or error") | help="Leave bitcoinds and test.* datadir on exit or error") | ||||
parser.add_argument("--noshutdown", dest="noshutdown", default=False, action="store_true", | parser.add_argument("--noshutdown", dest="noshutdown", default=False, action="store_true", | ||||
help="Don't stop bitcoinds after the test execution") | help="Don't stop bitcoinds after the test execution") | ||||
parser.add_argument("--srcdir", dest="srcdir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../../src"), | |||||
help="Source directory containing bitcoind/bitcoin-cli (default: %(default)s)") | |||||
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"), | parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"), | ||||
help="Directory for caching pregenerated datadirs (default: %(default)s)") | help="Directory for caching pregenerated datadirs (default: %(default)s)") | ||||
parser.add_argument("--tmpdir", dest="tmpdir", | parser.add_argument("--tmpdir", dest="tmpdir", | ||||
help="Root directory for datadirs") | help="Root directory for datadirs") | ||||
parser.add_argument("-l", "--loglevel", dest="loglevel", default="INFO", | parser.add_argument("-l", "--loglevel", dest="loglevel", default="INFO", | ||||
help="log events at this level and higher to the console. Can be set to DEBUG, INFO, WARNING, ERROR or CRITICAL. Passing --loglevel DEBUG will output all logs to console. Note that logs at all levels are always written to the test_framework.log file in the temporary test directory.") | help="log events at this level and higher to the console. Can be set to DEBUG, INFO, WARNING, ERROR or CRITICAL. Passing --loglevel DEBUG will output all logs to console. Note that logs at all levels are always written to the test_framework.log file in the temporary test directory.") | ||||
parser.add_argument("--tracerpc", dest="trace_rpc", default=False, action="store_true", | parser.add_argument("--tracerpc", dest="trace_rpc", default=False, action="store_true", | ||||
help="Print out all RPC calls as they are made") | help="Print out all RPC calls as they are made") | ||||
Show All 13 Lines | def main(self): | ||||
self.options = parser.parse_args() | self.options = parser.parse_args() | ||||
self.set_test_params() | self.set_test_params() | ||||
assert hasattr( | assert hasattr( | ||||
self, "num_nodes"), "Test must set self.num_nodes in set_test_params()" | self, "num_nodes"), "Test must set self.num_nodes in set_test_params()" | ||||
PortSeed.n = self.options.port_seed | PortSeed.n = self.options.port_seed | ||||
os.environ['PATH'] = self.options.srcdir + os.pathsep + \ | |||||
self.options.srcdir + os.path.sep + "qt" + os.pathsep + \ | |||||
os.environ['PATH'] | |||||
check_json_precision() | check_json_precision() | ||||
self.options.cachedir = os.path.abspath(self.options.cachedir) | self.options.cachedir = os.path.abspath(self.options.cachedir) | ||||
config = configparser.ConfigParser() | config = configparser.ConfigParser() | ||||
config.read_file(open(self.options.configfile, encoding='utf-8')) | config.read_file(open(self.options.configfile, encoding='utf-8')) | ||||
self.options.bitcoind = os.getenv( | self.options.bitcoind = os.getenv( | ||||
"BITCOIND", default=config["environment"]["BUILDDIR"] + '/src/bitcoind' + config["environment"]["EXEEXT"]) | "BITCOIND", default=config["environment"]["BUILDDIR"] + '/src/bitcoind' + config["environment"]["EXEEXT"]) | ||||
self.options.bitcoincli = os.getenv( | self.options.bitcoincli = os.getenv( | ||||
"BITCOINCLI", default=config["environment"]["BUILDDIR"] + '/src/bitcoin-cli' + config["environment"]["EXEEXT"]) | "BITCOINCLI", default=config["environment"]["BUILDDIR"] + '/src/bitcoin-cli' + config["environment"]["EXEEXT"]) | ||||
os.environ['PATH'] = config['environment']['BUILDDIR'] + os.pathsep + \ | |||||
config['environment']['BUILDDIR'] + os.path.sep + "qt" + os.pathsep + \ | |||||
os.environ['PATH'] | |||||
# Set up temp directory and start logging | # Set up temp directory and start logging | ||||
if self.options.tmpdir: | if self.options.tmpdir: | ||||
self.options.tmpdir = os.path.abspath(self.options.tmpdir) | self.options.tmpdir = os.path.abspath(self.options.tmpdir) | ||||
os.makedirs(self.options.tmpdir, exist_ok=False) | os.makedirs(self.options.tmpdir, exist_ok=False) | ||||
else: | else: | ||||
self.options.tmpdir = tempfile.mkdtemp(prefix="test") | self.options.tmpdir = tempfile.mkdtemp(prefix="test") | ||||
self._start_logging() | self._start_logging() | ||||
▲ Show 20 Lines • Show All 368 Lines • Show Last 20 Lines |