Previous 199869 Revisions Next

r20080 Saturday 5th January, 2013 at 16:17:42 UTC by Oliver Stöneberg
first version of chdman unit test / fixed dependies of tests target (nw)
[/trunk]makefile
[src/regtests/chdman]chdtest.py
[src/regtests/chdman/input/createcd_cue_empty]in.bin* in.cue*
[src/regtests/chdman/input/createcd_iso_empty]in.iso*
[src/regtests/chdman/output/createcd_cue_empty]out.chd*
[src/regtests/chdman/output/createcd_iso_empty]out.chd*

trunk/makefile
r20079r20080
684684all: default tools
685685
686686# TODO: move to a .mak file in the regtests folder?
687tests: default tools
687tests: tools
688688   @echo Running jedutil unittest
689689   $(PYTHON) src/regtests/jedutil/jedtest.py
690   #@echo Running chdman unittest
691   #$(PYTHON) src/regtests/chdman/chdtest.py
690   @echo Running chdman unittest
691   $(PYTHON) src/regtests/chdman/chdtest.py
692692
6936937Z_LIB = $(OBJ)/lib7z.a
694694
trunk/src/regtests/chdman/input/createcd_iso_empty/in.iso
trunk/src/regtests/chdman/input/createcd_cue_empty/in.bin
trunk/src/regtests/chdman/input/createcd_cue_empty/in.cue
r0r20080
1FILE "in.bin" BINARY
2  TRACK 01 MODE1/2352
3    INDEX 01 00:00:00
No newline at end of file
trunk/src/regtests/chdman/output/createcd_iso_empty/out.chd
trunk/src/regtests/chdman/output/createcd_cue_empty/out.chd
trunk/src/regtests/chdman/chdtest.py
r20079r20080
1import os
2import subprocess
3import sys
4
5def runProcess(cmd):
6   process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
7   (stdout, stderr) = process.communicate()
8   return process.returncode, stdout, stderr
9   
10def compareInfo(info1, info2):
11   lines1 = info1.splitlines();
12   lines2 = info2.splitlines();
13   if not len(lines1) == len(lines2):
14      return False
15   
16   mismatch = False
17   for i in range(len(lines1)):
18      if lines1[i].startswith("chdman - ") and lines2[i].startswith("chdman - "):
19         continue
20      if lines1[i].startswith("Input file:") and lines2[i].startswith("Input file:"):
21         continue
22      if not lines1[i] == lines2[i]:
23         mismatch = True
24         print lines1[i] + " - " + lines2[i]
25   
26   return mismatch == False
27
28currentDirectory = os.path.dirname(os.path.realpath(__file__))
29inputPath = os.path.join(currentDirectory, 'input')
30outputPath = os.path.join(currentDirectory, "output")
31tempPath = os.path.join(currentDirectory, "temp")
32if os.name == 'nt':
33   chdmanBin = os.path.normpath(os.path.join(currentDirectory, "..", "..", "..", "chdman.exe"))
34else:     
35   chdmanBin = os.path.normpath(os.path.join(currentDirectory, "..", "..", "..", "chdman"))
36
37if not os.path.exists(chdmanBin):
38   print chdmanBin + " does not exist"
39   sys.exit(1)
40
41if not os.path.exists(inputPath):
42   print inputPath + " does not exist"
43   sys.exit(1)
44   
45if not os.path.exists(inputPath):
46   print inputPath + " does not exist"
47   sys.exit(1)
48   
49failure = False
50
51for root, dirs, files in os.walk(inputPath):
52   for d in dirs:
53      inFile = os.path.join(root, d, "in")
54      # TODO: make this better
55      outFile = os.path.join(root, d, "out.chd").replace("input", "output")
56      tempFilePath = os.path.join(tempPath, d)
57      tempFile = os.path.join(tempFilePath, "out.chd")
58      cmd = ""
59      if not os.path.exists(tempFilePath):
60         os.makedirs(tempFilePath)
61      if d.startswith("createcd"):
62         ext = d.split("_", 2)[1]
63         inFile += "." + ext
64         cmd = chdmanBin + " createcd -f -i " + inFile + " -o " + tempFile
65      else:
66         print "unsupported mode"
67         continue
68      exitcode, stdout, stderr = runProcess(cmd)
69      if not exitcode == 0:
70         print d + " - command failed with " + str(exitcode) + " (" + stderr + ")"
71         failure = True
72      exitcode, stdout, stderr = runProcess(chdmanBin + " verify -i " + tempFile)
73      if not exitcode == 0:
74         print d + " - verify failed with " + str(exitcode) + " (" + stderr + ")"
75         failure = True
76      # TODO: store exected output of reference file as well and compare
77      exitcode, info1, stderr = runProcess(chdmanBin + " info -v -i " + tempFile)
78      if not exitcode == 0:
79         print d + " - info (temp) failed with " + str(exitcode) + " (" + stderr + ")"
80         failure = True
81      exitcode, info2, stderr = runProcess(chdmanBin + " info -v -i " + outFile)
82      if not exitcode == 0:
83         print d + " - info (output) failed with " + str(exitcode) + " (" + stderr + ")"
84         failure = True
85      if not compareInfo(info1, info2):
86         print d + " - info output differs"
87         failure = True
88      # TODO: extract and compare
89
90if not failure:
91   print "All tests finished successfully"
No newline at end of file

Previous 199869 Revisions Next


© 1997-2024 The MAME Team