aboutsummaryrefslogtreecommitdiff
path: root/qa/pull-tester
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2016-04-27 22:29:52 +0200
committerMarcoFalke <falke.marco@gmail.com>2016-05-06 12:43:34 +0200
commitfabbf6bd62c1d8a290841b63fb1e5acec42ba3b0 (patch)
tree3f4a6a90e0d7db5d13ce126b3d854537c29409e2 /qa/pull-tester
parent77b637f20e8cb91cf007bf416b603ca362385cdb (diff)
downloadbitcoin-fabbf6bd62c1d8a290841b63fb1e5acec42ba3b0.tar.xz
[qa] Refactor test_framework and pull tester
* log to stdout * increase range for p2p and rpc ports * UPPERCASE_CONSTANTS * Stop nodes on CTRL+C
Diffstat (limited to 'qa/pull-tester')
-rwxr-xr-xqa/pull-tester/rpc-tests.py83
1 files changed, 39 insertions, 44 deletions
diff --git a/qa/pull-tester/rpc-tests.py b/qa/pull-tester/rpc-tests.py
index 15153b7f58..e8434b4a60 100755
--- a/qa/pull-tester/rpc-tests.py
+++ b/qa/pull-tester/rpc-tests.py
@@ -31,6 +31,14 @@ import re
from tests_config import *
+BOLD = ("","")
+if os.name == 'posix':
+ # primitive formatting on supported
+ # terminal via ANSI escape sequences:
+ BOLD = ('\033[0m', '\033[1m')
+
+RPC_TESTS_DIR = BUILDDIR + '/qa/rpc-tests/'
+
#If imported values are not defined then set to zero (or disabled)
if 'ENABLE_WALLET' not in vars():
ENABLE_WALLET=0
@@ -43,29 +51,29 @@ if 'ENABLE_ZMQ' not in vars():
ENABLE_COVERAGE=0
-#Create a set to store arguments and create the passOn string
+#Create a set to store arguments and create the passon string
opts = set()
-passOn = ""
-p = re.compile("^--")
+passon_args = ""
+PASSON_REGEX = re.compile("^--")
-bold = ("","")
-if (os.name == 'posix'):
- bold = ('\033[0m', '\033[1m')
+print_help = False
for arg in sys.argv[1:]:
+ if arg == "--help" or arg == "-h" or arg == "-?":
+ print_help = True
+ break
if arg == '--coverage':
ENABLE_COVERAGE = 1
- elif (p.match(arg) or arg == "-h"):
- passOn += " " + arg
+ elif PASSON_REGEX.match(arg):
+ passon_args += " " + arg
else:
opts.add(arg)
#Set env vars
-buildDir = BUILDDIR
if "BITCOIND" not in os.environ:
- os.environ["BITCOIND"] = buildDir + '/src/bitcoind' + EXEEXT
+ os.environ["BITCOIND"] = BUILDDIR + '/src/bitcoind' + EXEEXT
if "BITCOINCLI" not in os.environ:
- os.environ["BITCOINCLI"] = buildDir + '/src/bitcoin-cli' + EXEEXT
+ os.environ["BITCOINCLI"] = BUILDDIR + '/src/bitcoin-cli' + EXEEXT
if EXEEXT == ".exe" and "-win" not in opts:
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
@@ -153,48 +161,35 @@ testScriptsExt = [
]
def runtests():
+ test_list = []
+ if '-extended' in opts:
+ test_list = testScripts + testScriptsExt
+ elif len(opts) == 0 or (len(opts) == 1 and "-win" in opts):
+ test_list = testScripts
+ else:
+ for t in testScripts + testScriptsExt:
+ if t in opts or re.sub(".py$", "", t) in opts:
+ test_list.append(t)
+
+ if print_help:
+ # Help should be the same for all scripts, so just
+ # call the first and exit
+ subprocess.check_call(RPC_TESTS_DIR + test_list[0] + ' -h', shell=True)
+ sys.exit(0)
+
coverage = None
if ENABLE_COVERAGE:
coverage = RPCCoverage()
print("Initializing coverage directory at %s\n" % coverage.dir)
-
- rpcTestDir = buildDir + '/qa/rpc-tests/'
- run_extended = '-extended' in opts
- cov_flag = coverage.flag if coverage else ''
- flags = " --srcdir %s/src %s %s" % (buildDir, cov_flag, passOn)
+ flags = " --srcdir %s/src %s %s" % (BUILDDIR, coverage.flag if coverage else '', passon_args)
#Run Tests
- for i in range(len(testScripts)):
- if (len(opts) == 0
- or (len(opts) == 1 and "-win" in opts )
- or run_extended
- or testScripts[i] in opts
- or re.sub(".py$", "", testScripts[i]) in opts ):
-
- print("Running testscript %s%s%s ..." % (bold[1], testScripts[i], bold[0]))
- time0 = time.time()
- subprocess.check_call(
- rpcTestDir + testScripts[i] + flags, shell=True)
- print("Duration: %s s\n" % (int(time.time() - time0)))
-
- # exit if help is called so we print just one set of
- # instructions
- p = re.compile(" -h| --help")
- if p.match(passOn):
- sys.exit(0)
-
- # Run Extended Tests
- for i in range(len(testScriptsExt)):
- if (run_extended or testScriptsExt[i] in opts
- or re.sub(".py$", "", testScriptsExt[i]) in opts):
-
- print(
- "Running 2nd level testscript "
- + "%s%s%s ..." % (bold[1], testScriptsExt[i], bold[0]))
+ for t in test_list:
+ print("Running testscript %s%s%s ..." % (BOLD[1], t, BOLD[0]))
time0 = time.time()
subprocess.check_call(
- rpcTestDir + testScriptsExt[i] + flags, shell=True)
+ RPC_TESTS_DIR + t + flags, shell=True)
print("Duration: %s s\n" % (int(time.time() - time0)))
if coverage: