< prev index next >

test/hotspot/jtreg/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java

Print this page

 32  * @requires vm.flagless
 33  * @requires !vm.rtm.cpu & vm.rtm.compiler
 34  * @run driver compiler.rtm.cli.TestUseRTMLockingOptionOnUnsupportedCPU
 35  */
 36 
 37 package compiler.rtm.cli;
 38 
 39 import jdk.test.lib.process.ExitCode;
 40 import jdk.test.lib.Platform;
 41 import jdk.test.lib.cli.CommandLineOptionTest;
 42 
 43 public class TestUseRTMLockingOptionOnUnsupportedCPU {
 44     private static final String DEFAULT_VALUE = "false";
 45 
 46     public void runTestCases() throws Throwable {
 47         String unrecognizedOption
 48                 = CommandLineOptionTest.getUnrecognizedOptionErrorMessage(
 49                 "UseRTMLocking");
 50         String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR;
 51 
 52         if (Platform.isX86() || Platform.isX64() || Platform.isPPC()) {
 53             String shouldFailMessage = "JVM startup should fail with option " +
 54                                        "-XX:+UseRTMLocking on unsupported CPU";
 55 
 56             try {
 57                 // verify that we get an error when use +UseRTMLocking
 58                 // on unsupported CPU
 59                 CommandLineOptionTest.verifySameJVMStartup(
 60                         new String[] { errorMessage },
 61                         new String[] { unrecognizedOption }, shouldFailMessage,
 62                         shouldFailMessage + ". Error message should be shown.",
 63                         ExitCode.FAIL, "-XX:+UseRTMLocking");
 64             } catch (Throwable e) {
 65                 // verify that we get an error when use +UseRTMLocking
 66                 // on unsupported OS. It might be the case that although CPU
 67                 // supports RTM the OS version does not support RTM
 68                 if (Platform.isPPC()) {
 69                     String errorMessage2 = RTMGenericCommandLineOptionTest.RTM_OS_ERROR;
 70                     String shouldFailMessage2 = "JVM startup should fail with option " +
 71                                                 "-XX:+UseRTMLocking on unsupported CPU or " +
 72                                                 "OS version";
 73 
 74                     CommandLineOptionTest.verifySameJVMStartup(
 75                             new String[] { errorMessage2 },
 76                             new String[] { unrecognizedOption}, shouldFailMessage2,
 77                             shouldFailMessage2 + ". Error message should be shown.",
 78                             ExitCode.FAIL, "-XX:+UseRTMLocking");
 79                 } else {
 80                     throw e; // checking unsupported OS error is not necessary
 81                 }
 82             }
 83 
 84             String shouldPassMessage = "JVM startup should pass with option "
 85                     + "-XX:-UseRTMLocking even on unsupported CPU";
 86             // verify that we can pass -UseRTMLocking without
 87             // getting any error messages
 88             CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
 89                     errorMessage, unrecognizedOption }, shouldPassMessage,
 90                     shouldPassMessage + " without any warnings", ExitCode.OK,
 91                     "-XX:-UseRTMLocking");
 92 
 93             // verify that UseRTMLocking is false by default
 94             CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
 95                     TestUseRTMLockingOptionOnUnsupportedCPU.DEFAULT_VALUE,
 96                     String.format("Default value of option 'UseRTMLocking' "
 97                         +"should be '%s'", DEFAULT_VALUE));
 98         } else {
 99             String shouldFailMessage = "RTMLocking should be unrecognized"
100                     + " on non-x86 CPUs. JVM startup should fail."
101                     + "Error message should be shown";
102             // verify that on non-x86 CPUs RTMLocking could not be used

 32  * @requires vm.flagless
 33  * @requires !vm.rtm.cpu & vm.rtm.compiler
 34  * @run driver compiler.rtm.cli.TestUseRTMLockingOptionOnUnsupportedCPU
 35  */
 36 
 37 package compiler.rtm.cli;
 38 
 39 import jdk.test.lib.process.ExitCode;
 40 import jdk.test.lib.Platform;
 41 import jdk.test.lib.cli.CommandLineOptionTest;
 42 
 43 public class TestUseRTMLockingOptionOnUnsupportedCPU {
 44     private static final String DEFAULT_VALUE = "false";
 45 
 46     public void runTestCases() throws Throwable {
 47         String unrecognizedOption
 48                 = CommandLineOptionTest.getUnrecognizedOptionErrorMessage(
 49                 "UseRTMLocking");
 50         String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR;
 51 
 52         if (Platform.isX86() || Platform.isX64()) {
 53             String shouldFailMessage = "JVM startup should fail with option " +
 54                                        "-XX:+UseRTMLocking on unsupported CPU";
 55 
 56             // verify that we get an error when use +UseRTMLocking
 57             // on unsupported CPU
 58             CommandLineOptionTest.verifySameJVMStartup(
 59                     new String[] { errorMessage },
 60                     new String[] { unrecognizedOption }, shouldFailMessage,
 61                     shouldFailMessage + ". Error message should be shown.",
 62                     ExitCode.FAIL, "-XX:+UseRTMLocking");




















 63 
 64             String shouldPassMessage = "JVM startup should pass with option "
 65                     + "-XX:-UseRTMLocking even on unsupported CPU";
 66             // verify that we can pass -UseRTMLocking without
 67             // getting any error messages
 68             CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
 69                     errorMessage, unrecognizedOption }, shouldPassMessage,
 70                     shouldPassMessage + " without any warnings", ExitCode.OK,
 71                     "-XX:-UseRTMLocking");
 72 
 73             // verify that UseRTMLocking is false by default
 74             CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
 75                     TestUseRTMLockingOptionOnUnsupportedCPU.DEFAULT_VALUE,
 76                     String.format("Default value of option 'UseRTMLocking' "
 77                         +"should be '%s'", DEFAULT_VALUE));
 78         } else {
 79             String shouldFailMessage = "RTMLocking should be unrecognized"
 80                     + " on non-x86 CPUs. JVM startup should fail."
 81                     + "Error message should be shown";
 82             // verify that on non-x86 CPUs RTMLocking could not be used
< prev index next >