Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_logging.py
Show All 32 Lines | def run_test(self): | ||||
assert os.path.isfile(tempname) | assert os.path.isfile(tempname) | ||||
# check that invalid log (relative) will cause error | # check that invalid log (relative) will cause error | ||||
invdir = self.relative_log_path("foo") | invdir = self.relative_log_path("foo") | ||||
invalidname = os.path.join("foo", "foo.log") | invalidname = os.path.join("foo", "foo.log") | ||||
self.stop_node(0) | self.stop_node(0) | ||||
exp_stderr = r"Error: Could not open debug log file \S+$" | exp_stderr = r"Error: Could not open debug log file \S+$" | ||||
self.nodes[0].assert_start_raises_init_error( | self.nodes[0].assert_start_raises_init_error( | ||||
[f"-debuglogfile={invalidname}"], exp_stderr, match=ErrorMatch.FULL_REGEX) | [f"-debuglogfile={invalidname}"], exp_stderr, match=ErrorMatch.FULL_REGEX | ||||
) | |||||
assert not os.path.isfile(os.path.join(invdir, "foo.log")) | assert not os.path.isfile(os.path.join(invdir, "foo.log")) | ||||
# check that invalid log (relative) works after path exists | # check that invalid log (relative) works after path exists | ||||
self.stop_node(0) | self.stop_node(0) | ||||
os.mkdir(invdir) | os.mkdir(invdir) | ||||
self.start_node(0, [f"-debuglogfile={invalidname}"]) | self.start_node(0, [f"-debuglogfile={invalidname}"]) | ||||
assert os.path.isfile(os.path.join(invdir, "foo.log")) | assert os.path.isfile(os.path.join(invdir, "foo.log")) | ||||
# check that invalid log (absolute) will cause error | # check that invalid log (absolute) will cause error | ||||
self.stop_node(0) | self.stop_node(0) | ||||
invdir = os.path.join(self.options.tmpdir, "foo") | invdir = os.path.join(self.options.tmpdir, "foo") | ||||
invalidname = os.path.join(invdir, "foo.log") | invalidname = os.path.join(invdir, "foo.log") | ||||
self.nodes[0].assert_start_raises_init_error( | self.nodes[0].assert_start_raises_init_error( | ||||
[f"-debuglogfile={invalidname}"], exp_stderr, match=ErrorMatch.FULL_REGEX) | [f"-debuglogfile={invalidname}"], exp_stderr, match=ErrorMatch.FULL_REGEX | ||||
) | |||||
assert not os.path.isfile(os.path.join(invdir, "foo.log")) | assert not os.path.isfile(os.path.join(invdir, "foo.log")) | ||||
# check that invalid log (absolute) works after path exists | # check that invalid log (absolute) works after path exists | ||||
self.stop_node(0) | self.stop_node(0) | ||||
os.mkdir(invdir) | os.mkdir(invdir) | ||||
self.start_node(0, [f"-debuglogfile={invalidname}"]) | self.start_node(0, [f"-debuglogfile={invalidname}"]) | ||||
assert os.path.isfile(os.path.join(invdir, "foo.log")) | assert os.path.isfile(os.path.join(invdir, "foo.log")) | ||||
# check that -nodebuglogfile disables logging | # check that -nodebuglogfile disables logging | ||||
self.stop_node(0) | self.stop_node(0) | ||||
os.unlink(default_log_path) | os.unlink(default_log_path) | ||||
assert not os.path.isfile(default_log_path) | assert not os.path.isfile(default_log_path) | ||||
self.start_node(0, ["-nodebuglogfile"]) | self.start_node(0, ["-nodebuglogfile"]) | ||||
assert not os.path.isfile(default_log_path) | assert not os.path.isfile(default_log_path) | ||||
# just sanity check no crash here | # just sanity check no crash here | ||||
self.restart_node(0, [f"-debuglogfile={os.devnull}"]) | self.restart_node(0, [f"-debuglogfile={os.devnull}"]) | ||||
if __name__ == '__main__': | if __name__ == "__main__": | ||||
LoggingTest().main() | LoggingTest().main() |