trunk/src/regtests/chdman/chdtest.py
| r23794 | r23795 | |
| 36 | 36 | f.close() |
| 37 | 37 | return sha1.hexdigest() |
| 38 | 38 | |
| 39 | def extractcdAndCompare(type): |
| 40 | extractFileDir = os.path.join(tempFilePath, type + "_output") |
| 41 | if not os.path.exists(extractFileDir): |
| 42 | os.makedirs(extractFileDir) |
| 43 | extractFileBase = os.path.join(extractFileDir, "extract") |
| 44 | extractFile = extractFileBase + "." + type |
| 45 | extractFileBin = extractFileBase + ".bin" |
| 46 | |
| 47 | exitcode, stdout, stderr = runProcess([chdmanBin, "extractcd", "-f", "-i", outFile, "-o", extractFile]) |
| 48 | if not exitcode == 0: |
| 49 | print d + " - extractcd (" + type + ") failed with " + str(exitcode) + " (" + stderr + ")" |
| 50 | failure = True |
| 51 | |
| 52 | sha1_extract = sha1sum(extractFile); |
| 53 | sha1_extract_bin = sha1sum(extractFileBin); |
| 54 | |
| 55 | extractFileDir = os.path.join(tempFilePath, type + "_temp") |
| 56 | if not os.path.exists(extractFileDir): |
| 57 | os.makedirs(extractFileDir) |
| 58 | extractFileBase = os.path.join(extractFileDir, "extract") |
| 59 | extractFile = extractFileBase + "." + type |
| 60 | extractFileBin = extractFileBase + ".bin" |
| 61 | |
| 62 | exitcode, stdout, stderr = runProcess([chdmanBin, "extractcd", "-f", "-i", tempFile, "-o", extractFile]) |
| 63 | if not exitcode == 0: |
| 64 | print d + " - extractcd (" + type + ") failed with " + str(exitcode) + " (" + stderr + ")" |
| 65 | failure = True |
| 66 | |
| 67 | sha1_extract_2 = sha1sum(extractFile); |
| 68 | sha1_extract_bin_2 = sha1sum(extractFileBin); |
| 69 | |
| 70 | if not sha1_extract == sha1_extract_2: |
| 71 | print "SHA1 mismatch (extractcd - " + type + " - toc) - expected: " + sha1_out + " found: " + sha1_temp |
| 72 | failure = True |
| 73 | |
| 74 | if not sha1_extract_bin == sha1_extract_bin_2: |
| 75 | print "SHA1 mismatch (extractcd - " + type + " - bin) - expected: " + sha1_out + " found: " + sha1_temp |
| 76 | failure = True |
| 77 | |
| 39 | 78 | currentDirectory = os.path.dirname(os.path.realpath(__file__)) |
| 40 | 79 | inputPath = os.path.join(currentDirectory, 'input') |
| 41 | 80 | outputPath = os.path.join(currentDirectory, "output") |
| r23794 | r23795 | |
| 126 | 165 | if not compareInfo(info1, info2): |
| 127 | 166 | print d + " - info output differs" |
| 128 | 167 | failure = True |
| 129 | | sha1_1 = sha1sum(tempFile) |
| 130 | | sha1_2 = sha1sum(outFile) |
| 131 | | if not sha1_1 == sha1_2: |
| 132 | | print "SHA1 mismatch - expected: " + sha1_2 + " found: " + sha1_1 |
| 168 | |
| 169 | # extract and compare |
| 170 | if command == "createcd": |
| 171 | extractcdAndCompare("toc") |
| 172 | extractcdAndCompare("cue") |
| 173 | # TODO: implement extraction for remaining cases |
| 174 | |
| 175 | # compare SHA1 of output files |
| 176 | sha1_out = sha1sum(outFile) |
| 177 | sha1_temp = sha1sum(tempFile) |
| 178 | if not sha1_out == sha1_temp: |
| 179 | print "SHA1 mismatch (output file) - expected: " + sha1_out + " found: " + sha1_temp |
| 133 | 180 | failure = True |
| 134 | | # TODO: extract and compare |
| 135 | 181 | |
| 136 | 182 | if failure: |
| 137 | 183 | print d + " failed" |