< prev index next >

test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java

Print this page




  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 with rtm support
  28  *          in case when VM should not support this option.
  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.TestUseRTMLockingOptionOnUnsupportedVM
  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.cli.CommandLineOptionTest;
  47 import jdk.test.lib.cli.predicate.AndPredicate;
  48 import jdk.test.lib.cli.predicate.NotPredicate;
  49 
  50 public class TestUseRTMLockingOptionOnUnsupportedVM
  51         extends CommandLineOptionTest {
  52     private static final String DEFAULT_VALUE = "false";
  53 
  54     private TestUseRTMLockingOptionOnUnsupportedVM() {
  55         super(new AndPredicate(new SupportedCPU(),
  56                 new NotPredicate(new SupportedVM())));
  57     }
  58     @Override
  59     public void runTestCases() throws Throwable {
  60         String errorMessage
  61                 = RTMGenericCommandLineOptionTest.RTM_UNSUPPORTED_VM_ERROR;
  62         String shouldFailMessage = "JVM startup should fail with option "
  63                 + "-XX:+UseRTMLocking even on unsupported VM. Error message"
  64                 + " should be shown";
  65         String shouldPassMessage = "JVM startup should pass with option "
  66                 + "-XX:-UseRTMLocking even on unsupported VM";
  67         // verify that we can't use +UseRTMLocking
  68         CommandLineOptionTest.verifySameJVMStartup(
  69                 new String[] { errorMessage }, null, shouldFailMessage,
  70                 shouldFailMessage, ExitCode.FAIL,
  71                  "-XX:+UseRTMLocking");
  72         // verify that we can turn it off
  73         CommandLineOptionTest.verifySameJVMStartup(null,
  74                 new String[] { errorMessage }, shouldPassMessage,
  75                 shouldPassMessage + " without any warnings", ExitCode.OK,
  76                 "-XX:-UseRTMLocking");
  77         // verify that it is off by default
  78         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
  79                 TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE,
  80                 String.format("Default value of option 'UseRTMLocking' should"
  81                     + " be '%s'", DEFAULT_VALUE));
  82     }
  83 
  84     public static void main(String args[]) throws Throwable {
  85         new TestUseRTMLockingOptionOnUnsupportedVM().test();
  86     }
  87 }


  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 with rtm support
  28  *          in case when VM should not support this option.
  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.TestUseRTMLockingOptionOnUnsupportedVM
  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 TestUseRTMLockingOptionOnUnsupportedVM {

  47     private static final String DEFAULT_VALUE = "false";
  48 





  49     public void runTestCases() throws Throwable {
  50         String errorMessage
  51                 = RTMGenericCommandLineOptionTest.RTM_UNSUPPORTED_VM_ERROR;
  52         String shouldFailMessage = "JVM startup should fail with option "
  53                 + "-XX:+UseRTMLocking even on unsupported VM. Error message"
  54                 + " should be shown";
  55         String shouldPassMessage = "JVM startup should pass with option "
  56                 + "-XX:-UseRTMLocking even on unsupported VM";
  57         // verify that we can't use +UseRTMLocking
  58         CommandLineOptionTest.verifySameJVMStartup(
  59                 new String[] { errorMessage }, null, shouldFailMessage,
  60                 shouldFailMessage, ExitCode.FAIL,
  61                  "-XX:+UseRTMLocking");
  62         // verify that we can turn it off
  63         CommandLineOptionTest.verifySameJVMStartup(null,
  64                 new String[] { errorMessage }, shouldPassMessage,
  65                 shouldPassMessage + " without any warnings", ExitCode.OK,
  66                 "-XX:-UseRTMLocking");
  67         // verify that it is off by default
  68         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
  69                 TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE,
  70                 String.format("Default value of option 'UseRTMLocking' should"
  71                     + " be '%s'", DEFAULT_VALUE));
  72     }
  73 
  74     public static void main(String args[]) throws Throwable {
  75         new TestUseRTMLockingOptionOnUnsupportedVM().runTestCases();
  76     }
  77 }
< prev index next >