mirror of
https://github.com/holub/mame
synced 2025-06-30 16:00:01 +03:00
chdtest.py: added SHA1 check of output file (nw)
This commit is contained in:
parent
11c25fd89f
commit
0137a8a49d
@ -1,6 +1,7 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import hashlib
|
||||
|
||||
def runProcess(cmd):
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
@ -8,8 +9,8 @@ def runProcess(cmd):
|
||||
return process.returncode, stdout, stderr
|
||||
|
||||
def compareInfo(info1, info2):
|
||||
lines1 = info1.splitlines();
|
||||
lines2 = info2.splitlines();
|
||||
lines1 = info1.splitlines()
|
||||
lines2 = info2.splitlines()
|
||||
if not len(lines1) == len(lines2):
|
||||
return False
|
||||
|
||||
@ -25,6 +26,15 @@ def compareInfo(info1, info2):
|
||||
|
||||
return mismatch == False
|
||||
|
||||
def sha1sum(path):
|
||||
if not os.path.exists(path):
|
||||
return ""
|
||||
sha1 = hashlib.sha1()
|
||||
f = open(path, 'r')
|
||||
sha1.update(f.read())
|
||||
f.close()
|
||||
return sha1.hexdigest()
|
||||
|
||||
currentDirectory = os.path.dirname(os.path.realpath(__file__))
|
||||
inputPath = os.path.join(currentDirectory, 'input')
|
||||
outputPath = os.path.join(currentDirectory, "output")
|
||||
@ -106,6 +116,11 @@ for root, dirs, files in os.walk(inputPath):
|
||||
if not compareInfo(info1, info2):
|
||||
print d + " - info output differs"
|
||||
failure = True
|
||||
sha1_1 = sha1sum(tempFile)
|
||||
sha1_2 = sha1sum(outFile)
|
||||
if not sha1_1 == sha1_2:
|
||||
print "SHA1 mismatch - expected: " + sha1_2 + " found: " + sha1_1
|
||||
failure = True
|
||||
# TODO: extract and compare
|
||||
|
||||
if not failure:
|
||||
|
Loading…
Reference in New Issue
Block a user