Skip to content

Commit 3d5ad7f

Browse files
committed
test: Add tests for -debuglogfile with subdirs
backports bitcoin/bitcoin@5a7c09a
1 parent 2c2e36d commit 3d5ad7f

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

test/functional/feature_logging.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,35 @@ def run_test(self):
3131
self.log.info("Alternative filename outside datadir ok")
3232

3333
# check that invalid log (relative) will cause error
34+
invdir = os.path.join(self.nodes[0].datadir, "regtest", "foo")
35+
invalidname = os.path.join("foo", "foo.log")
3436
self.stop_node(0)
35-
self.assert_start_raises_init_error(0, ["-debuglogfile=ssdksjdf/sdasdfa/sdfsdfsfd"],
37+
self.assert_start_raises_init_error(0, ["-debuglogfile=%s" % (invalidname)],
3638
"Error: Could not open debug log file")
39+
assert not os.path.isfile(os.path.join(invdir, "foo.log"))
3740
self.log.info("Invalid relative filename throws")
3841

42+
# check that a previously invalid log (relative) works after path exists
43+
os.mkdir(invdir)
44+
self.start_node(0, ["-debuglogfile=%s" % (invalidname)])
45+
assert os.path.isfile(os.path.join(invdir, "foo.log"))
46+
self.log.info("Relative filename ok when path exists")
47+
3948
# check that invalid log (absolute) will cause error
4049
self.stop_node(0)
41-
invalidname = os.path.join(self.options.tmpdir, "foo/foo.log")
50+
invdir = os.path.join(self.options.tmpdir, "foo")
51+
invalidname = os.path.join(invdir, "foo.log")
4252
self.assert_start_raises_init_error(0, ["-debuglogfile=%s" % invalidname],
4353
"Error: Could not open debug log file")
54+
assert not os.path.isfile(os.path.join(invdir, "foo.log"))
4455
self.log.info("Invalid absolute filename throws")
4556

57+
# check that a previously invalid log (relative) works after path exists
58+
os.mkdir(invdir)
59+
self.start_node(0, ["-debuglogfile=%s" % (invalidname)])
60+
assert os.path.isfile(os.path.join(invdir, "foo.log"))
61+
self.log.info("Absolute filename ok when path exists")
62+
4663

4764
if __name__ == '__main__':
4865
LoggingTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@
6666
'wallet_abandonconflict.py', # ~ 212 sec
6767
'wallet_hd.py', # ~ 210 sec
6868
'wallet_zerocoin_publicspends.py', # ~ 202 sec
69+
'feature_logging.py', # ~ 200 sec
6970
'rpc_rawtransaction.py', # ~ 193 sec
7071
'wallet_zapwallettxes.py', # ~ 180 sec
7172
'wallet_keypool_topup.py', # ~ 174 sec
72-
'feature_logging.py', # ~ 166 sec
7373
'wallet_txn_doublespend.py --mineblock', # ~ 157 sec
7474
'wallet_txn_clone.py --mineblock', # ~ 157 sec
7575
'rpc_spork.py', # ~ 156 sec

0 commit comments

Comments
 (0)