aboutsummaryrefslogtreecommitdiff
path: root/test/util
diff options
context:
space:
mode:
authordongsamb <dongsamb@gmail.com>2017-09-09 07:19:07 +0900
committerdongsamb <dongsamb@gmail.com>2017-12-09 15:14:41 +0900
commita3ac7672ed9c63b954d3f368a90616448d31b4c3 (patch)
treecd6bc9ae8aeea5748de323386475d8c0ef01dfee /test/util
parent4ef4dfebbc07d93d72899f60e01ca77a280c9122 (diff)
downloadbitcoin-a3ac7672ed9c63b954d3f368a90616448d31b4c3.tar.xz
Fix string concatenation to os.path.join and add exception case
Diffstat (limited to 'test/util')
-rwxr-xr-xtest/util/bitcoin-util-test.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/util/bitcoin-util-test.py b/test/util/bitcoin-util-test.py
index ef34955d90..64e826ad0b 100755
--- a/test/util/bitcoin-util-test.py
+++ b/test/util/bitcoin-util-test.py
@@ -48,7 +48,7 @@ def main():
def bctester(testDir, input_basename, buildenv):
""" Loads and parses the input file, runs all tests and reports results"""
- input_filename = testDir + "/" + input_basename
+ input_filename = os.path.join(testDir, input_basename)
raw_data = open(input_filename).read()
input_data = json.loads(raw_data)
@@ -77,7 +77,7 @@ def bctest(testDir, testObj, buildenv):
are not as expected. Error is caught by bctester() and reported.
"""
# Get the exec names and arguments
- execprog = buildenv["BUILDDIR"] + "/src/" + testObj['exec'] + buildenv["EXEEXT"]
+ execprog = os.path.join(buildenv["BUILDDIR"], "src", testObj["exec"] + buildenv["EXEEXT"])
execargs = testObj['args']
execrun = [execprog] + execargs
@@ -85,24 +85,28 @@ def bctest(testDir, testObj, buildenv):
stdinCfg = None
inputData = None
if "input" in testObj:
- filename = testDir + "/" + testObj['input']
+ filename = os.path.join(testDir, testObj["input"])
inputData = open(filename).read()
stdinCfg = subprocess.PIPE
# Read the expected output data (if there is any)
outputFn = None
outputData = None
+ outputType = None
if "output_cmp" in testObj:
outputFn = testObj['output_cmp']
outputType = os.path.splitext(outputFn)[1][1:] # output type from file extension (determines how to compare)
try:
- outputData = open(testDir + "/" + outputFn).read()
+ outputData = open(os.path.join(testDir, outputFn)).read()
except:
logging.error("Output file " + outputFn + " can not be opened")
raise
if not outputData:
logging.error("Output data missing for " + outputFn)
raise Exception
+ if not outputType:
+ logging.error("Output file %s does not have a file extension" % outputFn)
+ raise Exception
# Run the test
proc = subprocess.Popen(execrun, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)