changeset 404:9702f3eaf020

7901970: jcstress omits samples gathered during sanity checks
author shade
date Mon, 08 May 2017 15:02:01 +0200
parents 9cbe23132d16
children 04bd0247edbb
files jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ReportUtils.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java
diffstat 4 files changed, 32 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Wed Mar 29 13:43:24 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Mon May 08 15:02:01 2017 +0200
@@ -66,7 +66,7 @@
         this.output = pw;
         this.expectedTests = expectedTests;
         this.expectedForks = expectedForks;
-        this.expectedIterations = expectedForks * opts.getIterations();
+        this.expectedIterations = expectedForks * (opts.getIterations() + 1); // +1 sanity check iteration #0
         verbose = opts.isVerbose();
         progressLen = 1;
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ReportUtils.java	Wed Mar 29 13:43:24 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ReportUtils.java	Mon May 08 15:02:01 2017 +0200
@@ -112,7 +112,7 @@
         if (inProgress) {
             pw.format("    (fork: #%d, iteration #%d, JVM args: %s)%n",
                     r.getConfig().forkId + 1,
-                    r.getIteration() + 1,
+                    r.getIteration(),
                     r.getConfig().jvmArgs
             );
         } else {
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Wed Mar 29 13:43:24 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Mon May 08 15:02:01 2017 +0200
@@ -336,20 +336,25 @@
         pw.println();
 
         pw.println("    @Override");
-        pw.println("    public void sanityCheck() throws Throwable {");
-        pw.println("        sanityCheck_API();");
-        pw.println("        sanityCheck_Footprints();");
+        pw.println("    public Counter<" + r + "> sanityCheck() throws Throwable {");
+        pw.println("        Counter<" + r + "> counter = new Counter<>();");
+        pw.println("        sanityCheck_API(counter);");
+        pw.println("        sanityCheck_Footprints(counter);");
+        pw.println("        return counter;");
         pw.println("    }");
         pw.println();
-        pw.println("    private void sanityCheck_API() throws Throwable {");
-        pw.println("        final " + t + " t = new " + t + "();");
+        pw.println("    private void sanityCheck_API(Counter<" + r + "> counter) throws Throwable {");
+
         pw.println("        final " + s + " s = new " + s + "();");
         pw.println("        final " + r + " r = new " + r + "();");
+        if (!isStateItself) {
+            pw.println("        final " + t + " t = new " + t + "();");
+        }
 
         pw.println("        Collection<Future<?>> res = new ArrayList<>();");
         for (ExecutableElement el : info.getActors()) {
             pw.print("        res.add(pool.submit(() -> ");
-            emitMethod(pw, el, "t." + el.getSimpleName(), "s", "r", false);
+            emitMethod(pw, el, (isStateItself ? "s." : "t.") + el.getSimpleName(), "s", "r", false);
             pw.println("));");
         }
 
@@ -362,15 +367,20 @@
         pw.println("        }");
 
         if (info.getArbiter() != null) {
-            emitMethod(pw, info.getArbiter(), "        t." + info.getArbiter().getSimpleName(), "s", "r", true);
+            pw.print("        ");
+            emitMethod(pw, info.getArbiter(), (isStateItself ? "s." : "t.") + info.getArbiter().getSimpleName(), "s", "r", true);
         }
+        pw.println("        counter.record(r);");
         pw.println("    }");
         pw.println();
 
-        pw.println("    private void sanityCheck_Footprints() throws Throwable {");
+        pw.println("    private void sanityCheck_Footprints(Counter<" + r + "> counter) throws Throwable {");
         pw.println("        config.adjustStrides(size -> {");
         pw.println("            version = new StateHolder<>(new " + s + "[size], new " + r + "[size], " + actorsCount + ", config.spinLoopStyle);");
-        pw.println("            final " + t + " t = new " + t + "();");
+
+        if (!isStateItself) {
+            pw.println("            final " + t + " t = new " + t + "();");
+        }
 
         pw.println("            for (int c = 0; c < size; c++) {");
         pw.println("                " + r + " r = new " + r + "();");
@@ -386,6 +396,11 @@
             }
             pw.println(";");
         }
+        if (info.getArbiter() != null) {
+            pw.print("                ");
+            emitMethod(pw, info.getArbiter(), (isStateItself ? "s." : "t.") + info.getArbiter().getSimpleName(), "s", "r", true);
+        }
+        pw.println("                counter.record(r);");
         pw.println("            }");
         pw.println("        });");
         pw.println("    }");
@@ -733,7 +748,7 @@
         pw.println("    }");
         pw.println();
         pw.println("    @Override");
-        pw.println("    public void sanityCheck() throws Throwable {");
+        pw.println("    public Counter<Outcome> sanityCheck() throws Throwable {");
         pw.println("        throw new UnsupportedOperationException();");
         pw.println("    }");
         pw.println();
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java	Wed Mar 29 13:43:24 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Runner.java	Mon May 08 15:02:01 2017 +0200
@@ -68,16 +68,16 @@
      */
     public void run() {
         try {
-            sanityCheck();
+            dump(0, sanityCheck());
         } catch (ClassFormatError | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
-            dumpFailure(-1, Status.API_MISMATCH, "Test sanity check failed, skipping", e);
+            dumpFailure(0, Status.API_MISMATCH, "Test sanity check failed, skipping", e);
             return;
         } catch (Throwable e) {
-            dumpFailure(-1, Status.CHECK_TEST_ERROR, "Check test failed", e);
+            dumpFailure(0, Status.CHECK_TEST_ERROR, "Check test failed", e);
             return;
         }
 
-        for (int c = 0; c < config.iters; c++) {
+        for (int c = 1; c <= config.iters; c++) {
             try {
                 WhiteBoxSupport.tryDeopt(config.deoptRatio);
             } catch (NoClassDefFoundError err) {
@@ -118,7 +118,7 @@
         collector.add(result);
     }
 
-    public abstract void sanityCheck() throws Throwable;
+    public abstract Counter<R> sanityCheck() throws Throwable;
 
     public abstract Counter<R> internalRun();