Previous 199869 Revisions Next

r23773 Tuesday 18th June, 2013 at 13:31:34 UTC by Oliver Stöneberg
chdtest.py: added SHA1 check of output file (nw)
[src/regtests/chdman]chdtest.py

trunk/src/regtests/chdman/chdtest.py
r23772r23773
11import os
22import subprocess
33import sys
4import hashlib
45
56def runProcess(cmd):
67   process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
r23772r23773
89   return process.returncode, stdout, stderr
910   
1011def compareInfo(info1, info2):
11   lines1 = info1.splitlines();
12   lines2 = info2.splitlines();
12   lines1 = info1.splitlines()
13   lines2 = info2.splitlines()
1314   if not len(lines1) == len(lines2):
1415      return False
1516   
r23772r23773
2526   
2627   return mismatch == False
2728
29def sha1sum(path):
30   if not os.path.exists(path):
31      return ""
32   sha1 = hashlib.sha1()
33   f = open(path, 'r')
34   sha1.update(f.read())
35   f.close()
36   return sha1.hexdigest()
37
2838currentDirectory = os.path.dirname(os.path.realpath(__file__))
2939inputPath = os.path.join(currentDirectory, 'input')
3040outputPath = os.path.join(currentDirectory, "output")
r23772r23773
106116      if not compareInfo(info1, info2):
107117         print d + " - info output differs"
108118         failure = True
119      sha1_1 = sha1sum(tempFile)
120      sha1_2 = sha1sum(outFile)
121      if not sha1_1 == sha1_2:
122         print "SHA1 mismatch - expected: " + sha1_2 + " found: " + sha1_1
123         failure = True
109124      # TODO: extract and compare
110125
111126if not failure:

Previous 199869 Revisions Next


© 1997-2024 The MAME Team