# 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}";
}
"""
# 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."""
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)
if __name__ == '__main__':
main()
-