summaryrefslogtreecommitdiffstats
path: root/src/regtests/chdman
diff options
context:
space:
mode:
authorGravatarGravatar Oliver Stöneberg <firewave@users.noreply.github.com>2013-01-05 16:17:42 +0000
committerGravatarGravatar Oliver Stöneberg <firewave@users.noreply.github.com>2013-01-05 16:17:42 +0000
commit585ecc7c2e26941929e1f56153e9745ce1ab4f11 (patch) (github)
tree9ea24d24d412d94f5969b110c4dcdeb77806b429 /src/regtests/chdman
parente18a790e6972fe248e0915384ee3660d1ad29a17 (diff)
downloadmame-585ecc7c2e26941929e1f56153e9745ce1ab4f11.tar.bz2
mame-585ecc7c2e26941929e1f56153e9745ce1ab4f11.zip
first version of chdman unit test / fixed dependies of tests target (nw)
Diffstat (limited to 'src/regtests/chdman')
-rw-r--r--src/regtests/chdman/chdtest.py91
-rw-r--r--src/regtests/chdman/input/createcd_cue_empty/in.binbin0 -> 1245184 bytes
-rw-r--r--src/regtests/chdman/input/createcd_cue_empty/in.cue3
-rw-r--r--src/regtests/chdman/input/createcd_iso_empty/in.isobin0 -> 1245184 bytes
-rw-r--r--src/regtests/chdman/output/createcd_cue_empty/out.chdbin0 -> 2279 bytes
-rw-r--r--src/regtests/chdman/output/createcd_iso_empty/out.chdbin0 -> 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
new file mode 100644
index 00000000000..0eb74d2e77a
--- /dev/null
+++ b/src/regtests/chdman/input/createcd_cue_empty/in.bin
Binary files differ
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
new file mode 100644
index 00000000000..af40397d87a
--- /dev/null
+++ b/src/regtests/chdman/input/createcd_iso_empty/in.iso
Binary files differ
diff --git a/src/regtests/chdman/output/createcd_cue_empty/out.chd b/src/regtests/chdman/output/createcd_cue_empty/out.chd
new file mode 100644
index 00000000000..8871f29e984
--- /dev/null
+++ b/src/regtests/chdman/output/createcd_cue_empty/out.chd
Binary files differ
diff --git a/src/regtests/chdman/output/createcd_iso_empty/out.chd b/src/regtests/chdman/output/createcd_iso_empty/out.chd
new file mode 100644
index 00000000000..a6b8d38890e
--- /dev/null
+++ b/src/regtests/chdman/output/createcd_iso_empty/out.chd
Binary files differ