Path: blob/master/test/hotspot/jtreg/compiler/arguments/BMIUnsupportedCPUTest.java
41149 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.arguments;2425import jdk.test.lib.process.ExitCode;26import jdk.test.lib.Platform;27import jdk.test.lib.cli.CommandLineOptionTest;2829/**30* Test on bit manipulation related command line options,31* that should be executed on CPU that does not support32* required features.33*34* Note that this test intended to verify that VM could be launched with35* specific options and that values of these options processed correctly.36* In order to do that test launch a new VM with tested options, the same37* flavor-specific flag as one that was used for parent VM (-client, -server,38* -minimal, -graal) and '-version'.39*/40public class BMIUnsupportedCPUTest extends BMICommandLineOptionTestBase {4142/**43* Construct new test on {@code optionName} option.44*45* @param optionName Name of the option to be tested46* without -XX:[+-] prefix.47* @param warningMessage Message that can occur in VM output48* if CPU on test box does not support49* features required by the option.50* @param cpuFeatures CPU features requires by the option.51*/52public BMIUnsupportedCPUTest(String optionName,53String warningMessage,54String... cpuFeatures) {55super(optionName, warningMessage, null, cpuFeatures);56}5758@Override59public void runTestCases() throws Throwable {60if (Platform.isX86() || Platform.isX64()) {61unsupportedX86CPUTestCases();62} else {63unsupportedNonX86CPUTestCases();64}65}6667/**68* Run test cases common for all bit manipulation related VM options69* targeted to X86 CPU that does not support required features.70*71* @throws Throwable if test failed.72*/73public void unsupportedX86CPUTestCases() throws Throwable {7475/*76Verify that VM will successfully start up, but output will contain a77warning. VM will be launched with following options:78-XX:+<tested option> -version79*/80String errorString = String.format("JVM should start with '-XX:+%s' "81+ "flag, but output should contain warning.", optionName);82CommandLineOptionTest.verifySameJVMStartup(83new String[] { warningMessage }, new String[] { errorMessage },84errorString, String.format("Option '%s' is unsupported.%n"85+ "Warning expected to be shown.", optionName), ExitCode.OK,86CommandLineOptionTest.prepareBooleanFlag(87optionName, true));8889/*90Verify that VM will successfully startup without any warnings.91VM will be launched with following options:92-XX:-<tested option> -version93*/94errorString = String.format("JVM should start with '-XX:-%s' flag "95+ "without any warnings", optionName);96CommandLineOptionTest.verifySameJVMStartup(null,97new String[] { warningMessage, errorMessage },98errorString, errorString, ExitCode.OK,99CommandLineOptionTest.prepareBooleanFlag(optionName, false));100101/*102* Verify that on unsupported CPUs option is off by default. VM will be103* launched with following options: -version104*/105CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",106String.format("Option '%s' is expected to have default value "107+ "'false' since feature required is not supported "108+ "on CPU", optionName));109110/*111Verify that on unsupported CPUs option will be off even if112it was explicitly turned on by user. VM will be launched with113following options: -XX:+<tested option> -version114*/115CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",116String.format("Option '%s' is expected to have default value"117+ " 'false' since feature required is not supported on"118+ " CPU even if user set another value.", optionName),119CommandLineOptionTest.prepareBooleanFlag(optionName, true));120121}122123/**124* Run test cases common for all bit manipulation related VM options125* targeted to non-X86 CPU that does not support required features.126*127* @throws Throwable if test failed.128*/129public void unsupportedNonX86CPUTestCases() throws Throwable {130131/*132Verify that VM known nothing about tested option. VM will be launched133with following options: -XX:[+-]<tested option> -version134*/135CommandLineOptionTest.verifySameJVMStartup(136new String[] { errorMessage }, null,137String.format("JVM startup should fail with '-XX:+%s' flag."138+ "%nOption should be unknown (non-X86CPU).",139optionName), "", ExitCode.FAIL,140CommandLineOptionTest.prepareBooleanFlag(optionName, true));141142CommandLineOptionTest.verifySameJVMStartup(143new String[] { errorMessage }, null,144String.format("JVM startup should fail with '-XX:-%s' flag."145+ "%nOption should be unknown (non-X86CPU)",146optionName), "", ExitCode.FAIL,147CommandLineOptionTest.prepareBooleanFlag(optionName, false));148}149}150151152153