< prev index next >

test/jtreg-ext/requires/VMProps.java

Print this page
rev 59593 : [mq]: 8246494

*** 29,42 **** --- 29,44 ---- import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.ArrayList; + import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; + import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern;
*** 113,122 **** --- 115,125 ---- map.put("vm.compiler1.enabled", this::isCompiler1Enabled); map.put("vm.compiler2.enabled", this::isCompiler2Enabled); map.put("docker.support", this::dockerSupport); map.put("release.implementor", this::implementor); map.put("test.vm.gc.nvdimm", this::isNvdimmTestEnabled); + map.put("vm.flagless", this::isFlagless); vmGC(map); // vm.gc.X = true/false vmOptFinalFlags(map); dump(map.map); return map.map;
*** 500,509 **** --- 503,571 ---- String isEnabled = System.getenv("TEST_VM_GC_NVDIMM"); return "" + "true".equalsIgnoreCase(isEnabled); } /** + * Checks if we are in <i>almost</i> out-of-box configuration, i.e. the flags + * which JVM is started with don't affect its behavior "significantly". + * {@code TEST_VM_FLAGLESS} enviroment variable can be used to force this + * method to return true and allow any flags. + * + * @return true if there are no JVM flags + */ + private String isFlagless() { + boolean result = true; + if (System.getenv("TEST_VM_FLAGLESS") != null) { + return "" + result; + } + + List<String> allFlags = new ArrayList<String>(); + Collections.addAll(allFlags, System.getProperty("test.vm.opts", "").trim().split("\\s+")); + Collections.addAll(allFlags, System.getProperty("test.java.opts", "").trim().split("\\s+")); + + // check -XX flags + var ignoredXXFlags = Set.of( + // added by run-test framework + "MaxRAMPercentage", + // added by test environment + "CreateCoredumpOnCrash" + ); + result &= allFlags.stream() + .filter(s -> s.startsWith("-XX:")) + // map to names: + // remove -XX: + .map(s -> s.substring(4)) + // remove +/- from bool flags + .map(s -> s.charAt(0) == '+' || s.charAt(0) == '-' ? s.substring(1) : s) + // remove =.* from others + .map(s -> s.contains("=") ? s.substring(0, s.indexOf('=')) : s) + // skip known-to-be-there flags + .filter(s -> !ignoredXXFlags.contains(s)) + .findAny() + .isEmpty(); + + // check -X flags + var ignoredXFlags = Set.of( + // default, yet still seen to be explicitly set + "mixed" + ); + result &= allFlags.stream() + .filter(s -> s.startsWith("-X") && !s.startsWith("-XX:")) + // map to names: + // remove -X + .map(s -> s.substring(2)) + // remove :.* from flags with values + .map(s -> s.contains(":") ? s.substring(0, s.indexOf(':')) : s) + // skip known-to-be-there flags + .filter(s -> !ignoredXFlags.contains(s)) + .findAny() + .isEmpty(); + + return "" + result; + } + + /** * Dumps the map to the file if the file name is given as the property. * This functionality could be helpful to know context in the real * execution. * * @param map
< prev index next >