changeset 79:fe3db9567f0d

Yak shaving: relax dependency on Test.
author shade
date Wed, 12 Mar 2014 23:42:12 +0400
parents 2049a7d46a2a
children ec966433b6be
files jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor1_Runner.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Arbiter1_Runner.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Runner.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor3_Runner.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor4_Runner.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/TerminationRunner.java
diffstat 7 files changed, 60 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor1_Runner.java	Sun Feb 23 12:45:08 2014 +0400
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor1_Runner.java	Wed Mar 12 23:42:12 2014 +0400
@@ -48,10 +48,12 @@
  */
 public class Actor1_Runner<S, R extends Result> extends Runner {
     private final Actor1_Test<S, R> test;
+    private final String testName;
 
     public Actor1_Runner(Options opts, Actor1_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
         super(opts, collector, pool);
         this.test = test;
+        this.testName = test.getClass().getName();
     }
 
     /**
@@ -59,7 +61,7 @@
      * This method blocks until test is complete
      */
     public void run() {
-        testLog.println("Running " + test.getClass().getName());
+        testLog.println("Running " + testName);
 
         try {
             R res1 = test.newResult();
@@ -68,22 +70,22 @@
         } catch (NoClassDefFoundError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH, e);
+            dumpFailure(testName, Status.API_MISMATCH, e);
             return;
         } catch (NoSuchFieldError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH, e);
+            dumpFailure(testName, Status.API_MISMATCH, e);
             return;
         } catch (NoSuchMethodError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH, e);
+            dumpFailure(testName, Status.API_MISMATCH, e);
             return;
         } catch (Throwable e) {
             testLog.println("Check test failed");
             testLog.println();
-            dumpFailure(test, Status.CHECK_TEST_ERROR, e);
+            dumpFailure(testName, Status.CHECK_TEST_ERROR, e);
             return;
         }
 
@@ -99,7 +101,7 @@
             testLog.flush();
             Counter<R> runResult = run(time);
 
-            dump(test, runResult);
+            dump(testName, runResult);
         }
         testLog.println();
     }
@@ -158,7 +160,7 @@
 
         controlHolder.isStopped = true;
 
-        waitFor(test, tasks);
+        waitFor(testName, tasks);
 
         return counter;
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Arbiter1_Runner.java	Sun Feb 23 12:45:08 2014 +0400
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Arbiter1_Runner.java	Wed Mar 12 23:42:12 2014 +0400
@@ -47,15 +47,17 @@
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
 public class Actor2_Arbiter1_Runner<S, R extends Result> extends Runner {
-    private Actor2_Arbiter1_Test<S, R> test;
+    private final Actor2_Arbiter1_Test<S, R> test;
+    private final String testName;
 
     public Actor2_Arbiter1_Runner(Options opts, Actor2_Arbiter1_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
         super(opts, collector, pool);
         this.test = test;
+        this.testName = test.getClass().getName();
     }
 
     public void run() {
-        testLog.println("Running " + test.getClass().getName());
+        testLog.println("Running " + testName);
 
         try {
             R res = test.newResult();
@@ -66,22 +68,22 @@
         } catch (NoClassDefFoundError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (NoSuchFieldError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (NoSuchMethodError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (Throwable e) {
             testLog.println("Check test failed");
             testLog.println();
-            dumpFailure(test, Status.CHECK_TEST_ERROR);
+            dumpFailure(testName, Status.CHECK_TEST_ERROR);
             return;
         }
 
@@ -97,7 +99,7 @@
             testLog.flush();
             Counter<R> runResult = run(time);
 
-            dump(test, runResult);
+            dump(testName, runResult);
         }
 
         testLog.println();
@@ -176,7 +178,7 @@
 
         controlHolder.isStopped = true;
 
-        waitFor(test, tasks);
+        waitFor(testName, tasks);
 
         return counter;
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Runner.java	Sun Feb 23 12:45:08 2014 +0400
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor2_Runner.java	Wed Mar 12 23:42:12 2014 +0400
@@ -48,10 +48,12 @@
  */
 public class Actor2_Runner<S, R extends Result> extends Runner {
     final Actor2_Test<S, R> test;
+    final String testName;
 
     public Actor2_Runner(Options opts, Actor2_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
         super(opts, collector, pool);
         this.test = test;
+        this.testName = test.getClass().getName();
     }
 
     /**
@@ -60,7 +62,8 @@
      *
      */
     public void run() {
-        testLog.println("Running " + test.getClass().getName());
+
+        testLog.println("Running " + testName);
 
         try {
             R res1 = test.newResult();
@@ -71,22 +74,22 @@
         } catch (NoClassDefFoundError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (NoSuchFieldError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (NoSuchMethodError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (Throwable e) {
             testLog.println("Check test failed");
             testLog.println();
-            dumpFailure(test, Status.CHECK_TEST_ERROR);
+            dumpFailure(testName, Status.CHECK_TEST_ERROR);
             return;
         }
 
@@ -102,7 +105,7 @@
             testLog.flush();
             Counter<R> runResult = run(time);
 
-            dump(test, runResult);
+            dump(testName, runResult);
         }
         testLog.println();
     }
@@ -169,7 +172,7 @@
 
         controlHolder.isStopped = true;
 
-        waitFor(test, tasks);
+        waitFor(testName, tasks);
 
         return counter;
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor3_Runner.java	Sun Feb 23 12:45:08 2014 +0400
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor3_Runner.java	Wed Mar 12 23:42:12 2014 +0400
@@ -48,10 +48,12 @@
  */
 public class Actor3_Runner<S, R extends Result> extends Runner {
     final Actor3_Test<S, R> test;
+    final String testName;
 
     public Actor3_Runner(Options opts, Actor3_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
         super(opts, collector, pool);
         this.test = test;
+        this.testName = test.getClass().getName();
     }
 
     /**
@@ -59,7 +61,7 @@
      * This method blocks until test is complete
      */
     public void run() {
-        testLog.println("Running " + test.getClass().getName());
+        testLog.println("Running " + testName);
 
         try {
             R res1 = test.newResult();
@@ -72,22 +74,22 @@
         } catch (NoClassDefFoundError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (NoSuchFieldError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (NoSuchMethodError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (Throwable e) {
             testLog.println("Check test failed");
             testLog.println();
-            dumpFailure(test, Status.CHECK_TEST_ERROR);
+            dumpFailure(testName, Status.CHECK_TEST_ERROR);
             return;
         }
 
@@ -103,7 +105,7 @@
             testLog.flush();
             Counter<R> runResult = run(time);
 
-            dump(test, runResult);
+            dump(testName, runResult);
         }
         testLog.println();
     }
@@ -179,7 +181,7 @@
 
         controlHolder.isStopped = true;
 
-        waitFor(test, tasks);
+        waitFor(testName, tasks);
 
         return counter;
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor4_Runner.java	Sun Feb 23 12:45:08 2014 +0400
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Actor4_Runner.java	Wed Mar 12 23:42:12 2014 +0400
@@ -48,10 +48,12 @@
  */
 public class Actor4_Runner<S, R extends Result> extends Runner {
     final Actor4_Test<S, R> test;
+    final String testName;
 
     public Actor4_Runner(Options opts, Actor4_Test<S, R> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
         super(opts, collector, pool);
         this.test = test;
+        this.testName = test.getClass().getName();
     }
 
     /**
@@ -59,7 +61,7 @@
      * This method blocks until test is complete
      */
     public void run() {
-        testLog.println("Running " + test.getClass().getName());
+        testLog.println("Running " + testName);
 
         try {
             R res1 = test.newResult();
@@ -74,22 +76,22 @@
         } catch (NoClassDefFoundError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (NoSuchFieldError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (NoSuchMethodError e) {
             testLog.println("Test sanity check failed, skipping");
             testLog.println();
-            dumpFailure(test, Status.API_MISMATCH);
+            dumpFailure(testName, Status.API_MISMATCH);
             return;
         } catch (Throwable e) {
             testLog.println("Check test failed");
             testLog.println();
-            dumpFailure(test, Status.CHECK_TEST_ERROR);
+            dumpFailure(testName, Status.CHECK_TEST_ERROR);
             return;
         }
 
@@ -105,7 +107,7 @@
             testLog.flush();
             Counter<R> runResult = run(time);
 
-            dump(test, runResult);
+            dump(testName, runResult);
         }
         testLog.println();
     }
@@ -190,7 +192,7 @@
 
         controlHolder.isStopped = true;
 
-        waitFor(test, tasks);
+        waitFor(testName, tasks);
 
         return counter;
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java	Sun Feb 23 12:45:08 2014 +0400
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java	Wed Mar 12 23:42:12 2014 +0400
@@ -106,13 +106,13 @@
         return res;
     }
 
-    protected void dumpFailure(ConcurrencyTest test, Status status) {
-        TestResult result = new TestResult(test.getClass().getName(), status);
+    protected void dumpFailure(String testName, Status status) {
+        TestResult result = new TestResult(testName, status);
         collector.add(result);
     }
 
-    protected void dumpFailure(ConcurrencyTest test, Status status, Throwable aux) {
-        TestResult result = new TestResult(test.getClass().getName(), status);
+    protected void dumpFailure(String testName, Status status, Throwable aux) {
+        TestResult result = new TestResult(testName, status);
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         aux.printStackTrace(pw);
@@ -121,8 +121,8 @@
         collector.add(result);
     }
 
-    protected <R> void dump(ConcurrencyTest test, Counter<R> results) {
-        TestResult result = new TestResult(test.getClass().getName(), Status.NORMAL);
+    protected <R> void dump(String testName, Counter<R> results) {
+        TestResult result = new TestResult(testName, Status.NORMAL);
 
         for (R e : results.elementSet()) {
             result.addState(e, results.count(e));
@@ -145,7 +145,7 @@
         testLog.println(s);
     }
 
-    protected void waitFor(ConcurrencyTest test, Collection<Future<?>> tasks) {
+    protected void waitFor(String testName, Collection<Future<?>> tasks) {
         long startTime = System.nanoTime();
         boolean allStopped = false;
         while (!allStopped) {
@@ -156,7 +156,7 @@
                 } catch (TimeoutException e) {
                     allStopped = false;
                 } catch (ExecutionException e) {
-                    dumpFailure(test, Status.TEST_ERROR, e.getCause());
+                    dumpFailure(testName, Status.TEST_ERROR, e.getCause());
                     return;
                 } catch (InterruptedException e) {
                     return;
@@ -164,7 +164,7 @@
             }
 
             if (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime) > Math.max(time, 60*1000)) {
-                dumpFailure(test, Status.TIMEOUT_ERROR);
+                dumpFailure(testName, Status.TIMEOUT_ERROR);
                 return;
             }
         }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/TerminationRunner.java	Sun Feb 23 12:45:08 2014 +0400
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/TerminationRunner.java	Wed Mar 12 23:42:12 2014 +0400
@@ -41,10 +41,12 @@
  */
 public class TerminationRunner<S> extends Runner {
     final TerminationTest<S> test;
+    final String testName;
 
     public TerminationRunner(Options opts,  TerminationTest<S> test, TestResultCollector collector, ExecutorService pool) throws FileNotFoundException, JAXBException {
         super(opts, collector, pool);
         this.test = test;
+        this.testName = test.getClass().getName();
     }
 
     /**
@@ -52,7 +54,7 @@
      * This method blocks until test is complete
      */
     public void run() {
-        testLog.println("Running " + test.getClass().getName());
+        testLog.println("Running " + testName);
 
         HashCounter<Outcome> results = new HashCounter<Outcome>();
 
@@ -68,7 +70,7 @@
             testLog.flush();
             run(time, results);
 
-            dump(test, results);
+            dump(testName, results);
 
             if (results.count(Outcome.STALE) > 0) {
                 warn("Have stale threads, forcing VM to exit");