--- old/test/hotspot/jtreg/TEST.ROOT 2020-06-03 14:12:28.000000000 -0700
+++ new/test/hotspot/jtreg/TEST.ROOT 2020-06-03 14:12:28.000000000 -0700
@@ -68,7 +68,8 @@
vm.compiler1.enabled \
vm.compiler2.enabled \
docker.support \
- test.vm.gc.nvdimm
+ test.vm.gc.nvdimm \
+ vm.flagless
# Minimum jtreg version
requiredVersion=5.1 b1
--- old/test/hotspot/jtreg/applications/scimark/Scimark.java 2020-06-03 14:12:30.000000000 -0700
+++ new/test/hotspot/jtreg/applications/scimark/Scimark.java 2020-06-03 14:12:30.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/*
* @test
* @library /test/lib
+ * @requires vm.flagless
* @run driver Scimark
*/
--- old/test/hotspot/jtreg/gtest/GTestWrapper.java 2020-06-03 14:12:31.000000000 -0700
+++ new/test/hotspot/jtreg/gtest/GTestWrapper.java 2020-06-03 14:12:31.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.xml
+ * @requires vm.flagless
* @run main/native GTestWrapper
*/
--- old/test/hotspot/jtreg/testlibrary_tests/process/TestNativeProcessBuilder.java 2020-06-03 14:12:33.000000000 -0700
+++ new/test/hotspot/jtreg/testlibrary_tests/process/TestNativeProcessBuilder.java 2020-06-03 14:12:33.000000000 -0700
@@ -25,6 +25,7 @@
* @test
* @summary Test the native process builder API.
* @library /test/lib
+ * @requires vm.flagless
* @build Test
* @run main/native TestNativeProcessBuilder
*/
--- old/test/jtreg-ext/requires/VMProps.java 2020-06-03 14:12:34.000000000 -0700
+++ new/test/jtreg-ext/requires/VMProps.java 2020-06-03 14:12:34.000000000 -0700
@@ -31,10 +31,12 @@
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;
@@ -115,6 +117,7 @@
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);
@@ -437,7 +440,7 @@
return "" + Compiler.isC2Enabled();
}
- /**
+ /**
* A simple check for docker support
*
* @return true if docker is supported in a given environment
@@ -502,6 +505,65 @@
}
/**
+ * Checks if we are in almost 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 allFlags = new ArrayList();
+ 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.