Merge pull request #5014

41d67c7 tests: fix python test-runner for windows (Cory Fields)
This commit is contained in:
Wladimir J. van der Laan 2014-10-01 08:50:17 +02:00
commit a6f3e9d843
No known key found for this signature in database
GPG key ID: 74810B012346C9A6
5 changed files with 32 additions and 19 deletions

View file

@ -793,7 +793,7 @@ AC_SUBST(BUILD_TEST)
AC_SUBST(BUILD_QT) AC_SUBST(BUILD_QT)
AC_SUBST(BUILD_TEST_QT) AC_SUBST(BUILD_TEST_QT)
AC_SUBST(MINIUPNPC_CPPFLAGS) AC_SUBST(MINIUPNPC_CPPFLAGS)
AC_CONFIG_FILES([Makefile src/Makefile share/setup.nsi share/qt/Info.plist]) AC_CONFIG_FILES([Makefile src/Makefile share/setup.nsi share/qt/Info.plist src/test/buildenv.py])
AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh]) AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh])
AC_CONFIG_FILES([qa/pull-tester/build-tests.sh],[chmod +x qa/pull-tester/build-tests.sh]) AC_CONFIG_FILES([qa/pull-tester/build-tests.sh],[chmod +x qa/pull-tester/build-tests.sh])
AC_OUTPUT AC_OUTPUT

View file

@ -7,9 +7,11 @@ import os
import json import json
import sys import sys
def bctest(testDir, testObj): def bctest(testDir, testObj, exeext):
execargs = testObj['exec']
execprog = testObj['exec'] + exeext
execargs = testObj['args']
execrun = [execprog] + execargs
stdinCfg = None stdinCfg = None
inputData = None inputData = None
if "input" in testObj: if "input" in testObj:
@ -22,12 +24,11 @@ def bctest(testDir, testObj):
if "output_cmp" in testObj: if "output_cmp" in testObj:
outputFn = testObj['output_cmp'] outputFn = testObj['output_cmp']
outputData = open(testDir + "/" + outputFn).read() outputData = open(testDir + "/" + outputFn).read()
proc = subprocess.Popen(execrun, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE,universal_newlines=True)
proc = subprocess.Popen(execargs, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try: try:
outs = proc.communicate(input=inputData) outs = proc.communicate(input=inputData)
except OSError: except OSError:
print("OSError, Failed to execute " + execargs[0]) print("OSError, Failed to execute " + execprog)
sys.exit(1) sys.exit(1)
if outputData and (outs[0] != outputData): if outputData and (outs[0] != outputData):
@ -41,13 +42,13 @@ def bctest(testDir, testObj):
print("Return code mismatch for " + outputFn) print("Return code mismatch for " + outputFn)
sys.exit(1) sys.exit(1)
def bctester(testDir, input_basename): def bctester(testDir, input_basename, buildenv):
input_filename = testDir + "/" + input_basename input_filename = testDir + "/" + input_basename
raw_data = open(input_filename).read() raw_data = open(input_filename).read()
input_data = json.loads(raw_data) input_data = json.loads(raw_data)
for testObj in input_data: for testObj in input_data:
bctest(testDir, testObj) bctest(testDir, testObj, buildenv.exeext)
sys.exit(0) sys.exit(0)

View file

@ -5,8 +5,9 @@
import os import os
import bctest import bctest
import buildenv
if __name__ == '__main__': if __name__ == '__main__':
bctest.bctester(os.environ["srcdir"] + "/test/data", bctest.bctester(os.environ["srcdir"] + "/test/data",
"bitcoin-util-test.json") "bitcoin-util-test.json",buildenv)

2
src/test/buildenv.py.in Normal file
View file

@ -0,0 +1,2 @@
#!/usr/bin/python
exeext="@EXEEXT@"

View file

@ -1,33 +1,41 @@
[ [
{ "exec": ["./bitcoin-tx", "-create"], { "exec": "././bitcoin-tx",
"args": ["-create"],
"output_cmp": "blanktx.hex" "output_cmp": "blanktx.hex"
}, },
{ "exec": ["./bitcoin-tx", "-"], { "exec": "./bitcoin-tx",
"args": ["-"],
"input": "blanktx.hex", "input": "blanktx.hex",
"output_cmp": "blanktx.hex" "output_cmp": "blanktx.hex"
}, },
{ "exec": ["./bitcoin-tx", "-", "delin=1"], { "exec": "./bitcoin-tx",
"args": ["-", "delin=1"],
"input": "tx394b54bb.hex", "input": "tx394b54bb.hex",
"output_cmp": "tt-delin1-out.hex" "output_cmp": "tt-delin1-out.hex"
}, },
{ "exec": ["./bitcoin-tx", "-", "delin=31"], { "exec": "./bitcoin-tx",
"args": ["-", "delin=31"],
"input": "tx394b54bb.hex", "input": "tx394b54bb.hex",
"return_code": 1 "return_code": 1
}, },
{ "exec": ["./bitcoin-tx", "-", "delout=1"], { "exec": "./bitcoin-tx",
"args": ["-", "delout=1"],
"input": "tx394b54bb.hex", "input": "tx394b54bb.hex",
"output_cmp": "tt-delout1-out.hex" "output_cmp": "tt-delout1-out.hex"
}, },
{ "exec": ["./bitcoin-tx", "-", "delout=2"], { "exec": "./bitcoin-tx",
"args": ["-", "delout=2"],
"input": "tx394b54bb.hex", "input": "tx394b54bb.hex",
"return_code": 1 "return_code": 1
}, },
{ "exec": ["./bitcoin-tx", "-", "locktime=317000"], { "exec": "./bitcoin-tx",
"args": ["-", "locktime=317000"],
"input": "tx394b54bb.hex", "input": "tx394b54bb.hex",
"output_cmp": "tt-locktime317000-out.hex" "output_cmp": "tt-locktime317000-out.hex"
}, },
{ "exec": { "exec": "./bitcoin-tx",
["./bitcoin-tx", "-create", "args":
["-create",
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0", "in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
"in=bf829c6bcf84579331337659d31f89dfd138f7f7785802d5501c92333145ca7c:18", "in=bf829c6bcf84579331337659d31f89dfd138f7f7785802d5501c92333145ca7c:18",
"in=22a6f904655d53ae2ff70e701a0bbd90aa3975c0f40bfc6cc996a9049e31cdfc:1", "in=22a6f904655d53ae2ff70e701a0bbd90aa3975c0f40bfc6cc996a9049e31cdfc:1",
@ -35,7 +43,8 @@
"outaddr=4:1P8yWvZW8jVihP1bzHeqfE4aoXNX8AVa46"], "outaddr=4:1P8yWvZW8jVihP1bzHeqfE4aoXNX8AVa46"],
"output_cmp": "txcreate1.hex" "output_cmp": "txcreate1.hex"
}, },
{ "exec": ["./bitcoin-tx", "-create", "outscript=0:"], { "exec": "./bitcoin-tx",
"args": ["-create", "outscript=0:"],
"output_cmp": "txcreate2.hex" "output_cmp": "txcreate2.hex"
} }
] ]