1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
#!/usr/bin/python3
# Csound6 Regresson Test Suite
# By Steven Yi<stevenyi at gmail dot com>John ffitch
import os
import sys
# from testUI import TestApplication
# try:
# # Python 3
# from tkinter import *
# except:
# # Python 2
# from Tkinter import *
# showUIatClose = False
csoundExecutable = ""
sourceDirectory = "."
class Test:
def __init__(self, fileName, description, expected=True):
self.fileName = fileName
self.description = ""
self.expected = expected
# def showUI(results):
# root = Tk()
# app = TestApplication(master=root)
# app.setResults(results.test_output_list)
# app.mainloop()
# root.destroy()
def showHelp():
message = """Csound Regression Test Suite by John ffitch
Runs tests and shows return values of tests. Results
are written to results.txt file.
"""
print(message)
def runTest():
runArgs = "-Wd -n"
tests = [
["buga1.csd", " "],
["buga.csd", " "],
["bugas.csd", " "],
["bugb.csd", " "],
["bugf.csd", " "],
["buginit.csd", " "],
["bugl.csd", " "],
["bugm.csd", " "],
["bugn.csd", "named instruments"],
["bugs.csd", "multipe strings in score"],
["bugsort.csd", "memory problem in sort"],
["bugst.csd", "string in score"],
["bugtrans.csd", "transegr"],
["bugbra.csd", "Open bracket in expression"],
["bugy.csd", "y in score"],
["bugbigargs.csd", "many arguments in score"],
["bugadsr.csd", "xadsr"],
["bug18.csd", "gen18"],
["bugaa.csd", "arate array arithmetic"],
["bugarray.csd", "krate array arithmetic"],
["bugausst.csd", "gausstrig"],
["bugblam.csd", "macro test"],
["bugcopy.csd", "copy mixed rate arrays"],
["bugftlen.csd", "table size oddity"],
["buglosc.csd", "non integer loscil"],
["bugpow.csd", "karray power"],
["bugrezzy.csd", "rezzy stabilised"],
["buggen31.csd", "gen31 test"],
["bugg.csd", "grain3"],
["bugline.csd", "comments in score"],
["arrayout.csd", "array dimension greater than nchls"],
["bugstr1.csd", "escapes in score strings"],
["arit.csd", "arithmetic bretween array anf scalar"],
["bugsice.csd", "testing slicearray and array length"],
["bugj.csd", "testing varios array operations"],
["bugsize.csd", "Showing size change in arrays"],
["bugmon.csd", "test arrray form of monitor"],
["bugname.csd", "recompilation of instr"],
["vbapa.csd", "array case of vbap"],
["bugi.csd", "i() and array access",1],
["gerr.csd", "array syntax error", 1],
["conditional.csd", "conditional expression"],
["gen16.csd", "overwriting in gen16"]
]
output = ""
tempfile = "csound_test_output.txt"
counter = 1
retVals = TestResults()
for t in tests:
filename = t[0]
desc = t[1]
expectedResult = (len(t) == 3) and 1 or 0
if(os.sep == '\\'):
executable = (csoundExecutable == "") and "..\..\csound.exe" or csoundExecutable
command = "%s %s %s 2> %s"%(executable, runArgs, filename, tempfile)
print(command)
retVal = os.system(command)
else:
executable = (csoundExecutable == "") and "../../csound" or csoundExecutable
command = "%s %s %s/%s 2> %s"%(executable, runArgs, sourceDirectory, filename, tempfile)
print(command)
retVal = os.system(command)
if hasattr(os, 'WIFEXITED') and os.WIFEXITED(retVal):
retVal = os.WEXITSTATUS(retVal)
out = ""
if (retVal == 0) == (expectedResult == 0):
retVals.tests_passsed += 1
out = "[pass] - "
else:
retVals.tests_failed += 1
out = "[FAIL] - "
out += "Test %i: %s (%s)\n\tReturn Code: %i\tExpected: %d\n"%(counter, desc, filename, retVal, expectedResult
)
print(out)
output += "%s\n"%("=" * 80)
output += "Test %i: %s (%s)\nReturn Code: %i\n"%(counter, desc, filename, retVal)
output += "%s\n\n"%("=" * 80)
f = open(tempfile, "r")
csOutput = ""
for line in f:
csOutput += line
output += csOutput
f.close()
retVals.add_result(t + [retVal, csOutput])
output += "\n\n"
counter += 1
# print(output)
print("%s\n\n"%("=" * 80))
print("Tests Passed: %i\nTests Failed: %i\n"%(retVals.tests_passsed, retVals.tests_failed))
f = open("results.txt", "w")
f.write(output)
f.flush()
f.close()
return retVals
class TestResults:
def __init__(self):
self.test_output_list = []
self.tests_failed = 0
self.tests_passsed = 0
def add_result(self, result):
self.test_output_list.append(result)
if __name__ == "__main__":
if(len(sys.argv) > 1):
for arg in sys.argv:
if (arg == "--help"):
showHelp()
sys.exit(0)
# elif arg == "--show-ui":
# showUIatClose = True
elif arg.startswith("--csound-executable="):
csoundExecutable = arg[20:]
print(csoundExecutable)
elif arg.startswith("--opcode6dir64="):
os.environ['OPCODE6DIR64'] = arg[15:]
print(os.environ['OPCODE6DIR64'])
elif arg.startswith("--source-dir="):
sourceDirectory = arg[13:]
results = runTest()
# if (showUIatClose):
# showUI(results)
if results.tests_failed:
exit(1)
else:
exit(0)
|