Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 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.environ['PATH'] = self.options.srcdir + os.pathsep + \ | ||||
self.options.srcdir + "/qt:" + os.environ['PATH'] | 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)) | config.read_file(open(self.options.configfile)) | ||||
self.options.bitcoind = os.getenv( | self.options.bitcoind = os.getenv( | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | def main(self): | ||||
self.stop_nodes() | self.stop_nodes() | ||||
else: | else: | ||||
for node in self.nodes: | for node in self.nodes: | ||||
node.cleanup_on_exit = False | node.cleanup_on_exit = False | ||||
self.log.info( | self.log.info( | ||||
"Note: bitcoinds were not stopped and may still be running") | "Note: bitcoinds were not stopped and may still be running") | ||||
if not self.options.nocleanup and not self.options.noshutdown and success != TestStatus.FAILED: | if not self.options.nocleanup and not self.options.noshutdown and success != TestStatus.FAILED: | ||||
self.log.info("Cleaning up") | self.log.info("Cleaning up {} on exit".format(self.options.tmpdir)) | ||||
shutil.rmtree(self.options.tmpdir) | cleanup_tree_on_exit = True | ||||
else: | else: | ||||
self.log.warning( | self.log.warning( | ||||
"Not cleaning up dir {}".format(self.options.tmpdir)) | "Not cleaning up dir {}".format(self.options.tmpdir)) | ||||
cleanup_tree_on_exit = False | |||||
if success == TestStatus.PASSED: | if success == TestStatus.PASSED: | ||||
self.log.info("Tests successful") | self.log.info("Tests successful") | ||||
exit_code = TEST_EXIT_PASSED | exit_code = TEST_EXIT_PASSED | ||||
elif success == TestStatus.SKIPPED: | elif success == TestStatus.SKIPPED: | ||||
self.log.info("Test skipped") | self.log.info("Test skipped") | ||||
exit_code = TEST_EXIT_SKIPPED | exit_code = TEST_EXIT_SKIPPED | ||||
else: | else: | ||||
self.log.error( | self.log.error( | ||||
"Test failed. Test logging available at {}/test_framework.log".format(self.options.tmpdir)) | "Test failed. Test logging available at {}/test_framework.log".format(self.options.tmpdir)) | ||||
self.log.error("Hint: Call {} '{}' to consolidate all logs".format(os.path.normpath( | self.log.error("Hint: Call {} '{}' to consolidate all logs".format(os.path.normpath( | ||||
os.path.dirname(os.path.realpath(__file__)) + "/../combine_logs.py"), self.options.tmpdir)) | os.path.dirname(os.path.realpath(__file__)) + "/../combine_logs.py"), self.options.tmpdir)) | ||||
exit_code = TEST_EXIT_FAILED | exit_code = TEST_EXIT_FAILED | ||||
logging.shutdown() | logging.shutdown() | ||||
if cleanup_tree_on_exit: | |||||
shutil.rmtree(self.options.tmpdir) | |||||
sys.exit(exit_code) | sys.exit(exit_code) | ||||
# Methods to override in subclass test scripts. | # Methods to override in subclass test scripts. | ||||
def set_test_params(self): | def set_test_params(self): | ||||
"""Tests must this method to change default values for number of nodes, topology, etc""" | """Tests must this method to change default values for number of nodes, topology, etc""" | ||||
raise NotImplementedError | raise NotImplementedError | ||||
def add_options(self, parser): | def add_options(self, parser): | ||||
▲ Show 20 Lines • Show All 300 Lines • Show Last 20 Lines |