-
Notifications
You must be signed in to change notification settings - Fork 70
/
Main.java.template
117 lines (86 loc) · 3.11 KB
/
Main.java.template
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
package testcasesupport;
import testcasesupport.*;
public class Main {
public static void main(String[] args) {
if(args.length != 0) {
if(args[0].equals("-h") || args[0].equals("--help")) {
System.err.println("To use this main, you can either run the program with no " +
"command line arguments to run all test cases or you can specify one or more classes to test");
System.err.println("For example:");
System.err.println("java testcasesupport.Main testcases.CWE690_Unchecked_Return_Value_to_NULL_Pointer_Dereference.custom_function.CWE690_Unchecked_Return_Value_to_NULL_Pointer_Dereference__custom_function_01 testcases.CWE481_Assigning_instead_of_Comparing.bool.CWE481_Assigning_instead_of_Comparing__bool_01");
System.exit(1);
}
/* User supplied some class names on the command line, just use those with introspection
*
* String classNames[] = { "CWE481_Assigning_instead_of_Comparing__boolean_01",
* "CWE476_Null_Pointer_Dereference__getProperty_01" };
* could read class names from command line or use
* http://sadun-util.sourceforge.net/api/org/sadun/util/
* ClassPackageExplorer.html
*/
for (String className : args) {
try {
/* String classNameWithPackage = "testcases." + className; */
/* IO.writeLine("classNameWithPackage = " + classNameWithPackage); */
Class<?> myClass = Class.forName(className);
AbstractTestCase myObject = (AbstractTestCase) myClass
.newInstance();
myObject.runTest(className);
} catch (Exception ex) {
IO.writeLine("Could not run test for class " + className);
ex.printStackTrace();
}
IO.writeLine(""); /* leave a blank line between classes */
}
} else {
/* No command line args were used, we want to run every testcase */
/* needed to separate these calls into other methods because
we were running into the size limit Java has for a single method */
runTestCWE1();
runTestCWE2();
runTestCWE3();
runTestCWE4();
runTestCWE5();
runTestCWE6();
runTestCWE7();
runTestCWE8();
runTestCWE9();
}
}
private static void runTestCWE1() {
/* BEGIN-AUTOGENERATED-JAVA-TESTS-1 */
/* END-AUTOGENERATED-JAVA-TESTS-1 */
}
private static void runTestCWE2() {
/* BEGIN-AUTOGENERATED-JAVA-TESTS-2 */
/* END-AUTOGENERATED-JAVA-TESTS-2 */
}
private static void runTestCWE3() {
/* BEGIN-AUTOGENERATED-JAVA-TESTS-3 */
/* END-AUTOGENERATED-JAVA-TESTS-3 */
}
private static void runTestCWE4() {
/* BEGIN-AUTOGENERATED-JAVA-TESTS-4 */
/* END-AUTOGENERATED-JAVA-TESTS-4 */
}
private static void runTestCWE5() {
/* BEGIN-AUTOGENERATED-JAVA-TESTS-5 */
/* END-AUTOGENERATED-JAVA-TESTS-5 */
}
private static void runTestCWE6() {
/* BEGIN-AUTOGENERATED-JAVA-TESTS-6 */
/* END-AUTOGENERATED-JAVA-TESTS-6 */
}
private static void runTestCWE7() {
/* BEGIN-AUTOGENERATED-JAVA-TESTS-7 */
/* END-AUTOGENERATED-JAVA-TESTS-7 */
}
private static void runTestCWE8() {
/* BEGIN-AUTOGENERATED-JAVA-TESTS-8 */
/* END-AUTOGENERATED-JAVA-TESTS-8 */
}
private static void runTestCWE9() {
/* BEGIN-AUTOGENERATED-JAVA-TESTS-9 */
/* END-AUTOGENERATED-JAVA-TESTS-9 */
}
}