aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_logging.py
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-11-28 15:38:46 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-12-01 11:28:13 +0100
commit23232422e507a90922c0870611cade5c789bb83a (patch)
tree51294deb312089fc618c0edef314938c51cd080b /test/functional/feature_logging.py
parentcf5f432c69418adb51f0f4a0bdbd6ba3112ee11a (diff)
test: Add test for `-debuglogfile`
Diffstat (limited to 'test/functional/feature_logging.py')
-rwxr-xr-xtest/functional/feature_logging.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/functional/feature_logging.py b/test/functional/feature_logging.py
new file mode 100755
index 0000000000..24591e176f
--- /dev/null
+++ b/test/functional/feature_logging.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+# Copyright (c) 2017 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+"""Test debug logging."""
+
+import os
+
+from test_framework.test_framework import BitcoinTestFramework
+
+class LoggingTest(BitcoinTestFramework):
+ def set_test_params(self):
+ self.num_nodes = 1
+ self.setup_clean_chain = True
+
+ def run_test(self):
+ # test default log file name
+ assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "debug.log"))
+
+ # test alternative log file name in datadir
+ self.restart_node(0, ["-debuglogfile=foo.log"])
+ assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "foo.log"))
+
+ # test alternative log file name outside datadir
+ tempname = os.path.join(self.options.tmpdir, "foo.log")
+ self.restart_node(0, ["-debuglogfile=%s" % tempname])
+ assert os.path.isfile(tempname)
+
+ # check that invalid log (relative) will cause error
+ self.stop_node(0)
+ self.assert_start_raises_init_error(0, ["-debuglogfile=ssdksjdf/sdasdfa/sdfsdfsfd"],
+ "Error: Could not open debug log file")
+
+ # check that invalid log (absolute) will cause error
+ self.stop_node(0)
+ invalidname = os.path.join(self.options.tmpdir, "foo/foo.log")
+ self.assert_start_raises_init_error(0, ["-debuglogfile=%s" % invalidname],
+ "Error: Could not open debug log file")
+
+
+if __name__ == '__main__':
+ LoggingTest().main()