12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 8031320
27 * @summary Verify UseRTMForStackLocks option processing on CPUs without
28 * rtm support and/or on VMs without rtm locking support.
29 * @library /test/lib /
30 * @modules java.base/jdk.internal.misc
31 * java.management
32 *
33 * @build sun.hotspot.WhiteBox
34 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
35 * sun.hotspot.WhiteBox$WhiteBoxPermission
36 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
37 * -XX:+WhiteBoxAPI
38 * compiler.rtm.cli.TestUseRTMForStackLocksOptionOnUnsupportedConfig
39 */
40
41 package compiler.rtm.cli;
42
43 import compiler.testlibrary.rtm.predicate.SupportedCPU;
44 import compiler.testlibrary.rtm.predicate.SupportedOS;
45 import compiler.testlibrary.rtm.predicate.SupportedVM;
46 import jdk.test.lib.process.ExitCode;
47 import jdk.test.lib.cli.CommandLineOptionTest;
48 import jdk.test.lib.cli.predicate.AndPredicate;
49 import jdk.test.lib.cli.predicate.NotPredicate;
50
51 public class TestUseRTMForStackLocksOptionOnUnsupportedConfig
52 extends RTMGenericCommandLineOptionTest {
53 private static final String DEFAULT_VALUE = "false";
54
55 private TestUseRTMForStackLocksOptionOnUnsupportedConfig() {
56 super(new NotPredicate(
57 new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())),
58 "UseRTMForStackLocks", true, true,
59 TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
60 "true");
61 }
62
63 @Override
64 protected void runX86SupportedVMTestCases() throws Throwable {
65 String shouldFailMessage = String.format("VM option '%s' is "
66 + "experimental%nJVM startup should fail without "
67 + "-XX:+UnlockExperimentalVMOptions flag", optionName);
68
69 // verify that option is experimental
70 CommandLineOptionTest.verifySameJVMStartup(
71 new String[] { experimentalOptionError }, null,
72 shouldFailMessage, shouldFailMessage + "%nError message "
73 + "should be shown", ExitCode.FAIL,
74 prepareOptionValue("true"));
75
76 CommandLineOptionTest.verifySameJVMStartup(
77 new String[]{ experimentalOptionError }, null,
78 shouldFailMessage, shouldFailMessage + "%nError message "
94 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
95 prepareOptionValue("true")
96 );
97 // verify that options is turned off by default
98 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
99 TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
100 String.format("Default value of option '%s' should be '%s'",
101 optionName, DEFAULT_VALUE),
102 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
103 // verify that it could not be turned on without rtm locking
104 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
105 TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
106 String.format("Value of '%s' shouldn't able to be set to "
107 + "'true' without setting -XX:+UseRTMLocking flag",
108 optionName),
109 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
110 prepareOptionValue("true"));
111 }
112
113 public static void main(String args[]) throws Throwable {
114 new TestUseRTMForStackLocksOptionOnUnsupportedConfig().test();
115 }
116 }
|
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 8031320
27 * @summary Verify UseRTMForStackLocks option processing on CPUs without
28 * rtm support and/or on VMs without rtm locking support.
29 * @library /test/lib /
30 * @modules java.base/jdk.internal.misc
31 * java.management
32 * @requires !(vm.flavor == "server" & !vm.emulatedClient & vm.rtm.cpu & vm.rtm.os)
33 * @build sun.hotspot.WhiteBox
34 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
35 * sun.hotspot.WhiteBox$WhiteBoxPermission
36 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
37 * -XX:+WhiteBoxAPI
38 * compiler.rtm.cli.TestUseRTMForStackLocksOptionOnUnsupportedConfig
39 */
40
41 package compiler.rtm.cli;
42
43 import jdk.test.lib.process.ExitCode;
44 import jdk.test.lib.cli.CommandLineOptionTest;
45
46 public class TestUseRTMForStackLocksOptionOnUnsupportedConfig
47 extends RTMGenericCommandLineOptionTest {
48 private static final String DEFAULT_VALUE = "false";
49
50 private TestUseRTMForStackLocksOptionOnUnsupportedConfig() {
51 super("UseRTMForStackLocks", true, true,
52 TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
53 "true");
54 }
55
56 @Override
57 protected void runX86SupportedVMTestCases() throws Throwable {
58 String shouldFailMessage = String.format("VM option '%s' is "
59 + "experimental%nJVM startup should fail without "
60 + "-XX:+UnlockExperimentalVMOptions flag", optionName);
61
62 // verify that option is experimental
63 CommandLineOptionTest.verifySameJVMStartup(
64 new String[] { experimentalOptionError }, null,
65 shouldFailMessage, shouldFailMessage + "%nError message "
66 + "should be shown", ExitCode.FAIL,
67 prepareOptionValue("true"));
68
69 CommandLineOptionTest.verifySameJVMStartup(
70 new String[]{ experimentalOptionError }, null,
71 shouldFailMessage, shouldFailMessage + "%nError message "
87 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
88 prepareOptionValue("true")
89 );
90 // verify that options is turned off by default
91 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
92 TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
93 String.format("Default value of option '%s' should be '%s'",
94 optionName, DEFAULT_VALUE),
95 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
96 // verify that it could not be turned on without rtm locking
97 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
98 TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
99 String.format("Value of '%s' shouldn't able to be set to "
100 + "'true' without setting -XX:+UseRTMLocking flag",
101 optionName),
102 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
103 prepareOptionValue("true"));
104 }
105
106 public static void main(String args[]) throws Throwable {
107 new TestUseRTMForStackLocksOptionOnUnsupportedConfig().runTestCases();
108 }
109 }
|