X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2Fregression%2Fgenerate-cases.py;h=70da87d9163596332220e9a9b0fc34126be00116;hb=334d46c82420b40682d224b62f2930eb7d77af75;hp=18b55e9e28affd51a002b43002b7a36dcf6cf704;hpb=2fa210072055dd1d0dccd08192a6a6039d3ef8b9;p=fw%2Fsdcc diff --git a/support/regression/generate-cases.py b/support/regression/generate-cases.py index 18b55e9e..70da87d9 100644 --- a/support/regression/generate-cases.py +++ b/support/regression/generate-cases.py @@ -9,27 +9,21 @@ outdir = sys.argv[2] # Start of the test function table definition testfuntableheader = """ -static TESTFUNP _tests[] = { +void +__runSuite(void) +{ """ - # End of the test function table definition -testfuntablefooter = """\tNULL -}; +testfuntablefooter = """} """ # Code to generate the suite function testfunsuite = """ -TESTFUNP * -suite(void) -{ - return _tests; -} - -const char * -getSuiteName(void) +code const char * +__getSuiteName(void) { - return "{testcase}"; + return "{testcase}"; } """ @@ -68,8 +62,8 @@ class InstanceGenerator: self.functions = [] # Emit the suite wrapper into a temporary file self.tmpname = tempfile.mktemp() - (self.basename, self.ext) = re.split(r'\.', self.inname) - self.ext = '.' + self.ext + (self.dirname, self.filename) = os.path.split(self.inname) + (self.basename, self.ext) = os.path.splitext (self.filename) def permute(self, basepath, keys, trans = {}): """Permutes across all of the names. For each value, recursivly creates @@ -80,7 +74,7 @@ class InstanceGenerator: if len(keys) == 0: # End of the recursion. # Set the runtime substitutions. - trans['testcase'] = basepath + trans['testcase'] = re.sub(r'\\', r'\\\\', basepath) # Create the instance from the template T = TemplateDocument(self.tmpname) T.substitutions = trans @@ -111,12 +105,16 @@ class InstanceGenerator: # Emmit the suite table fout.write(testfuntableheader) + n = 0; for fun in self.functions: # Turn the function definition into a pointer fun = re.sub(r'\(\w+\)', '', fun) - fout.write("\t" + fun + ",\n") + fout.write(" __prints(\"Running " + fun + "\\n\");\n"); + fout.write(' ' + fun + "();\n") + n += 1; fout.write(testfuntablefooter) + fout.write("\nconst int __numCases = " + str(n) + ";\n") fout.write(testfunsuite); fout.close() @@ -176,12 +174,16 @@ class InstanceGenerator: # Remove the temporary file os.remove(self.tmpname) -# Check and parse the command line arguments -if len(sys.argv) < 3: - # PENDING: How to throw an error? - print "usage: generate-cases.py template.c outdir" +def main(): + # Check and parse the command line arguments + if len(sys.argv) < 3: + print "usage: generate-cases.py template.c outdir" + sys.exit(-1) + + # Input name is the first arg. -# Input name is the first arg. + s = InstanceGenerator(sys.argv[1]) + s.generate() -s = InstanceGenerator(sys.argv[1]) -s.generate() +if __name__ == '__main__': + main()