8246494: introduce vm.flagless at-requires property
Reviewed-by: mseledtsov, sspitsyn
This commit is contained in:
parent
8c8d1b31f0
commit
e333b6e153
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
|
# Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
#
|
#
|
||||||
# This code is free software; you can redistribute it and/or modify it
|
# This code is free software; you can redistribute it and/or modify it
|
||||||
@ -75,6 +75,7 @@ requires.properties= \
|
|||||||
vm.compiler1.enabled \
|
vm.compiler1.enabled \
|
||||||
vm.compiler2.enabled \
|
vm.compiler2.enabled \
|
||||||
vm.musl \
|
vm.musl \
|
||||||
|
vm.flagless \
|
||||||
docker.support \
|
docker.support \
|
||||||
jdk.containerized
|
jdk.containerized
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,6 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
|
* @requires vm.flagless
|
||||||
* @run driver Scimark
|
* @run driver Scimark
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,6 +26,7 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper
|
* @run main/native GTestWrapper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2020 SAP SE. All rights reserved.
|
* Copyright (c) 2020 SAP SE. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
@ -39,6 +39,7 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper --gtest_filter=os* -XX:+UseLargePages
|
* @run main/native GTestWrapper --gtest_filter=os* -XX:+UseLargePages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -49,6 +50,7 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper --gtest_filter=os* -XX:+UseLargePages -XX:LargePageSizeInBytes=1G
|
* @run main/native GTestWrapper --gtest_filter=os* -XX:+UseLargePages -XX:LargePageSizeInBytes=1G
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -58,5 +60,6 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper --gtest_filter=os* -XX:+UseLargePages -XX:+UseSHM
|
* @run main/native GTestWrapper --gtest_filter=os* -XX:+UseLargePages -XX:+UseSHM
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2020 SAP SE. All rights reserved.
|
* Copyright (c) 2020 SAP SE. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
@ -36,6 +36,7 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=none -XX:+UnlockDiagnosticVMOptions -XX:VerifyMetaspaceInterval=3
|
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=none -XX:+UnlockDiagnosticVMOptions -XX:VerifyMetaspaceInterval=3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -45,6 +46,7 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=none
|
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=none
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -58,6 +60,7 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=aggressive -XX:+UnlockDiagnosticVMOptions -XX:VerifyMetaspaceInterval=3
|
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=aggressive -XX:+UnlockDiagnosticVMOptions -XX:VerifyMetaspaceInterval=3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -67,6 +70,7 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=aggressive
|
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=aggressive
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -79,6 +83,7 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:VerifyMetaspaceInterval=3 -XX:+MetaspaceGuardAllocations
|
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:VerifyMetaspaceInterval=3 -XX:+MetaspaceGuardAllocations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -91,5 +96,6 @@
|
|||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.xml
|
* java.xml
|
||||||
|
* @requires vm.flagless
|
||||||
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=balanced -XX:-UseCompressedClassPointers
|
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:MetaspaceReclaimPolicy=balanced -XX:-UseCompressedClassPointers
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -20,6 +20,7 @@
|
|||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package requires;
|
package requires;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@ -31,10 +32,12 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -118,6 +121,7 @@ public class VMProps implements Callable<Map<String, String>> {
|
|||||||
map.put("vm.musl", this::isMusl);
|
map.put("vm.musl", this::isMusl);
|
||||||
map.put("release.implementor", this::implementor);
|
map.put("release.implementor", this::implementor);
|
||||||
map.put("jdk.containerized", this::jdkContainerized);
|
map.put("jdk.containerized", this::jdkContainerized);
|
||||||
|
map.put("vm.flagless", this::isFlagless);
|
||||||
vmGC(map); // vm.gc.X = true/false
|
vmGC(map); // vm.gc.X = true/false
|
||||||
vmOptFinalFlags(map);
|
vmOptFinalFlags(map);
|
||||||
|
|
||||||
@ -529,6 +533,65 @@ public class VMProps implements Callable<Map<String, String>> {
|
|||||||
return "" + "true".equalsIgnoreCase(isEnabled);
|
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.
|
* 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
|
* This functionality could be helpful to know context in the real
|
||||||
|
Loading…
x
Reference in New Issue
Block a user