diff options
author | 2013-01-05 16:17:42 +0000 | |
---|---|---|
committer | 2013-01-05 16:17:42 +0000 | |
commit | 585ecc7c2e26941929e1f56153e9745ce1ab4f11 (patch) | |
tree | 9ea24d24d412d94f5969b110c4dcdeb77806b429 /src | |
parent | e18a790e6972fe248e0915384ee3660d1ad29a17 (diff) |
first version of chdman unit test / fixed dependies of tests target (nw)
Diffstat (limited to 'src')
-rw-r--r-- | src/regtests/chdman/chdtest.py | 91 | ||||
-rw-r--r-- | src/regtests/chdman/input/createcd_cue_empty/in.bin | bin | 0 -> 1245184 bytes | |||
-rw-r--r-- | src/regtests/chdman/input/createcd_cue_empty/in.cue | 3 | ||||
-rw-r--r-- | src/regtests/chdman/input/createcd_iso_empty/in.iso | bin | 0 -> 1245184 bytes | |||
-rw-r--r-- | src/regtests/chdman/output/createcd_cue_empty/out.chd | bin | 0 -> 2279 bytes | |||
-rw-r--r-- | src/regtests/chdman/output/createcd_iso_empty/out.chd | bin | 0 -> 2017 bytes |
6 files changed, 94 insertions, 0 deletions
diff --git a/src/regtests/chdman/chdtest.py b/src/regtests/chdman/chdtest.py index e69de29bb2d..cd68f842e9c 100644 --- a/src/regtests/chdman/chdtest.py +++ b/src/regtests/chdman/chdtest.py @@ -0,0 +1,91 @@ +import os +import subprocess +import sys + +def runProcess(cmd): + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (stdout, stderr) = process.communicate() + return process.returncode, stdout, stderr + +def compareInfo(info1, info2): + lines1 = info1.splitlines(); + lines2 = info2.splitlines(); + if not len(lines1) == len(lines2): + return False + + mismatch = False + for i in range(len(lines1)): + if lines1[i].startswith("chdman - ") and lines2[i].startswith("chdman - "): + continue + if lines1[i].startswith("Input file:") and lines2[i].startswith("Input file:"): + continue + if not lines1[i] == lines2[i]: + mismatch = True + print lines1[i] + " - " + lines2[i] + + return mismatch == False + +currentDirectory = os.path.dirname(os.path.realpath(__file__)) +inputPath = os.path.join(currentDirectory, 'input') +outputPath = os.path.join(currentDirectory, "output") +tempPath = os.path.join(currentDirectory, "temp") +if os.name == 'nt': + chdmanBin = os.path.normpath(os.path.join(currentDirectory, "..", "..", "..", "chdman.exe")) +else: + chdmanBin = os.path.normpath(os.path.join(currentDirectory, "..", "..", "..", "chdman")) + +if not os.path.exists(chdmanBin): + print chdmanBin + " does not exist" + sys.exit(1) + +if not os.path.exists(inputPath): + print inputPath + " does not exist" + sys.exit(1) + +if not os.path.exists(inputPath): + print inputPath + " does not exist" + sys.exit(1) + +failure = False + +for root, dirs, files in os.walk(inputPath): + for d in dirs: + inFile = os.path.join(root, d, "in") + # TODO: make this better + outFile = os.path.join(root, d, "out.chd").replace("input", "output") + tempFilePath = os.path.join(tempPath, d) + tempFile = os.path.join(tempFilePath, "out.chd") + cmd = "" + if not os.path.exists(tempFilePath): + os.makedirs(tempFilePath) + if d.startswith("createcd"): + ext = d.split("_", 2)[1] + inFile += "." + ext + cmd = chdmanBin + " createcd -f -i " + inFile + " -o " + tempFile + else: + print "unsupported mode" + continue + exitcode, stdout, stderr = runProcess(cmd) + if not exitcode == 0: + print d + " - command failed with " + str(exitcode) + " (" + stderr + ")" + failure = True + exitcode, stdout, stderr = runProcess(chdmanBin + " verify -i " + tempFile) + if not exitcode == 0: + print d + " - verify failed with " + str(exitcode) + " (" + stderr + ")" + failure = True + # TODO: store exected output of reference file as well and compare + exitcode, info1, stderr = runProcess(chdmanBin + " info -v -i " + tempFile) + if not exitcode == 0: + print d + " - info (temp) failed with " + str(exitcode) + " (" + stderr + ")" + failure = True + exitcode, info2, stderr = runProcess(chdmanBin + " info -v -i " + outFile) + if not exitcode == 0: + print d + " - info (output) failed with " + str(exitcode) + " (" + stderr + ")" + failure = True + if not compareInfo(info1, info2): + print d + " - info output differs" + failure = True + # TODO: extract and compare + +if not failure: + print "All tests finished successfully"
\ No newline at end of file diff --git a/src/regtests/chdman/input/createcd_cue_empty/in.bin b/src/regtests/chdman/input/createcd_cue_empty/in.bin Binary files differnew file mode 100644 index 00000000000..0eb74d2e77a --- /dev/null +++ b/src/regtests/chdman/input/createcd_cue_empty/in.bin diff --git a/src/regtests/chdman/input/createcd_cue_empty/in.cue b/src/regtests/chdman/input/createcd_cue_empty/in.cue new file mode 100644 index 00000000000..ad7dcbb209b --- /dev/null +++ b/src/regtests/chdman/input/createcd_cue_empty/in.cue @@ -0,0 +1,3 @@ +FILE "in.bin" BINARY + TRACK 01 MODE1/2352 + INDEX 01 00:00:00
\ No newline at end of file diff --git a/src/regtests/chdman/input/createcd_iso_empty/in.iso b/src/regtests/chdman/input/createcd_iso_empty/in.iso Binary files differnew file mode 100644 index 00000000000..af40397d87a --- /dev/null +++ b/src/regtests/chdman/input/createcd_iso_empty/in.iso diff --git a/src/regtests/chdman/output/createcd_cue_empty/out.chd b/src/regtests/chdman/output/createcd_cue_empty/out.chd Binary files differnew file mode 100644 index 00000000000..8871f29e984 --- /dev/null +++ b/src/regtests/chdman/output/createcd_cue_empty/out.chd diff --git a/src/regtests/chdman/output/createcd_iso_empty/out.chd b/src/regtests/chdman/output/createcd_iso_empty/out.chd Binary files differnew file mode 100644 index 00000000000..a6b8d38890e --- /dev/null +++ b/src/regtests/chdman/output/createcd_iso_empty/out.chd |