Commit 8b6852fd authored by ISWB Prasetya's avatar ISWB Prasetya
Browse files

adding timeout to generated Junit

parent 417b92e5
......@@ -658,19 +658,30 @@ public class SUITE implements Serializable {
pw.write(" log = Logger.getLogger(CONSTANTS.T3loggerName) ;\n");
pw.write(" S = SUITE.load(\"" + traceFile + "\") ;\n");
pw.write(" Pool pool = new Pool() ;\n") ;
pw.write(" info = S.exec(pool," + testclassName + ".class.getClassLoader(),"
+ "null,"
+ showLength + ","
+ showDepth + ","
+ showExcExecution + ","
+ "true ," // runAll is set to true
+ regressionMode + ","
+ "null) ;\n" // suppress violation reporting, else use System.err
pw.write(" Thread mainthread = Thread.currentThread() ;\n") ;
pw.write(" Thread suiterunner = new Thread() {\n") ;
pw.write(" public void run() {\n") ;
pw.write(" try { info = S.exec(pool," + testclassName + ".class.getClassLoader(),"
+ "null,"
+ showLength + ","
+ showDepth + ","
+ showExcExecution + ","
+ "true ," // runAll is set to true
+ regressionMode + ","
+ "null) ;\n" // suppress violation reporting, else use System.err
) ;
pw.write(" mainthread.interrupt(); }\n") ;
pw.write(" catch (Exception e) { } }\n") ;
pw.write(" } ;\n") ;
pw.write(" suiterunner.start() ;\n") ;
// wait 60 ms -- hard wired here:
pw.write(" try { mainthread.sleep(60000); log.warning(\"** JUnit's test suite execution has TIMED OUT.\"); }\n") ;
pw.write(" catch (Exception e) { log.warning(\"Test suite execution is done.\"); }") ;
pw.write(" }\n\n") ;
// test-1
pw.write(" @Test\n") ;
pw.write(" public void test1() throws Exception {\n") ;
pw.write(" if (info==null) { log.info(\"NO VERDICT.\"); return ; } \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");
......@@ -678,6 +689,7 @@ public class SUITE implements Serializable {
// test-2
pw.write(" @Test\n") ;
pw.write(" public void testExceptionTypeOnly() throws Exception {\n") ;
pw.write(" if (info==null) { log.info(\"NO VERDICT.\"); return ; } \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");
......@@ -685,6 +697,7 @@ public class SUITE implements Serializable {
// test-3
pw.write(" @Test\n") ;
pw.write(" public void testAllOracles() throws Exception {\n") ;
pw.write(" if (info==null) { log.info(\"NO VERDICT.\"); return ; } \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");
......
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