X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2Fregression%2Fgenerate-cases.py;h=e2c08cc7b98f031a270e4df8af77c94397f263c7;hb=40b04e016f0390381414b38643fd5b6f4184974d;hp=81ebe8daaf96e21138ff428a3e40228430a18703;hpb=3a9211f3fa7fc3c3e3593149008f855e685457bd;p=fw%2Fsdcc diff --git a/support/regression/generate-cases.py b/support/regression/generate-cases.py index 81ebe8da..e2c08cc7 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 @@ -111,15 +105,19 @@ 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") + # Turn the function definition into a function call + 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() + return n def readfile(self): """Read in all of the input file.""" @@ -158,20 +156,22 @@ class InstanceGenerator: None else: # Pull out any test function names - if re.search(r'^test\w+\(\w+\)', line) != None: - self.functions.append(line) + m = re.match(r'^(?:\W*void\W+)?\W*(test\w*)\W*\(\W*void\W*\)', line) + if m != None: + self.functions.append(m.group(1)) def generate(self): """Main function. Generates all of the instances.""" self.readfile() self.parse() - self.writetemplate() + if self.writetemplate() == 0: + sys.stderr.write("Empty function list in " + self.inname + "!\n") # Create the output directory if it doesn't exist createdir(outdir) # Generate - self.permute(os.path.join(outdir, os.path.basename(self.basename)), self.replacements.keys()) + self.permute(os.path.join(outdir, self.basename), self.replacements.keys()) # Remove the temporary file os.remove(self.tmpname) @@ -189,4 +189,3 @@ def main(): if __name__ == '__main__': main() -