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 UseRTMLocking option processing on CPU without
28 * rtm 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.TestUseRTMLockingOptionOnUnsupportedCPU
39 */
40
41 package compiler.rtm.cli;
42
43 import compiler.testlibrary.rtm.predicate.SupportedCPU;
44 import compiler.testlibrary.rtm.predicate.SupportedVM;
45 import jdk.test.lib.process.ExitCode;
46 import jdk.test.lib.Platform;
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 TestUseRTMLockingOptionOnUnsupportedCPU
52 extends CommandLineOptionTest {
53 private static final String DEFAULT_VALUE = "false";
54
55 private TestUseRTMLockingOptionOnUnsupportedCPU() {
56 super(new AndPredicate(new NotPredicate(new SupportedCPU()),
57 new SupportedVM()));
58 }
59
60 @Override
61 public void runTestCases() throws Throwable {
62 String unrecongnizedOption
63 = CommandLineOptionTest.getUnrecognizedOptionErrorMessage(
64 "UseRTMLocking");
65 String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR;
66
67 if (Platform.isX86() || Platform.isX64() || Platform.isPPC()) {
68 String shouldFailMessage = "JVM startup should fail with option "
69 + "-XX:+UseRTMLocking on unsupported CPU";
70 // verify that we get an error when use +UseRTMLocking
71 // on unsupported CPU
72 CommandLineOptionTest.verifySameJVMStartup(
73 new String[] { errorMessage },
74 new String[] { unrecongnizedOption }, shouldFailMessage,
75 shouldFailMessage + ". Error message should be shown",
76 ExitCode.FAIL, "-XX:+UseRTMLocking");
77
78 String shouldPassMessage = "JVM startup should pass with option "
79 + "-XX:-UseRTMLocking even on unsupported CPU";
80 // verify that we can pass -UseRTMLocking without
90 String.format("Default value of option 'UseRTMLocking' "
91 +"should be '%s'", DEFAULT_VALUE));
92 } else {
93 String shouldFailMessage = "RTMLocking should be unrecognized"
94 + " on non-x86 CPUs. JVM startup should fail."
95 + "Error message should be shown";
96 // verify that on non-x86 CPUs RTMLocking could not be used
97 CommandLineOptionTest.verifySameJVMStartup(
98 new String[] { unrecongnizedOption },
99 null, shouldFailMessage, shouldFailMessage,
100 ExitCode.FAIL, "-XX:+UseRTMLocking");
101
102 CommandLineOptionTest.verifySameJVMStartup(
103 new String[] { unrecongnizedOption },
104 null, shouldFailMessage, shouldFailMessage,
105 ExitCode.FAIL, "-XX:-UseRTMLocking");
106 }
107 }
108
109 public static void main(String args[]) throws Throwable {
110 new TestUseRTMLockingOptionOnUnsupportedCPU().test();
111 }
112 }
|
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 UseRTMLocking option processing on CPU without
28 * rtm support.
29 * @library /test/lib /
30 * @modules java.base/jdk.internal.misc
31 * java.management
32 * @requires (!vm.rtm.cpu) & (vm.flavor == "server" & !vm.emulatedClient)
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.TestUseRTMLockingOptionOnUnsupportedCPU
39 */
40
41 package compiler.rtm.cli;
42
43 import jdk.test.lib.process.ExitCode;
44 import jdk.test.lib.Platform;
45 import jdk.test.lib.cli.CommandLineOptionTest;
46
47 public class TestUseRTMLockingOptionOnUnsupportedCPU {
48 private static final String DEFAULT_VALUE = "false";
49
50 public void runTestCases() throws Throwable {
51 String unrecongnizedOption
52 = CommandLineOptionTest.getUnrecognizedOptionErrorMessage(
53 "UseRTMLocking");
54 String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR;
55
56 if (Platform.isX86() || Platform.isX64() || Platform.isPPC()) {
57 String shouldFailMessage = "JVM startup should fail with option "
58 + "-XX:+UseRTMLocking on unsupported CPU";
59 // verify that we get an error when use +UseRTMLocking
60 // on unsupported CPU
61 CommandLineOptionTest.verifySameJVMStartup(
62 new String[] { errorMessage },
63 new String[] { unrecongnizedOption }, shouldFailMessage,
64 shouldFailMessage + ". Error message should be shown",
65 ExitCode.FAIL, "-XX:+UseRTMLocking");
66
67 String shouldPassMessage = "JVM startup should pass with option "
68 + "-XX:-UseRTMLocking even on unsupported CPU";
69 // verify that we can pass -UseRTMLocking without
79 String.format("Default value of option 'UseRTMLocking' "
80 +"should be '%s'", DEFAULT_VALUE));
81 } else {
82 String shouldFailMessage = "RTMLocking should be unrecognized"
83 + " on non-x86 CPUs. JVM startup should fail."
84 + "Error message should be shown";
85 // verify that on non-x86 CPUs RTMLocking could not be used
86 CommandLineOptionTest.verifySameJVMStartup(
87 new String[] { unrecongnizedOption },
88 null, shouldFailMessage, shouldFailMessage,
89 ExitCode.FAIL, "-XX:+UseRTMLocking");
90
91 CommandLineOptionTest.verifySameJVMStartup(
92 new String[] { unrecongnizedOption },
93 null, shouldFailMessage, shouldFailMessage,
94 ExitCode.FAIL, "-XX:-UseRTMLocking");
95 }
96 }
97
98 public static void main(String args[]) throws Throwable {
99 new TestUseRTMLockingOptionOnUnsupportedCPU().runTestCases();
100 }
101 }
|