1 /* 2 * Copyright (c) 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 25 /* 26 * @test 27 * @library /testlibrary /test/lib /compiler/codegen/7184394 / 28 * @modules java.base/jdk.internal.misc 29 * java.management 30 * @ignore 8146128 31 * @build TestAESIntrinsicsOnSupportedConfig TestAESMain 32 * @run driver ClassFileInstaller sun.hotspot.WhiteBox 33 * sun.hotspot.WhiteBox$WhiteBoxPermission 34 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 35 * -XX:+WhiteBoxAPI -Xbatch 36 * TestAESIntrinsicsOnSupportedConfig 37 */ 38 39 import jdk.test.lib.OutputAnalyzer; 40 import jdk.test.lib.Platform; 41 import jdk.test.lib.ProcessTools; 42 43 public class TestAESIntrinsicsOnSupportedConfig extends AESIntrinsicsBase { 44 45 /** 46 * Constructs new TestAESIntrinsicsOnSupportedConfig that will be executed 47 * only if AESSupportPredicate returns true 48 */ 49 private TestAESIntrinsicsOnSupportedConfig() { 50 super(AESIntrinsicsBase.AES_SUPPORTED_PREDICATE); 51 } 52 53 @Override 54 protected void runTestCases() throws Throwable { 55 testUseAES(); 56 testUseAESUseSSE2(); 57 testUseAESUseVIS2(); 58 testNoUseAES(); 59 testNoUseAESUseSSE2(); 60 testNoUseAESUseVIS2(); 61 testNoUseAESIntrinsic(); 62 } 63 64 /** 65 * Test checks following situation: <br/> 66 * UseAES flag is set to true, TestAESMain is executed <br/> 67 * Expected result: UseAESIntrinsics flag is set to true <br/> 68 * If vm type is server then output should contain intrinsics usage <br/> 69 * 70 * @throws Throwable 71 */ 72 private void testUseAES() throws Throwable { 73 OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( 74 prepareArguments(prepareBooleanFlag(AESIntrinsicsBase 75 .USE_AES, true))); 76 final String errorMessage = "Case testUseAES failed"; 77 if (Platform.isServer()) { 78 verifyOutput(new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, 79 AESIntrinsicsBase.AES_INTRINSIC}, null, errorMessage, 80 outputAnalyzer); 81 } else { 82 verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, 83 AESIntrinsicsBase.AES_INTRINSIC}, errorMessage, 84 outputAnalyzer); 85 } 86 verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage, 87 outputAnalyzer); 88 verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "true", 89 errorMessage, outputAnalyzer); 90 } 91 92 /** 93 * Test checks following situation: <br/> 94 * UseAES flag is set to true, UseSSE flag is set to 2, 95 * Platform should support UseSSE (x86 or x64) <br/> 96 * TestAESMain is executed <br/> 97 * Expected result: UseAESIntrinsics flag is set to false <br/> 98 * Output shouldn't contain intrinsics usage <br/> 99 * 100 * @throws Throwable 101 */ 102 private void testUseAESUseSSE2() throws Throwable { 103 if (Platform.isX86() || Platform.isX64()) { 104 OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( 105 prepareArguments(prepareBooleanFlag(AESIntrinsicsBase 106 .USE_AES_INTRINSICS, true), 107 prepareNumericFlag(AESIntrinsicsBase.USE_SSE, 2))); 108 final String errorMessage = "Case testUseAESUseSSE2 failed"; 109 verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, 110 AESIntrinsicsBase.AES_INTRINSIC}, 111 errorMessage, outputAnalyzer); 112 verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage, 113 outputAnalyzer); 114 verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", 115 errorMessage, outputAnalyzer); 116 verifyOptionValue(AESIntrinsicsBase.USE_SSE, "2", errorMessage, 117 outputAnalyzer); 118 } 119 } 120 121 /** 122 * Test checks following situation: <br/> 123 * UseAES flag is set to false, UseSSE flag is set to 2, 124 * Platform should support UseSSE (x86 or x64) <br/> 125 * TestAESMain is executed <br/> 126 * Expected result: UseAESIntrinsics flag is set to false <br/> 127 * Output shouldn't contain intrinsics usage <br/> 128 * 129 * @throws Throwable 130 */ 131 private void testNoUseAESUseSSE2() throws Throwable { 132 if (Platform.isX86() || Platform.isX64()) { 133 OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( 134 prepareArguments(prepareBooleanFlag(AESIntrinsicsBase 135 .USE_AES, false), 136 prepareNumericFlag(AESIntrinsicsBase.USE_SSE, 2))); 137 final String errorMessage = "Case testNoUseAESUseSSE2 failed"; 138 verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, 139 AESIntrinsicsBase.AES_INTRINSIC}, 140 errorMessage, outputAnalyzer); 141 verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage, 142 outputAnalyzer); 143 verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", 144 errorMessage, outputAnalyzer); 145 verifyOptionValue(AESIntrinsicsBase.USE_SSE, "2", errorMessage, 146 outputAnalyzer); 147 } 148 } 149 150 /** 151 * Test checks following situation: <br/> 152 * UseAES flag is set to true, UseVIS flag is set to 2, 153 * Platform should support UseVIS (sparc) <br/> 154 * TestAESMain is executed <br/> 155 * Expected result: UseAESIntrinsics flag is set to false <br/> 156 * Output shouldn't contain intrinsics usage <br/> 157 * 158 * @throws Throwable 159 */ 160 private void testUseAESUseVIS2() throws Throwable { 161 if (Platform.isSparc()) { 162 OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( 163 prepareArguments(prepareBooleanFlag(AESIntrinsicsBase 164 .USE_AES_INTRINSICS, true), 165 prepareNumericFlag(AESIntrinsicsBase.USE_VIS, 2))); 166 final String errorMessage = "Case testUseAESUseVIS2 failed"; 167 verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, 168 AESIntrinsicsBase.AES_INTRINSIC}, 169 errorMessage, outputAnalyzer); 170 verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage, 171 outputAnalyzer); 172 verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", 173 errorMessage, outputAnalyzer); 174 verifyOptionValue(AESIntrinsicsBase.USE_VIS, "2", errorMessage, 175 outputAnalyzer); 176 } 177 } 178 179 180 /** 181 * Test checks following situation: <br/> 182 * UseAES flag is set to false, UseVIS flag is set to 2, 183 * Platform should support UseVIS (sparc) <br/> 184 * TestAESMain is executed <br/> 185 * Expected result: UseAESIntrinsics flag is set to false <br/> 186 * Output shouldn't contain intrinsics usage <br/> 187 * 188 * @throws Throwable 189 */ 190 private void testNoUseAESUseVIS2() throws Throwable { 191 if (Platform.isSparc()) { 192 OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( 193 prepareArguments(prepareBooleanFlag(AESIntrinsicsBase 194 .USE_AES, false), 195 prepareNumericFlag(AESIntrinsicsBase.USE_VIS, 2))); 196 final String errorMessage = "Case testNoUseAESUseVIS2 failed"; 197 verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, 198 AESIntrinsicsBase.AES_INTRINSIC}, 199 errorMessage, outputAnalyzer); 200 verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage, 201 outputAnalyzer); 202 verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", 203 errorMessage, outputAnalyzer); 204 verifyOptionValue(AESIntrinsicsBase.USE_VIS, "2", errorMessage, 205 outputAnalyzer); 206 } 207 } 208 209 /** 210 * Test checks following situation: <br/> 211 * UseAES flag is set to false, TestAESMain is executed <br/> 212 * Expected result: UseAESIntrinsics flag is set to false <br/> 213 * Output shouldn't contain intrinsics usage <br/> 214 * 215 * @throws Throwable 216 */ 217 private void testNoUseAES() throws Throwable { 218 OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( 219 prepareArguments(prepareBooleanFlag(AESIntrinsicsBase 220 .USE_AES, false))); 221 final String errorMessage = "Case testNoUseAES failed"; 222 verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, 223 AESIntrinsicsBase.AES_INTRINSIC}, 224 errorMessage, outputAnalyzer); 225 verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage, 226 outputAnalyzer); 227 verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", 228 errorMessage, outputAnalyzer); 229 } 230 231 /** 232 * Test checks following situation: <br/> 233 * UseAESIntrinsics flag is set to false, TestAESMain is executed <br/> 234 * Expected result: UseAES flag is set to true <br/> 235 * Output shouldn't contain intrinsics usage <br/> 236 * 237 * @throws Throwable 238 */ 239 private void testNoUseAESIntrinsic() throws Throwable { 240 OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( 241 prepareArguments(prepareBooleanFlag(AESIntrinsicsBase 242 .USE_AES_INTRINSICS, false))); 243 final String errorMessage = "Case testNoUseAESIntrinsic failed"; 244 verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, 245 AESIntrinsicsBase.AES_INTRINSIC}, errorMessage, 246 outputAnalyzer); 247 verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage, 248 outputAnalyzer); 249 verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", 250 errorMessage, outputAnalyzer); 251 } 252 253 public static void main(String args[]) throws Throwable { 254 new TestAESIntrinsicsOnSupportedConfig().test(); 255 } 256 }