2
2
# Copyright (c) 2014-2016 The Bitcoin Core developers
3
3
# Distributed under the MIT software license, see the accompanying
4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
-
6
5
"""
7
- Run Regression Test Suite
6
+ rpc-tests.py - run regression test suite
8
7
9
8
This module calls down into individual test cases via subprocess. It will
10
- forward all unrecognized arguments onto the individual test scripts, other
11
- than:
12
-
13
- - `-extended`: run the "extended" test suite in addition to the basic one.
14
- - `-win`: signal that this is running in a Windows environment, and we
15
- should run the tests.
16
- - `--coverage`: this generates a basic coverage report for the RPC
17
- interface.
9
+ forward all unrecognized arguments onto the individual test scripts.
18
10
19
11
For a description of arguments recognized by test scripts, see
20
12
`qa/pull-tester/test_framework/test_framework.py:BitcoinTestFramework.main`.
32
24
import re
33
25
34
26
# Parse arguments and pass through unrecognised args
35
- parser = argparse .ArgumentParser (add_help = False )
36
- parser .add_argument ('--coverage' , action = 'store_true' )
37
- parser .add_argument ('-extended' , action = 'store_true' )
38
- parser .add_argument ('--help' , '-h' , '-?' , action = 'store_true' )
39
- parser .add_argument ('--parallel' , type = int , default = 4 )
40
- parser .add_argument ('-win' , action = 'store_true' )
27
+ parser = argparse .ArgumentParser (add_help = False ,
28
+ usage = '%(prog)s [rpc-test.py options] [script options] [scripts]' ,
29
+ description = __doc__ ,
30
+ epilog = '''
31
+ Help text and arguments for individual test script:''' ,
32
+ formatter_class = argparse .RawTextHelpFormatter )
33
+ parser .add_argument ('--coverage' , action = 'store_true' , help = 'generate a basic coverage report for the RPC interface' )
34
+ parser .add_argument ('--extended' , action = 'store_true' , help = 'run the extended test suite in addition to the basic tests' )
35
+ parser .add_argument ('--help' , '-h' , '-?' , action = 'store_true' , help = 'print help text and exit' )
36
+ parser .add_argument ('--jobs' , '-j' , type = int , default = 4 , help = 'how many test scripts to run in parallel. Default=4.' )
37
+ parser .add_argument ('--nozmq' , action = 'store_true' , help = 'do not run the zmq tests' )
38
+ parser .add_argument ('--win' , action = 'store_true' , help = 'signal that this is running in a Windows environment and that we should run the tests' )
41
39
(args , unknown_args ) = parser .parse_known_args ()
42
40
43
41
#Create a set to store arguments and create the passon string
57
55
ENABLE_WALLET = config ["components" ]["ENABLE_WALLET" ] == "True"
58
56
ENABLE_UTILS = config ["components" ]["ENABLE_UTILS" ] == "True"
59
57
ENABLE_BITCOIND = config ["components" ]["ENABLE_BITCOIND" ] == "True"
60
- ENABLE_ZMQ = config ["components" ]["ENABLE_ZMQ" ] == "True"
58
+ ENABLE_ZMQ = config ["components" ]["ENABLE_ZMQ" ] == "True" and not args . nozmq
61
59
62
60
RPC_TESTS_DIR = config ["environment" ]["SRCDIR" ] + '/qa/rpc-tests/'
63
61
64
62
print_help = args .help
65
- run_parallel = args .parallel
63
+ jobs = args .jobs
66
64
67
65
#Set env vars
68
66
if "BITCOIND" not in os .environ :
71
69
if config ["environment" ]["EXEEXT" ] == ".exe" and not args .win :
72
70
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
73
71
# https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964
74
- print ("Win tests currently disabled by default. Use -win option to enable" )
72
+ print ("Win tests currently disabled by default. Use -- win option to enable" )
75
73
sys .exit (0 )
76
74
77
75
if not (ENABLE_WALLET and ENABLE_UTILS and ENABLE_BITCOIND ):
83
81
try :
84
82
import zmq
85
83
except ImportError :
86
- print ("ERROR: \" import zmq\" failed. Set ENABLE_ZMQ=0 or "
87
- "to run zmq tests, see dependency info in /qa/README.md." )
88
- # ENABLE_ZMQ=0
84
+ print ("ERROR: \" import zmq\" failed. Use -nozmq to run without the ZMQ tests."
85
+ "To run zmq tests, see dependency info in /qa/README.md." )
89
86
raise
90
87
91
88
BASE_SCRIPTS = [
@@ -202,7 +199,8 @@ def runtests():
202
199
# longer sorted.
203
200
204
201
if args .help :
205
- # Only print help of the first script and exit
202
+ # Print help for rpc-tests.py, then print help of the first script and exit.
203
+ parser .print_help ()
206
204
subprocess .check_call ((RPC_TESTS_DIR + test_list [0 ]).split () + ['-h' ])
207
205
sys .exit (0 )
208
206
@@ -216,15 +214,15 @@ def runtests():
216
214
if coverage :
217
215
flags .append (coverage .flag )
218
216
219
- if len (test_list ) > 1 and run_parallel > 1 :
217
+ if len (test_list ) > 1 and jobs > 1 :
220
218
# Populate cache
221
219
subprocess .check_output ([RPC_TESTS_DIR + 'create_cache.py' ] + flags )
222
220
223
221
#Run Tests
224
222
max_len_name = len (max (test_list , key = len ))
225
223
time_sum = 0
226
224
time0 = time .time ()
227
- job_queue = RPCTestHandler (run_parallel , test_list , flags )
225
+ job_queue = RPCTestHandler (jobs , test_list , flags )
228
226
results = BOLD [1 ] + "%s | %s | %s\n \n " % ("TEST" .ljust (max_len_name ), "PASSED" , "DURATION" ) + BOLD [0 ]
229
227
all_passed = True
230
228
for _ in range (len (test_list )):
0 commit comments