Skip to content

Commit d454e39

Browse files
author
MarcoFalke
committed
Merge #12843: [tests] Test starting bitcoind with -h and -version
63048ec [tests] Test starting bitcoind with -h and -version (John Newbery) Pull request description: Test that starting bitcoind/bitcoin-qt with `-h` and `-version` works as expected. Prompted by bitcoin/bitcoin#10762 (comment), which is a nullpointer dereference triggered by starting bitcoin-qt with `-h`. On master, this test passes when run over bitcoind, but fails when running over bitcoin-qt. I used xvfb as a virtual frame buffer to test: ``` BITCOIND=/home/ubuntu/bitcoin/src/qt/bitcoin-qt xvfb-run ./feature_help.py --nocleanup 2018-03-30T17:09:37.767000Z TestFramework (INFO): Initializing test directory /tmp/user/1000/testdi4dre13 2018-03-30T17:09:37.767000Z TestFramework (INFO): Start bitcoin with -h for help text 2018-03-30T17:09:37.841000Z TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "/home/ubuntu/bitcoin/test/functional/test_framework/test_framework.py", line 126, in main self.run_test() File "./feature_help.py", line 25, in run_test assert_equal(ret_code, 0) File "/home/ubuntu/bitcoin/test/functional/test_framework/util.py", line 39, in assert_equal raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args)) AssertionError: not(-11 == 0) 2018-03-30T17:09:37.842000Z TestFramework (INFO): Stopping nodes Traceback (most recent call last): File "./feature_help.py", line 42, in <module> HelpTest().main() File "/home/ubuntu/bitcoin/test/functional/test_framework/test_framework.py", line 149, in main self.stop_nodes() File "/home/ubuntu/bitcoin/test/functional/test_framework/test_framework.py", line 273, in stop_nodes node.stop_node() File "/home/ubuntu/bitcoin/test/functional/test_framework/test_node.py", line 141, in stop_node self.stop() File "/home/ubuntu/bitcoin/test/functional/test_framework/test_node.py", line 87, in __getattr__ assert self.rpc_connected and self.rpc is not None, "Error: no RPC connection" AssertionError: Error: no RPC connection ``` Passes for bitcoind and bitcoin-qt when run on #12836. Longer term, we should consider running functional tests over bitcoin-qt in one of the Travis jobs. Tree-SHA512: 0c2f40f3d5f0e78c3a1b07dbee8fd383eebab27ed0bf2a98a5b9cc66613dbd7b70e363c56163a37e02f68ae7ff7b3ae1769705d0e110ca68a00f8693315730a4
2 parents 2a09a78 + 63048ec commit d454e39

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

test/functional/feature_help.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2018 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Verify that starting bitcoin with -h works as expected."""
6+
import subprocess
7+
8+
from test_framework.test_framework import BitcoinTestFramework
9+
from test_framework.util import assert_equal
10+
11+
class HelpTest(BitcoinTestFramework):
12+
def set_test_params(self):
13+
self.setup_clean_chain = True
14+
self.num_nodes = 1
15+
16+
def setup_network(self):
17+
self.add_nodes(self.num_nodes)
18+
# Don't start the node
19+
20+
def run_test(self):
21+
self.log.info("Start bitcoin with -h for help text")
22+
self.nodes[0].start(extra_args=['-h'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
23+
# Node should exit immediately and output help to stdout.
24+
ret_code = self.nodes[0].process.wait(timeout=1)
25+
assert_equal(ret_code, 0)
26+
output = self.nodes[0].process.stdout.read()
27+
assert b'Options' in output
28+
self.log.info("Help text received: {} (...)".format(output[0:60]))
29+
self.nodes[0].running = False
30+
31+
self.log.info("Start bitcoin with -version for version information")
32+
self.nodes[0].start(extra_args=['-version'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
33+
# Node should exit immediately and output version to stdout.
34+
ret_code = self.nodes[0].process.wait(timeout=1)
35+
assert_equal(ret_code, 0)
36+
output = self.nodes[0].process.stdout.read()
37+
assert b'version' in output
38+
self.log.info("Version text received: {} (...)".format(output[0:60]))
39+
self.nodes[0].running = False
40+
41+
if __name__ == '__main__':
42+
HelpTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
'p2p_node_network_limited.py',
139139
'feature_blocksdir.py',
140140
'feature_config_args.py',
141+
'feature_help.py',
141142
# Don't append tests at the end to avoid merge conflicts
142143
# Put them in a random line within the section that fits their approximate run-time
143144
]

0 commit comments

Comments
 (0)