changeset 59:52dc3f38237c

Treat the test error (e.g. exception) properly.
author shade
date Thu, 03 Oct 2013 15:36:46 +0400
parents b508dbc99189
children db4410e10574
files harness/src/main/java/org/openjdk/jcstress/JCStress.java harness/src/main/java/org/openjdk/jcstress/infra/Status.java harness/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java harness/src/main/java/org/openjdk/jcstress/infra/grading/ExceptionReportPrinter.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor1_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Arbiter1_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor3_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor4_Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java harness/src/main/java/org/openjdk/jcstress/infra/runners/TerminationRunner.java
diffstat 11 files changed, 81 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/harness/src/main/java/org/openjdk/jcstress/JCStress.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/JCStress.java	Thu Oct 03 15:36:46 2013 +0400
@@ -230,13 +230,7 @@
 
             @Override
             public void run() {
-                try {
-                    runner.run();
-                } catch (InterruptedException e) {
-                    throw new IllegalStateException(e);
-                } catch (ExecutionException e) {
-                    throw new IllegalStateException(e);
-                }
+                runner.run();
             }
         });
     }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/Status.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/Status.java	Thu Oct 03 15:36:46 2013 +0400
@@ -35,7 +35,8 @@
     API_MISMATCH(1),
     CHECK_TEST_ERROR(2),
     TIMEOUT_ERROR(3),
-    VM_ERROR(4);
+    TEST_ERROR(4),
+    VM_ERROR(5);
 
     private int severity;
 
--- a/harness/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Thu Oct 03 15:36:46 2013 +0400
@@ -115,19 +115,21 @@
     private void parseSummary(PrintWriter output, TestResult r) {
         switch (r.status()) {
             case TIMEOUT_ERROR:
-                output.println();
                 printLine(output, "TIMEOUT", r);
-                parseVerbose(output, r);
-                output.println();
                 return;
             case CHECK_TEST_ERROR:
-                printLine(output, "CHECK ERROR", r);
+            case TEST_ERROR:
+                output.println();
+                printLine(output, "ERROR", r);
+                for (String data : r.getAuxData()) {
+                    output.println(data);
+                }
+                output.println();
                 return;
             case VM_ERROR:
                 output.println();
                 printLine(output, "VM ERROR", r);
-                List<String> auxData = r.getAuxData();
-                for (String data : auxData) {
+                for (String data : r.getAuxData()) {
                     output.println(data);
                 }
                 output.println();
--- a/harness/src/main/java/org/openjdk/jcstress/infra/grading/ExceptionReportPrinter.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/grading/ExceptionReportPrinter.java	Thu Oct 03 15:36:46 2013 +0400
@@ -123,7 +123,10 @@
     public void emitTest(TestResult result, Test description) throws FileNotFoundException, JAXBException {
         switch (result.status()) {
             case CHECK_TEST_ERROR:
-                failures.add(result.getName() + " had failed the pre-test.");
+                failures.add(result.getName() + " had failed with the pre-test error.");
+                break;
+            case TEST_ERROR:
+                failures.add(result.getName() + " had failed with the test error.");
                 break;
             case TIMEOUT_ERROR:
                 failures.add(result.getName() + " had timed out.");
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor1_Runner.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor1_Runner.java	Thu Oct 03 15:36:46 2013 +0400
@@ -37,7 +37,6 @@
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -58,12 +57,8 @@
     /**
      * Run the test.
      * This method blocks until test is complete
-     *
-     * @throws InterruptedException
-     * @throws java.util.concurrent.ExecutionException
-     *
      */
-    public void run() throws ExecutionException, InterruptedException {
+    public void run() {
         testLog.println("Running " + test.getClass().getName());
 
         try {
@@ -115,7 +110,7 @@
     }
 
 
-    private Counter<R> run(int time) throws InterruptedException, ExecutionException {
+    private Counter<R> run(int time) {
 
         @SuppressWarnings("unchecked")
         final S[] poison = (S[]) new Object[0];
@@ -155,13 +150,15 @@
                 }
         ));
 
-        TimeUnit.MILLISECONDS.sleep(time);
+        try {
+            TimeUnit.MILLISECONDS.sleep(time);
+        } catch (InterruptedException e) {
+            // do nothing
+        }
 
         controlHolder.isStopped = true;
 
-        if (!waitFor(tasks)) {
-            dumpFailure(test, Status.TIMEOUT_ERROR);
-        }
+        waitFor(test, tasks);
 
         return counter;
     }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Arbiter1_Runner.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Arbiter1_Runner.java	Thu Oct 03 15:36:46 2013 +0400
@@ -37,7 +37,6 @@
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -55,7 +54,7 @@
         this.test = test;
     }
 
-    public void run() throws InterruptedException, ExecutionException {
+    public void run() {
         testLog.println("Running " + test.getClass().getName());
 
         try {
@@ -109,7 +108,7 @@
         return 3;
     }
 
-    public Counter<R> run(int time) throws InterruptedException, ExecutionException {
+    public Counter<R> run(int time) {
         @SuppressWarnings("unchecked")
         final S[] poison = (S[]) new Object[0];
 
@@ -169,13 +168,15 @@
         );
         tasks.add(a2);
 
-        TimeUnit.MILLISECONDS.sleep(time);
+        try {
+            TimeUnit.MILLISECONDS.sleep(time);
+        } catch (InterruptedException e) {
+            // do nothing
+        }
 
         controlHolder.isStopped = true;
 
-        if (!waitFor(tasks)) {
-            dumpFailure(test, Status.TIMEOUT_ERROR);
-        }
+        waitFor(test, tasks);
 
         return counter;
     }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Runner.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Runner.java	Thu Oct 03 15:36:46 2013 +0400
@@ -37,7 +37,6 @@
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -59,11 +58,8 @@
      * Run the test.
      * This method blocks until test is complete
      *
-     * @throws InterruptedException
-     * @throws java.util.concurrent.ExecutionException
-     *
      */
-    public void run() throws ExecutionException, InterruptedException {
+    public void run() {
         testLog.println("Running " + test.getClass().getName());
 
         try {
@@ -116,7 +112,7 @@
         return 2;
     }
 
-    private Counter<R> run(int time) throws InterruptedException, ExecutionException {
+    private Counter<R> run(int time) {
 
         @SuppressWarnings("unchecked")
         final S[] poison = (S[]) new Object[0];
@@ -165,13 +161,15 @@
                 }
         ));
 
-        TimeUnit.MILLISECONDS.sleep(time);
+        try {
+            TimeUnit.MILLISECONDS.sleep(time);
+        } catch (InterruptedException e) {
+            // do nothing
+        }
 
         controlHolder.isStopped = true;
 
-        if (!waitFor(tasks)) {
-            dumpFailure(test, Status.TIMEOUT_ERROR);
-        }
+        waitFor(test, tasks);
 
         return counter;
     }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor3_Runner.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor3_Runner.java	Thu Oct 03 15:36:46 2013 +0400
@@ -37,7 +37,6 @@
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -58,12 +57,8 @@
     /**
      * Run the test.
      * This method blocks until test is complete
-     *
-     * @throws InterruptedException
-     * @throws java.util.concurrent.ExecutionException
-     *
      */
-    public void run() throws ExecutionException, InterruptedException {
+    public void run() {
         testLog.println("Running " + test.getClass().getName());
 
         try {
@@ -118,7 +113,7 @@
         return 3;
     }
 
-    private Counter<R> run(int time) throws InterruptedException, ExecutionException {
+    private Counter<R> run(int time) {
 
         @SuppressWarnings("unchecked")
         final S[] poison = (S[]) new Object[0];
@@ -176,13 +171,15 @@
                 }
         ));
 
-        TimeUnit.MILLISECONDS.sleep(time);
+        try {
+            TimeUnit.MILLISECONDS.sleep(time);
+        } catch (InterruptedException e) {
+            // do nothing
+        }
 
         controlHolder.isStopped = true;
 
-        if (!waitFor(tasks)) {
-            dumpFailure(test, Status.TIMEOUT_ERROR);
-        }
+        waitFor(test, tasks);
 
         return counter;
     }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor4_Runner.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Actor4_Runner.java	Thu Oct 03 15:36:46 2013 +0400
@@ -37,7 +37,6 @@
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -58,12 +57,8 @@
     /**
      * Run the test.
      * This method blocks until test is complete
-     *
-     * @throws InterruptedException
-     * @throws java.util.concurrent.ExecutionException
-     *
      */
-    public void run() throws ExecutionException, InterruptedException {
+    public void run() {
         testLog.println("Running " + test.getClass().getName());
 
         try {
@@ -120,7 +115,7 @@
         return 4;
     }
 
-    private Counter<R> run(int time) throws InterruptedException, ExecutionException {
+    private Counter<R> run(int time) {
 
         @SuppressWarnings("unchecked")
         final S[] poison = (S[]) new Object[0];
@@ -187,13 +182,15 @@
                 }
         ));
 
-        TimeUnit.MILLISECONDS.sleep(time);
+        try {
+            TimeUnit.MILLISECONDS.sleep(time);
+        } catch (InterruptedException e) {
+            // do nothing
+        }
 
         controlHolder.isStopped = true;
 
-        if (!waitFor(tasks)) {
-            dumpFailure(test, Status.TIMEOUT_ERROR);
-        }
+        waitFor(test, tasks);
 
         return counter;
     }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java	Thu Oct 03 15:36:46 2013 +0400
@@ -131,7 +131,7 @@
         collector.add(result);
     }
 
-    public abstract void run() throws InterruptedException, ExecutionException;
+    public abstract void run();
 
     public abstract int requiredThreads();
 
@@ -154,19 +154,26 @@
         }
     }
 
-    protected boolean waitFor(Collection<Future<?>> tasks) throws ExecutionException, InterruptedException {
+    protected void waitFor(ConcurrencyTest test, Collection<Future<?>> tasks) {
         long startTime = System.nanoTime();
         boolean allStopped = false;
         while (!allStopped) {
             if (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime) > time * 2) {
-                return false;
+                dumpFailure(test, Status.TIMEOUT_ERROR);
+                return;
             }
 
             allStopped = true;
             for (Future<?> t : tasks) {
-                allStopped &= tryWaitFor(t);
+                try {
+                    allStopped &= tryWaitFor(t);
+                } catch (ExecutionException e) {
+                    dumpFailure(test, Status.TEST_ERROR, e.getCause());
+                    return;
+                } catch (InterruptedException e) {
+                    return;
+                }
             }
         }
-        return true;
     }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/runners/TerminationRunner.java	Thu Oct 03 15:11:10 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/runners/TerminationRunner.java	Thu Oct 03 15:36:46 2013 +0400
@@ -33,7 +33,6 @@
 
 import javax.xml.bind.JAXBException;
 import java.io.FileNotFoundException;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 
@@ -51,12 +50,8 @@
     /**
      * Run the test.
      * This method blocks until test is complete
-     *
-     * @throws InterruptedException
-     * @throws java.util.concurrent.ExecutionException
-     *
      */
-    public void run() throws ExecutionException, InterruptedException {
+    public void run() {
         testLog.println("Running " + test.getClass().getName());
 
         HashCounter<Outcome> results = new HashCounter<Outcome>();
@@ -100,7 +95,7 @@
         ERROR,
     }
 
-    private void run(int time, Counter<Outcome> results) throws InterruptedException, ExecutionException {
+    private void run(int time, Counter<Outcome> results) {
         long target = System.currentTimeMillis() + time;
         while (System.currentTimeMillis() < target) {
 
@@ -120,14 +115,24 @@
             });
             t1.start();
 
-            TimeUnit.MILLISECONDS.sleep(10);
+            try {
+                TimeUnit.MILLISECONDS.sleep(10);
+            } catch (InterruptedException e) {
+                // do nothing
+            }
+
             try {
                 test.signal(holder.state, t1);
             } catch (Exception e) {
                 holder.error = true;
             }
 
-            t1.join(1000);
+            try {
+                t1.join(1000);
+            } catch (InterruptedException e) {
+                // do nothing
+            }
+
             if (holder.terminated) {
                 if (holder.error) {
                     results.record(Outcome.ERROR);