changeset 247:43189e8da359

Runners: run multiple discovered VM modes
author shade
date Fri, 13 May 2016 02:01:20 +0300
parents 4eaeffc68390
children 21f3179b8244
files jcstress-core/src/main/java/org/openjdk/jcstress/JCStress.java jcstress-core/src/main/java/org/openjdk/jcstress/Options.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/TestConfig.java jcstress-core/src/main/java/org/openjdk/jcstress/vm/VMSupport.java
diffstat 5 files changed, 25 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/JCStress.java	Fri May 13 01:42:55 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/JCStress.java	Fri May 13 02:01:20 2016 +0300
@@ -153,16 +153,22 @@
     private List<TestConfig> prepareRunProgram(Options opts, Set<String> tests) {
         List<TestConfig> configs = new ArrayList<>();
         if (opts.shouldFork()) {
+            List<String> inputArgs = ManagementFactory.getRuntimeMXBean().getInputArguments();
             for (String test : tests) {
-                for (int f = 0; f < opts.getForks(); f++) {
-                    configs.add(new TestConfig(opts, TestList.getInfo(test), TestConfig.RunMode.FORKED, f));
+                for (List<String> jvmArgs : VMSupport.getAvailableVMModes()) {
+                    List<String> fullArgs = new ArrayList<>();
+                    fullArgs.addAll(inputArgs);
+                    fullArgs.addAll(jvmArgs);
+                    for (int f = 0; f < opts.getForks(); f++) {
+                        configs.add(new TestConfig(opts, TestList.getInfo(test), TestConfig.RunMode.FORKED, f, fullArgs));
+                    }
                 }
             }
         } else {
             for (String test : tests) {
                 TestInfo info = TestList.getInfo(test);
                 TestConfig.RunMode mode = info.requiresFork() ? TestConfig.RunMode.FORKED : TestConfig.RunMode.EMBEDDED;
-                configs.add(new TestConfig(opts, info, mode, -1));
+                configs.add(new TestConfig(opts, info, mode, -1, Collections.emptyList()));
             }
         }
         return configs;
@@ -176,12 +182,7 @@
             command.addAll(VMSupport.getJavaInvokeLine());
 
             // jvm args
-            command.addAll(ManagementFactory.getRuntimeMXBean().getInputArguments());
-
-            String appendJvmArgs = config.appendJvmArgs;
-            if (appendJvmArgs.length() > 0) {
-                command.addAll(Arrays.asList(appendJvmArgs.split("\\s")));
-            }
+            command.addAll(config.jvmArgs);
 
             command.add(ForkedMain.class.getName());
 
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/Options.java	Fri May 13 01:42:55 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/Options.java	Fri May 13 02:01:20 2016 +0300
@@ -55,7 +55,6 @@
     private boolean parse;
     private boolean list;
     private boolean verbose;
-    private String appendJvmArgs;
     private int systemCPUs;
     private int userCPUs;
     private int forks;
@@ -117,9 +116,6 @@
                 "with occasional forking.")
                 .withOptionalArg().ofType(Integer.class).describedAs("count");
 
-        OptionSpec<String> appendJvmArgs = parser.accepts("jvmArgs", "Append these JVM arguments for the forked runs.")
-                .withRequiredArg().ofType(String.class).describedAs("opts");
-
         OptionSpec<String> modeStr = parser.accepts("m", "Test mode preset: sanity, quick, default, tough, stress.")
                 .withRequiredArg().ofType(String.class).describedAs("mode");
 
@@ -171,7 +167,6 @@
             this.resultFile = "jcstress." + System.currentTimeMillis();
         }
         this.list = orDefault(set.has(list), false);
-        this.appendJvmArgs = orDefault(set.valueOf(appendJvmArgs), "");
         this.verbose = orDefault(set.has("v"), false);
 
         this.hostName = set.valueOf(hostName);
@@ -361,10 +356,6 @@
         return iters;
     }
 
-    public String getAppendJvmArgs() {
-        return appendJvmArgs;
-    }
-
     public boolean isVerbose() {
         return verbose;
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Fri May 13 01:42:55 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Fri May 13 02:01:20 2016 +0300
@@ -134,9 +134,10 @@
         }
 
         if (isVerbose) {
-            output.format("    (fork: #%d, iteration #%d)%n",
+            output.format("    (fork: #%d, iteration #%d, JVM args: %s)%n",
                     r.getConfig().forkId + 1,
-                    r.getIteration() + 1
+                    r.getIteration() + 1,
+                    r.getConfig().jvmArgs
             );
 
             int idLen = "Observed state".length();
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/TestConfig.java	Fri May 13 01:42:55 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/TestConfig.java	Fri May 13 02:01:20 2016 +0300
@@ -28,6 +28,7 @@
 import org.openjdk.jcstress.infra.TestInfo;
 
 import java.io.Serializable;
+import java.util.List;
 
 public class TestConfig implements Serializable, Comparable<TestConfig> {
 
@@ -41,7 +42,7 @@
     public final int threads;
     public final String name;
     public final String generatedRunnerName;
-    public final String appendJvmArgs;
+    public final List<String> jvmArgs;
     public final RunMode runMode;
     public final int forkId;
 
@@ -50,9 +51,10 @@
         FORKED,
     }
 
-    public TestConfig(Options opts, TestInfo info, RunMode runMode, int forkId) {
+    public TestConfig(Options opts, TestInfo info, RunMode runMode, int forkId, List<String> jvmArgs) {
         this.runMode = runMode;
         this.forkId = forkId;
+        this.jvmArgs = jvmArgs;
         time = opts.getTime();
         minStride = opts.getMinStride();
         maxStride = opts.getMaxStride();
@@ -62,7 +64,6 @@
         deoptRatio = opts.deoptRatio();
         threads = info.threads();
         name = info.name();
-        appendJvmArgs = opts.getAppendJvmArgs();
         generatedRunnerName = info.generatedRunner();
     }
 
@@ -74,7 +75,6 @@
         TestConfig that = (TestConfig) o;
 
         if (shouldYield != that.shouldYield) return false;
-        if (verbose != that.verbose) return false;
         if (minStride != that.minStride) return false;
         if (maxStride != that.maxStride) return false;
         if (time != that.time) return false;
@@ -82,14 +82,14 @@
         if (deoptRatio != that.deoptRatio) return false;
         if (threads != that.threads) return false;
         if (!name.equals(that.name)) return false;
-        if (!generatedRunnerName.equals(that.generatedRunnerName)) return false;
-        return appendJvmArgs.equals(that.appendJvmArgs);
+        if (!jvmArgs.equals(that.jvmArgs)) return false;
+        return runMode == that.runMode;
+
     }
 
     @Override
     public int hashCode() {
         int result = (shouldYield ? 1 : 0);
-        result = 31 * result + (verbose ? 1 : 0);
         result = 31 * result + minStride;
         result = 31 * result + maxStride;
         result = 31 * result + time;
@@ -97,8 +97,8 @@
         result = 31 * result + deoptRatio;
         result = 31 * result + threads;
         result = 31 * result + name.hashCode();
-        result = 31 * result + generatedRunnerName.hashCode();
-        result = 31 * result + appendJvmArgs.hashCode();
+        result = 31 * result + jvmArgs.hashCode();
+        result = 31 * result + runMode.hashCode();
         return result;
     }
 
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/vm/VMSupport.java	Fri May 13 01:42:55 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/vm/VMSupport.java	Fri May 13 02:01:20 2016 +0300
@@ -170,4 +170,7 @@
     }
 
 
+    public static List<List<String>> getAvailableVMModes() {
+        return AVAIL_JVM_MODES;
+    }
 }