|
|
@ -31,6 +31,14 @@ import re |
|
|
|
|
|
|
|
|
|
|
|
from tests_config import * |
|
|
|
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 imported values are not defined then set to zero (or disabled) |
|
|
|
if 'ENABLE_WALLET' not in vars(): |
|
|
|
if 'ENABLE_WALLET' not in vars(): |
|
|
|
ENABLE_WALLET=0 |
|
|
|
ENABLE_WALLET=0 |
|
|
@ -43,29 +51,29 @@ if 'ENABLE_ZMQ' not in vars(): |
|
|
|
|
|
|
|
|
|
|
|
ENABLE_COVERAGE=0 |
|
|
|
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() |
|
|
|
opts = set() |
|
|
|
passOn = "" |
|
|
|
passon_args = "" |
|
|
|
p = re.compile("^--") |
|
|
|
PASSON_REGEX = re.compile("^--") |
|
|
|
|
|
|
|
|
|
|
|
bold = ("","") |
|
|
|
print_help = False |
|
|
|
if (os.name == 'posix'): |
|
|
|
|
|
|
|
bold = ('\033[0m', '\033[1m') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for arg in sys.argv[1:]: |
|
|
|
for arg in sys.argv[1:]: |
|
|
|
|
|
|
|
if arg == "--help" or arg == "-h" or arg == "-?": |
|
|
|
|
|
|
|
print_help = True |
|
|
|
|
|
|
|
break |
|
|
|
if arg == '--coverage': |
|
|
|
if arg == '--coverage': |
|
|
|
ENABLE_COVERAGE = 1 |
|
|
|
ENABLE_COVERAGE = 1 |
|
|
|
elif (p.match(arg) or arg == "-h"): |
|
|
|
elif PASSON_REGEX.match(arg): |
|
|
|
passOn += " " + arg |
|
|
|
passon_args += " " + arg |
|
|
|
else: |
|
|
|
else: |
|
|
|
opts.add(arg) |
|
|
|
opts.add(arg) |
|
|
|
|
|
|
|
|
|
|
|
#Set env vars |
|
|
|
#Set env vars |
|
|
|
buildDir = BUILDDIR |
|
|
|
|
|
|
|
if "BITCOIND" not in os.environ: |
|
|
|
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: |
|
|
|
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: |
|
|
|
if EXEEXT == ".exe" and "-win" not in opts: |
|
|
|
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9 |
|
|
|
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9 |
|
|
@ -153,48 +161,35 @@ testScriptsExt = [ |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
def runtests(): |
|
|
|
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 |
|
|
|
coverage = None |
|
|
|
|
|
|
|
|
|
|
|
if ENABLE_COVERAGE: |
|
|
|
if ENABLE_COVERAGE: |
|
|
|
coverage = RPCCoverage() |
|
|
|
coverage = RPCCoverage() |
|
|
|
print("Initializing coverage directory at %s\n" % coverage.dir) |
|
|
|
print("Initializing coverage directory at %s\n" % coverage.dir) |
|
|
|
|
|
|
|
flags = " --srcdir %s/src %s %s" % (BUILDDIR, coverage.flag if coverage else '', passon_args) |
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Run Tests |
|
|
|
#Run Tests |
|
|
|
for i in range(len(testScripts)): |
|
|
|
for t in test_list: |
|
|
|
if (len(opts) == 0 |
|
|
|
print("Running testscript %s%s%s ..." % (BOLD[1], t, BOLD[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])) |
|
|
|
|
|
|
|
time0 = time.time() |
|
|
|
time0 = time.time() |
|
|
|
subprocess.check_call( |
|
|
|
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))) |
|
|
|
print("Duration: %s s\n" % (int(time.time() - time0))) |
|
|
|
|
|
|
|
|
|
|
|
if coverage: |
|
|
|
if coverage: |
|
|
|