Skip to content

Commit 2c2e36d

Browse files
committed
test: Add test for -debuglogfile
backports bitcoin/bitcoin@2323242
1 parent b44a324 commit 2c2e36d

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

test/functional/feature_logging.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2017 The Bitcoin Core developers
3+
# Copyright (c) 20200 The PIVX Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
"""Test debug logging."""
7+
8+
import os
9+
10+
from test_framework.test_framework import PivxTestFramework
11+
12+
class LoggingTest(PivxTestFramework):
13+
def set_test_params(self):
14+
self.num_nodes = 1
15+
self.setup_clean_chain = True
16+
17+
def run_test(self):
18+
# test default log file name
19+
assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "debug.log"))
20+
self.log.info("Default filename ok")
21+
22+
# test alternative log file name in datadir
23+
self.restart_node(0, ["-debuglogfile=foo.log"])
24+
assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "foo.log"))
25+
self.log.info("Alternative filename ok")
26+
27+
# test alternative log file name outside datadir
28+
tempname = os.path.join(self.options.tmpdir, "foo.log")
29+
self.restart_node(0, ["-debuglogfile=%s" % tempname])
30+
assert os.path.isfile(tempname)
31+
self.log.info("Alternative filename outside datadir ok")
32+
33+
# check that invalid log (relative) will cause error
34+
self.stop_node(0)
35+
self.assert_start_raises_init_error(0, ["-debuglogfile=ssdksjdf/sdasdfa/sdfsdfsfd"],
36+
"Error: Could not open debug log file")
37+
self.log.info("Invalid relative filename throws")
38+
39+
# check that invalid log (absolute) will cause error
40+
self.stop_node(0)
41+
invalidname = os.path.join(self.options.tmpdir, "foo/foo.log")
42+
self.assert_start_raises_init_error(0, ["-debuglogfile=%s" % invalidname],
43+
"Error: Could not open debug log file")
44+
self.log.info("Invalid absolute filename throws")
45+
46+
47+
if __name__ == '__main__':
48+
LoggingTest().main()

test/functional/test_runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
'rpc_rawtransaction.py', # ~ 193 sec
7070
'wallet_zapwallettxes.py', # ~ 180 sec
7171
'wallet_keypool_topup.py', # ~ 174 sec
72+
'feature_logging.py', # ~ 166 sec
7273
'wallet_txn_doublespend.py --mineblock', # ~ 157 sec
7374
'wallet_txn_clone.py --mineblock', # ~ 157 sec
7475
'rpc_spork.py', # ~ 156 sec
@@ -153,6 +154,7 @@
153154
LEGACY_SKIP_TESTS = [
154155
# These tests are not run when the flag --legacywallet is used
155156
'feature_help.py',
157+
'feature_logging.py',
156158
'feature_reindex.py',
157159
'feature_proxy.py',
158160
'feature_uacomment.py',

0 commit comments

Comments
 (0)