trunk/src/regtests/chdman/chdtest.py
| r23772 | r23773 | |
| 1 | 1 | import os |
| 2 | 2 | import subprocess |
| 3 | 3 | import sys |
| 4 | import hashlib |
| 4 | 5 | |
| 5 | 6 | def runProcess(cmd): |
| 6 | 7 | process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| r23772 | r23773 | |
| 8 | 9 | return process.returncode, stdout, stderr |
| 9 | 10 | |
| 10 | 11 | def compareInfo(info1, info2): |
| 11 | | lines1 = info1.splitlines(); |
| 12 | | lines2 = info2.splitlines(); |
| 12 | lines1 = info1.splitlines() |
| 13 | lines2 = info2.splitlines() |
| 13 | 14 | if not len(lines1) == len(lines2): |
| 14 | 15 | return False |
| 15 | 16 | |
| r23772 | r23773 | |
| 25 | 26 | |
| 26 | 27 | return mismatch == False |
| 27 | 28 | |
| 29 | def 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 | |
| 28 | 38 | currentDirectory = os.path.dirname(os.path.realpath(__file__)) |
| 29 | 39 | inputPath = os.path.join(currentDirectory, 'input') |
| 30 | 40 | outputPath = os.path.join(currentDirectory, "output") |
| r23772 | r23773 | |
| 106 | 116 | if not compareInfo(info1, info2): |
| 107 | 117 | print d + " - info output differs" |
| 108 | 118 | 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 |
| 109 | 124 | # TODO: extract and compare |
| 110 | 125 | |
| 111 | 126 | if not failure: |