Path: blob/master/test/hotspot/jtreg/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java
41152 views
/*1* Copyright (c) 2014, 2016, 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*/2223package compiler.rtm.cli;2425import jdk.test.lib.process.ExitCode;26import jdk.test.lib.Platform;27import jdk.test.lib.cli.CommandLineOptionTest;2829public abstract class TestPrintPreciseRTMLockingStatisticsBase30extends RTMGenericCommandLineOptionTest {31protected static final String DEFAULT_VALUE = "false";3233protected TestPrintPreciseRTMLockingStatisticsBase() {34super("PrintPreciseRTMLockingStatistics", true, false,35TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE);36}3738@Override39protected void runNonX86TestCases() throws Throwable {40verifyJVMStartup();41verifyOptionValues();42}4344@Override45protected void verifyJVMStartup() throws Throwable {46if (Platform.isServer()) {47if (!Platform.isDebugBuild()) {48String shouldFailMessage = String.format("VM option '%s' is "49+ "diagnostic%nJVM startup should fail without "50+ "-XX:\\+UnlockDiagnosticVMOptions flag", optionName);51String shouldPassMessage = String.format("VM option '%s' is "52+ "diagnostic%nJVM startup should pass with "53+ "-XX:\\+UnlockDiagnosticVMOptions in debug build",54optionName);55String errorMessage = CommandLineOptionTest.56getDiagnosticOptionErrorMessage(optionName);57// verify that option is actually diagnostic58CommandLineOptionTest.verifySameJVMStartup(59new String[] { errorMessage }, null, shouldFailMessage,60shouldFailMessage, ExitCode.FAIL,61prepareOptionValue("true"));6263CommandLineOptionTest.verifySameJVMStartup(null,64new String[] { errorMessage }, shouldPassMessage,65shouldPassMessage + "without any warnings", ExitCode.OK,66CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,67prepareOptionValue("true"));68} else {69String shouldPassMessage = String.format("JVM startup should "70+ "pass with '%s' option in debug build",71optionName);72CommandLineOptionTest.verifySameJVMStartup(null, null,73shouldPassMessage, shouldPassMessage,74ExitCode.OK, prepareOptionValue("true"));75}76} else {77String errorMessage = CommandLineOptionTest.78getUnrecognizedOptionErrorMessage(optionName);79String shouldFailMessage = String.format("JVM startup should fail"80+ " with '%s' option in not debug build", optionName);81CommandLineOptionTest.verifySameJVMStartup(82new String[]{errorMessage}, null, shouldFailMessage,83shouldFailMessage, ExitCode.FAIL,84CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,85prepareOptionValue("true"));86}87}8889@Override90protected void verifyOptionValues() throws Throwable {91if (Platform.isServer()) {92// Verify default value93CommandLineOptionTest.verifyOptionValueForSameVM(optionName,94TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE,95String.format("Option '%s' should have '%s' default value",96optionName,97TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE),98CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS);99}100}101}102103104