Path: blob/master/test/hotspot/jtreg/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.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 UseRTMLocking option processing on CPU and OS with rtm support and27* on VM with 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.TestUseRTMLockingOptionOnSupportedConfig34*/3536package compiler.rtm.cli;3738import jdk.test.lib.process.ExitCode;39import jdk.test.lib.cli.CommandLineOptionTest;4041public class TestUseRTMLockingOptionOnSupportedConfig {42private static final String DEFAULT_VALUE = "false";4344public void runTestCases() throws Throwable {45String unrecongnizedOption46= CommandLineOptionTest.getUnrecognizedOptionErrorMessage(47"UseRTMLocking");48String shouldPassMessage = "VM option 'UseRTMLocking' is experimental"49+ "%nJVM startup should pass with "50+ "-XX:+UnlockExperimentalVMOptions flag";51// verify that there are no warning or error in VM output52CommandLineOptionTest.verifySameJVMStartup(null,53new String[]{54RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR,55unrecongnizedOption56}, shouldPassMessage, "There should not be any warning when use"57+ "with -XX:+UnlockExperimentalVMOptions", ExitCode.OK,58CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,59"-XX:+UseRTMLocking"60);6162CommandLineOptionTest.verifySameJVMStartup(null,63new String[]{64RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR,65unrecongnizedOption66}, shouldPassMessage, "There should not be any warning when use"67+ "with -XX:+UnlockExperimentalVMOptions", ExitCode.OK,68CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,69"-XX:-UseRTMLocking"70);71// verify that UseRTMLocking is of by default72CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",73TestUseRTMLockingOptionOnSupportedConfig.DEFAULT_VALUE,74String.format("Default value of option 'UseRTMLocking' should "75+ "be '%s'", DEFAULT_VALUE),76CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);77// verify that we can change UseRTMLocking value78CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",79TestUseRTMLockingOptionOnSupportedConfig.DEFAULT_VALUE,80String.format("Default value of option 'UseRTMLocking' should "81+ "be '%s'", DEFAULT_VALUE),82CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,83"-XX:-UseRTMLocking");84CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",85"true", "Value of 'UseRTMLocking' should be set "86+ "to 'true' if -XX:+UseRTMLocking flag set",87CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,88"-XX:+UseRTMLocking");89}9091public static void main(String args[]) throws Throwable {92new TestUseRTMLockingOptionOnSupportedConfig().runTestCases();93}94}959697