1 /* 2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 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 package compiler.intrinsics.sha.cli.testcases; 25 26 import compiler.intrinsics.sha.cli.SHAOptionsBase; 27 import jdk.test.lib.ExitCode; 28 import jdk.test.lib.Platform; 29 import jdk.test.lib.cli.CommandLineOptionTest; 30 import jdk.test.lib.cli.predicate.AndPredicate; 31 import jdk.test.lib.cli.predicate.NotPredicate; 32 33 /** 34 * Generic test case for SHA-related options targeted to AArch64 CPUs 35 * which don't support instruction required by the tested option. 36 */ 37 public class GenericTestCaseForUnsupportedAArch64CPU extends 38 SHAOptionsBase.TestCase { 39 public GenericTestCaseForUnsupportedAArch64CPU(String optionName) { 40 super(optionName, new AndPredicate(Platform::isAArch64, 41 new NotPredicate(SHAOptionsBase.getPredicateForOption( 42 optionName)))); 43 } 44 45 @Override 46 protected void verifyWarnings() throws Throwable { 47 String shouldPassMessage = String.format("JVM startup should pass with" 48 + "option '-XX:-%s' without any warnings", optionName); 49 //Verify that option could be disabled without any warnings. 50 CommandLineOptionTest.verifySameJVMStartup(null, new String[] { 51 SHAOptionsBase.getWarningForUnsupportedCPU(optionName) 52 }, shouldPassMessage, shouldPassMessage, ExitCode.OK, 53 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, 54 CommandLineOptionTest.prepareBooleanFlag(optionName, false)); 55 56 shouldPassMessage = String.format("If JVM is started with '-XX:-" 57 + "%s' '-XX:+%s', output should contain warning.", 58 SHAOptionsBase.USE_SHA_OPTION, optionName); 59 60 // Verify that when the tested option is enabled, then 61 // a warning will occur in VM output if UseSHA is disabled. 62 if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) { 63 CommandLineOptionTest.verifySameJVMStartup( 64 new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, 65 null, 66 shouldPassMessage, 67 shouldPassMessage, 68 ExitCode.OK, 69 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, 70 CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), 71 CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 72 } 73 } 74 75 @Override 76 protected void verifyOptionValues() throws Throwable { 77 // Verify that option is disabled by default. 78 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 79 String.format("Option '%s' should be disabled by default", 80 optionName), 81 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS); 82 83 // Verify that option is disabled even if it was explicitly enabled 84 // using CLI options. 85 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 86 String.format("Option '%s' should be off on unsupported " 87 + "AArch64CPU even if set to true directly", optionName), 88 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, 89 CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 90 91 // Verify that option is disabled when +UseSHA was passed to JVM. 92 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 93 String.format("Option '%s' should be off on unsupported " 94 + "AArch64CPU even if %s flag set to JVM", 95 optionName, CommandLineOptionTest.prepareBooleanFlag( 96 SHAOptionsBase.USE_SHA_OPTION, true)), 97 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, 98 CommandLineOptionTest.prepareBooleanFlag( 99 SHAOptionsBase.USE_SHA_OPTION, true)); 100 } 101 }