trunk/src/regtests/chdman/chdtest.py
| r23793 | r23794 | |
| 2 | 2 | import subprocess |
| 3 | 3 | import sys |
| 4 | 4 | import hashlib |
| 5 | import shutil |
| 5 | 6 | |
| 6 | 7 | def runProcess(cmd): |
| 7 | 8 | process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| r23793 | r23794 | |
| 52 | 53 | print inputPath + " does not exist" |
| 53 | 54 | sys.exit(1) |
| 54 | 55 | |
| 55 | | if not os.path.exists(inputPath): |
| 56 | | print inputPath + " does not exist" |
| 56 | if not os.path.exists(outputPath): |
| 57 | print outputPath + " does not exist" |
| 57 | 58 | sys.exit(1) |
| 58 | 59 | |
| 59 | | failure = False |
| 60 | shutil.rmtree(tempPath) |
| 61 | |
| 62 | total_failure = False |
| 60 | 63 | |
| 61 | 64 | for root, dirs, files in os.walk(inputPath): |
| 62 | 65 | for d in dirs: |
| 63 | 66 | if d.startswith("."): |
| 64 | 67 | continue |
| 65 | 68 | |
| 69 | failure = False |
| 70 | |
| 66 | 71 | command = ext = d.split("_", 2)[0] |
| 67 | 72 | inFile = os.path.join(root, d, "in") |
| 68 | 73 | # TODO: make this better |
| r23793 | r23794 | |
| 96 | 101 | cmd = [chdmanBin, command, "-f", "-i", inFile, "-o", tempFile] + params |
| 97 | 102 | else: |
| 98 | 103 | cmd = [chdmanBin, command, "-f", "-o", tempFile] + params |
| 104 | |
| 99 | 105 | exitcode, stdout, stderr = runProcess(cmd) |
| 100 | 106 | if not exitcode == 0: |
| 101 | 107 | print d + " - command failed with " + str(exitcode) + " (" + stderr + ")" |
| 102 | 108 | failure = True |
| 109 | |
| 110 | # verify |
| 103 | 111 | exitcode, stdout, stderr = runProcess([chdmanBin, "verify", "-i", tempFile]) |
| 104 | 112 | if not exitcode == 0: |
| 105 | 113 | print d + " - verify failed with " + str(exitcode) + " (" + stderr + ")" |
| 106 | 114 | failure = True |
| 115 | |
| 116 | # compare info |
| 107 | 117 | # TODO: store expected output of reference file as well and compare |
| 108 | 118 | exitcode, info1, stderr = runProcess([chdmanBin, "info", "-v", "-i", tempFile]) |
| 109 | 119 | if not exitcode == 0: |
| r23793 | r23794 | |
| 123 | 133 | failure = True |
| 124 | 134 | # TODO: extract and compare |
| 125 | 135 | |
| 126 | | if not failure: |
| 136 | if failure: |
| 137 | print d + " failed" |
| 138 | total_failure = True |
| 139 | |
| 140 | if not total_failure: |
| 127 | 141 | print "All tests finished successfully" |
| | No newline at end of file |