Skip to content

Commit

Permalink
8341261: Tests assume UnlockExperimentalVMOptions is disabled by default
Browse files Browse the repository at this point in the history
Reviewed-by: stefank, mli, ysr
  • Loading branch information
toddjonker committed Oct 4, 2024
1 parent ec020f3 commit 1bdd79e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @test
* @library /test/lib /
* @requires vm.flagless
* @requires ! vm.opt.final.UnlockExperimentalVMOptions
* @requires vm.compMode != "Xint"
* @run driver compiler.blackhole.BlackholeExperimentalUnlockTest
*/
Expand Down
76 changes: 56 additions & 20 deletions test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,37 @@
*/

/*
* @test
* @test VMOptionWarningExperimental
* @bug 8027314
* @summary Warn if diagnostic or experimental vm option is used and -XX:+UnlockDiagnosticVMOptions or -XX:+UnlockExperimentalVMOptions, respectively, isn't specified. Warn if develop vm option is used with product version of VM.
* @summary Warn if experimental vm option is used and -XX:+UnlockExperimentalVMOptions isn't specified.
* @requires vm.flagless
* @requires ! vm.opt.final.UnlockExperimentalVMOptions
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run driver VMOptionWarning
* @run driver VMOptionWarning Experimental
*/

/* @test VMOptionWarningDiagnostic
* @bug 8027314
* @summary Warn if diagnostic vm option is used and -XX:+UnlockDiagnosticVMOptions isn't specified.
* @requires vm.flagless
* @requires ! vm.debug
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run driver VMOptionWarning Diagnostic
*/

/* @test VMOptionWarningDevelop
* @bug 8027314
* @summary Warn if develop vm option is used with product version of VM.
* @requires vm.flagless
* @requires ! vm.debug
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run driver VMOptionWarning Develop
*/

import jdk.test.lib.process.ProcessTools;
Expand All @@ -38,24 +61,37 @@

public class VMOptionWarning {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'AlwaysSafeConstructors' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.");

if (Platform.isDebugBuild()) {
System.out.println("Skip the rest of the tests on debug builds since diagnostic, and develop options are available on debug builds.");
return;
if (args.length != 1) {
throw new RuntimeException("wrong number of args: " + args.length);
}

pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintInlining", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");

pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+VerifyStack", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'VerifyStack' is develop and is available only in debug version of VM.");
ProcessBuilder pb;
OutputAnalyzer output;
switch (args[0]) {
case "Experimental": {
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'AlwaysSafeConstructors' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.");
break;
}
case "Diagnostic": {
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintInlining", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");
break;
}
case "Develop": {
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+VerifyStack", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'VerifyStack' is develop and is available only in debug version of VM.");
break;
}
default: {
throw new RuntimeException("Invalid argument: " + args[0]);
}
}
}
}
1 change: 1 addition & 0 deletions test/jtreg-ext/requires/VMProps.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ protected void vmOptFinalFlags(SafeMap map) {
vmOptFinalFlag(map, "CriticalJNINatives");
vmOptFinalFlag(map, "EnableJVMCI");
vmOptFinalFlag(map, "EliminateAllocations");
vmOptFinalFlag(map, "UnlockExperimentalVMOptions");
vmOptFinalFlag(map, "UseCompressedOops");
vmOptFinalFlag(map, "UseLargePages");
vmOptFinalFlag(map, "UseVectorizedMismatchIntrinsic");
Expand Down

1 comment on commit 1bdd79e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.