Path: blob/master/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java
41152 views
/*1* Copyright (c) 2015, 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* @library /test/lib /26* @modules java.base/jdk.internal.misc27* java.management28*29* @build sun.hotspot.WhiteBox30* @requires !(vm.cpu.features ~= ".*aes.*")31* @requires vm.compiler1.enabled | !vm.graal.enabled32* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox33* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions34* -XX:+WhiteBoxAPI -Xbatch35* compiler.cpuflags.TestAESIntrinsicsOnUnsupportedConfig36*/3738package compiler.cpuflags;3940import jdk.test.lib.process.OutputAnalyzer;41import jdk.test.lib.process.ProcessTools;42import jdk.test.lib.cli.predicate.NotPredicate;43import static jdk.test.lib.cli.CommandLineOptionTest.*;4445public class TestAESIntrinsicsOnUnsupportedConfig extends AESIntrinsicsBase {4647private static final String INTRINSICS_NOT_AVAILABLE_MSG = "warning: AES "48+ "intrinsics are not available on this CPU";49private static final String AES_NOT_AVAILABLE_MSG = "warning: AES "50+ "instructions are not available on this CPU";5152protected void runTestCases() throws Throwable {53testUseAES();54testUseAESIntrinsics();55}5657/**58* Test checks following situation: <br/>59* UseAESIntrinsics flag is set to true, TestAESMain is executed <br/>60* Expected result: UseAESIntrinsics flag is set to false <br/>61* UseAES flag is set to false <br/>62* Output shouldn't contain intrinsics usage <br/>63* Output should contain message about intrinsics unavailability64* @throws Throwable65*/66private void testUseAESIntrinsics() throws Throwable {67OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(68AESIntrinsicsBase.prepareArguments(prepareBooleanFlag(69AESIntrinsicsBase.USE_AES_INTRINSICS, true)));70final String errorMessage = "Case testUseAESIntrinsics failed";71verifyOutput(new String[] {INTRINSICS_NOT_AVAILABLE_MSG},72new String[] {AESIntrinsicsBase.CIPHER_INTRINSIC,73AESIntrinsicsBase.AES_INTRINSIC},74errorMessage, outputAnalyzer);75verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",76errorMessage, outputAnalyzer);77verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage,78outputAnalyzer);79}8081/**82* Test checks following situation: <br/>83* UseAESIntrinsics flag is set to true, TestAESMain is executed <br/>84* Expected result: UseAES flag is set to false <br/>85* UseAES flag is set to false <br/>86* Output shouldn't contain intrinsics usage <br/>87* Output should contain message about AES unavailability <br/>88* @throws Throwable89*/90private void testUseAES() throws Throwable {91OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(92AESIntrinsicsBase.prepareArguments(prepareBooleanFlag93(AESIntrinsicsBase.USE_AES, true)));94final String errorMessage = "Case testUseAES failed";95verifyOutput(new String[] {AES_NOT_AVAILABLE_MSG},96new String[] {AESIntrinsicsBase.CIPHER_INTRINSIC,97AESIntrinsicsBase.AES_INTRINSIC}, errorMessage, outputAnalyzer);98verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",99errorMessage, outputAnalyzer);100verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage,101outputAnalyzer);102}103104public static void main(String args[]) throws Throwable {105new TestAESIntrinsicsOnUnsupportedConfig().runTestCases();106}107}108109110