Commit 417b92e5 authored by ISWB Prasetya's avatar ISWB Prasetya
Browse files

slight improvement on generated junit

parent 480de26d
......@@ -21,7 +21,7 @@
debug="on"
destdir="${build}/classes"
source="1.8"
target="1.8">
target="1.8">
<compilerarg value="-Xlint"/>
<classpath>
<fileset dir="${libs}">
......
......@@ -31,7 +31,6 @@ import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import Sequenic.T3.CONSTANTS;
import Sequenic.T3.ExceptionOracleError;
import Sequenic.T3.Info.FieldPairsCoverage;
......@@ -651,13 +650,16 @@ public class SUITE implements Serializable {
pw.write("public class " + testclassName + " {\n\n") ;
pw.write(" public " + testclassName + "() { }\n\n") ;
pw.write(" static SUITE S = null ;\n") ;
pw.write(" static SUITE_RT_info info = null ;\n\n") ;
// test-1
pw.write(" @Test\n") ;
pw.write(" public void test1() throws Exception {\n") ;
pw.write(" if (S==null) S = SUITE.load(\"" + traceFile + "\") ;\n") ;
pw.write(" static SUITE_RT_info info = null ;\n") ;
pw.write(" static Logger log ;\n\n") ;
// loading and executing the trace file; only need to do this 1x for all test cases in the class:
pw.write(" @BeforeClass\n") ;
pw.write(" public static void loadtrace() throws Exception {\n") ;
pw.write(" log = Logger.getLogger(CONSTANTS.T3loggerName) ;\n");
pw.write(" S = SUITE.load(\"" + traceFile + "\") ;\n");
pw.write(" Pool pool = new Pool() ;\n") ;
pw.write(" if (info==null) info = S.exec(pool,getClass().getClassLoader(),null,"
pw.write(" info = S.exec(pool," + testclassName + ".class.getClassLoader(),"
+ "null,"
+ showLength + ","
+ showDepth + ","
+ showExcExecution + ","
......@@ -665,46 +667,27 @@ public class SUITE implements Serializable {
+ regressionMode + ","
+ "null) ;\n" // suppress violation reporting, else use System.err
) ;
pw.write(" boolean verdict = !info.seenCrash() ;\n");
pw.write(" if (verdict) Logger.getLogger(CONSTANTS.T3loggerName).info(\"PASS\") ;\n") ;
pw.write(" else Logger.getLogger(CONSTANTS.T3loggerName).info(\"FAIL\") ;\n") ;
pw.write(" assertTrue(verdict) ;\n");
pw.write(" }\n\n") ;
// test-1
pw.write(" @Test\n") ;
pw.write(" public void test1() throws Exception {\n") ;
pw.write(" boolean verdict = !info.seenCrash() ;\n");
pw.write(" if (verdict) log.info(\"PASS\") ; else log.info(\"FAIL\") ;\n") ;
pw.write(" assertTrue(verdict) ;\n");
pw.write(" }\n\n") ;
// test-2
pw.write(" @Test\n") ;
pw.write(" public void testExceptionTypeOnly() throws Exception {\n") ;
pw.write(" if (S==null) S = SUITE.load(\"" + traceFile + "\") ;\n") ;
pw.write(" Pool pool = new Pool() ;\n") ;
pw.write(" if (info==null) info = S.exec(pool,getClass().getClassLoader(),null,"
+ showLength + ","
+ showDepth + ","
+ showExcExecution + ","
+ "true ," // runAll is set to true
+ regressionMode + ","
+ "null) ;\n" // suppress violation reporting, else use System.err
) ;
pw.write(" boolean verdict = info.inconsistentExc.isEmpty() ;\n");
pw.write(" if (verdict) Logger.getLogger(CONSTANTS.T3loggerName).info(\"PASS\") ;\n") ;
pw.write(" else Logger.getLogger(CONSTANTS.T3loggerName).info(\"FAIL\") ;\n") ;
pw.write(" assertTrue(verdict) ;\n");
pw.write(" boolean verdict = info.inconsistentExc.isEmpty() ;\n");
pw.write(" if (verdict) log.info(\"PASS\") ; else log.info(\"FAIL\") ;\n") ;
pw.write(" assertTrue(verdict) ;\n");
pw.write(" }\n\n") ;
// test-3
pw.write(" @Test\n") ;
pw.write(" public void testAllOracles() throws Exception {\n") ;
pw.write(" if (S==null) S = SUITE.load(\"" + traceFile + "\") ;\n") ;
pw.write(" Pool pool = new Pool() ;\n") ;
pw.write(" if (info==null) info = S.exec(pool,getClass().getClassLoader(),null,"
+ showLength + ","
+ showDepth + ","
+ showExcExecution + ","
+ "true ," // don't run all, stop at first violation
+ regressionMode + ","
+ "null) ;\n" // suppress violation reporting, else use System.err
) ;
pw.write(" boolean verdict = info.violating.isEmpty() ;\n");
pw.write(" if (verdict) Logger.getLogger(CONSTANTS.T3loggerName).info(\"PASS\") ;\n") ;
pw.write(" else Logger.getLogger(CONSTANTS.T3loggerName).info(\"FAIL\") ;\n") ;
pw.write(" assertTrue(verdict) ;\n");
pw.write(" boolean verdict = info.violating.isEmpty() ;\n");
pw.write(" if (verdict) log.info(\"PASS\") ; else log.info(\"FAIL\") ;\n") ;
pw.write(" assertTrue(verdict) ;\n");
pw.write(" }\n") ;
pw.write("}") ;
pw.flush(); pw.close();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment