Path: blob/master/test/hotspot/jtreg/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java
41152 views
/*1* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 803132026* @summary Verify UseRTMForStackLocks option processing on CPUs or OSs without27* rtm support and/or on VMs without rtm locking support.28* @library /test/lib /29* @modules java.base/jdk.internal.misc30* java.management31* @requires vm.flagless32* @requires !vm.rtm.cpu & vm.rtm.compiler33* @run driver compiler.rtm.cli.TestUseRTMForStackLocksOptionOnUnsupportedConfig34*/3536package compiler.rtm.cli;3738import jdk.test.lib.process.ExitCode;39import jdk.test.lib.cli.CommandLineOptionTest;4041public class TestUseRTMForStackLocksOptionOnUnsupportedConfig42extends RTMGenericCommandLineOptionTest {43private static final String DEFAULT_VALUE = "false";4445private TestUseRTMForStackLocksOptionOnUnsupportedConfig() {46super("UseRTMForStackLocks", true, true,47TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,48"true");49}5051@Override52protected void runX86SupportedVMTestCases() throws Throwable {53String shouldFailMessage = String.format("VM option '%s' is "54+ "experimental%nJVM startup should fail without "55+ "-XX:+UnlockExperimentalVMOptions flag", optionName);5657// verify that option is experimental58CommandLineOptionTest.verifySameJVMStartup(59new String[] { experimentalOptionError }, null,60shouldFailMessage, shouldFailMessage + "%nError message "61+ "should be shown", ExitCode.FAIL,62prepareOptionValue("true"));6364CommandLineOptionTest.verifySameJVMStartup(65new String[]{ experimentalOptionError }, null,66shouldFailMessage, shouldFailMessage + "%nError message "67+ "should be shown", ExitCode.FAIL,68prepareOptionValue("false"));6970String shouldPassMessage = String.format("VM option '%s' is "71+ " experimental%nJVM startup should pass with "72+ "-XX:+UnlockExperimentalVMOptions flag", optionName);73// verify that if we turn it on, then VM output will contain74// warning saying that this option could be turned on only75// when we use rtm locking76CommandLineOptionTest.verifySameJVMStartup(77new String[]{78RTMGenericCommandLineOptionTest.RTM_FOR_STACK_LOCKS_WARNING79}, null, shouldPassMessage, "There should be warning when try "80+ "to use rtm for stack lock, but not using rtm locking",81ExitCode.OK,82CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,83prepareOptionValue("true")84);85// verify that options is turned off by default86CommandLineOptionTest.verifyOptionValueForSameVM(optionName,87TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,88String.format("Default value of option '%s' should be '%s'",89optionName, DEFAULT_VALUE),90CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);91// verify that it could not be turned on without rtm locking92CommandLineOptionTest.verifyOptionValueForSameVM(optionName,93TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,94String.format("Value of '%s' shouldn't able to be set to "95+ "'true' without setting -XX:+UseRTMLocking flag",96optionName),97CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,98prepareOptionValue("true"));99}100101public static void main(String args[]) throws Throwable {102new TestUseRTMForStackLocksOptionOnUnsupportedConfig().runTestCases();103}104}105106107