Wed, 03 Sep 2014 15:29:57 +0400
8055904: Develop tests for new command-line options related to SHA intrinsics
Reviewed-by: kvn, iignatyev
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java Wed Sep 03 15:29:57 2014 +0400 1.3 @@ -0,0 +1,169 @@ 1.4 +/* 1.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + */ 1.26 + 1.27 +import com.oracle.java.testlibrary.Platform; 1.28 +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; 1.29 +import sha.predicate.IntrinsicPredicates; 1.30 + 1.31 +import java.util.function.BooleanSupplier; 1.32 + 1.33 +/** 1.34 + * Base class for all CLI tests on SHA-related options. 1.35 + * 1.36 + * Instead of using huge complex tests for each option, each test is constructed 1.37 + * from several test cases shared among different tests. 1.38 + */ 1.39 +public class SHAOptionsBase extends CommandLineOptionTest { 1.40 + protected static final String USE_SHA_OPTION = "UseSHA"; 1.41 + protected static final String USE_SHA1_INTRINSICS_OPTION 1.42 + = "UseSHA1Intrinsics"; 1.43 + protected static final String USE_SHA256_INTRINSICS_OPTION 1.44 + = "UseSHA256Intrinsics"; 1.45 + protected static final String USE_SHA512_INTRINSICS_OPTION 1.46 + = "UseSHA512Intrinsics"; 1.47 + 1.48 + // Note that strings below will be passed to 1.49 + // CommandLineOptionTest.verifySameJVMStartup and thus are regular 1.50 + // expressions, not just a plain strings. 1.51 + protected static final String SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE 1.52 + = "SHA instructions are not available on this CPU"; 1.53 + protected static final String SHA1_INSTRUCTION_IS_NOT_AVAILABLE 1.54 + = "SHA1 instruction is not available on this CPU\\."; 1.55 + protected static final String SHA256_INSTRUCTION_IS_NOT_AVAILABLE 1.56 + = "SHA256 instruction \\(for SHA-224 and SHA-256\\) " 1.57 + + "is not available on this CPU\\."; 1.58 + protected static final String SHA512_INSTRUCTION_IS_NOT_AVAILABLE 1.59 + = "SHA512 instruction \\(for SHA-384 and SHA-512\\) " 1.60 + + "is not available on this CPU\\."; 1.61 + protected static final String SHA_INTRINSICS_ARE_NOT_AVAILABLE 1.62 + = "SHA intrinsics are not available on this CPU"; 1.63 + 1.64 + private final TestCase[] testCases; 1.65 + 1.66 + /** 1.67 + * Returns warning message that should occur in VM output if an option with 1.68 + * the name {@code optionName} was turned on and CPU does not support 1.69 + * required instructions. 1.70 + * 1.71 + * @param optionName The name of the option for which warning message should 1.72 + * be returned. 1.73 + * @return A warning message that will be printed out to VM output if CPU 1.74 + * instructions required by the option are not supported. 1.75 + */ 1.76 + protected static String getWarningForUnsupportedCPU(String optionName) { 1.77 + if (Platform.isSparc()) { 1.78 + switch (optionName) { 1.79 + case SHAOptionsBase.USE_SHA_OPTION: 1.80 + return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE; 1.81 + case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION: 1.82 + return SHAOptionsBase.SHA1_INSTRUCTION_IS_NOT_AVAILABLE; 1.83 + case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION: 1.84 + return SHAOptionsBase.SHA256_INSTRUCTION_IS_NOT_AVAILABLE; 1.85 + case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION: 1.86 + return SHAOptionsBase.SHA512_INSTRUCTION_IS_NOT_AVAILABLE; 1.87 + default: 1.88 + throw new Error("Unexpected option " + optionName); 1.89 + } 1.90 + } else if (Platform.isX64() || Platform.isX86()) { 1.91 + switch (optionName) { 1.92 + case SHAOptionsBase.USE_SHA_OPTION: 1.93 + return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE; 1.94 + case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION: 1.95 + case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION: 1.96 + case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION: 1.97 + return SHAOptionsBase.SHA_INTRINSICS_ARE_NOT_AVAILABLE; 1.98 + default: 1.99 + throw new Error("Unexpected option " + optionName); 1.100 + } 1.101 + } else { 1.102 + throw new Error("Support for CPUs other then X86 or SPARC is not " 1.103 + + "implemented."); 1.104 + } 1.105 + } 1.106 + 1.107 + /** 1.108 + * Returns the predicate indicating whether or not CPU instructions required 1.109 + * by the option with name {@code optionName} are available. 1.110 + * 1.111 + * @param optionName The name of the option for which a predicate should be 1.112 + * returned. 1.113 + * @return The predicate on availability of CPU instructions required by the 1.114 + * option. 1.115 + */ 1.116 + protected static BooleanSupplier getPredicateForOption(String optionName) { 1.117 + switch (optionName) { 1.118 + case SHAOptionsBase.USE_SHA_OPTION: 1.119 + return IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE; 1.120 + case SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION: 1.121 + return IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE; 1.122 + case SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION: 1.123 + return IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE; 1.124 + case SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION: 1.125 + return IntrinsicPredicates.SHA512_INSTRUCTION_AVAILABLE; 1.126 + default: 1.127 + throw new Error("Unexpected option " + optionName); 1.128 + } 1.129 + } 1.130 + 1.131 + public SHAOptionsBase(TestCase... testCases) { 1.132 + super(Boolean.TRUE::booleanValue); 1.133 + this.testCases = testCases; 1.134 + } 1.135 + 1.136 + @Override 1.137 + protected void runTestCases() throws Throwable { 1.138 + for (TestCase testCase : testCases) { 1.139 + testCase.test(); 1.140 + } 1.141 + } 1.142 + 1.143 + public static abstract class TestCase { 1.144 + protected final String optionName; 1.145 + private final BooleanSupplier predicate; 1.146 + 1.147 + protected TestCase(String optionName, BooleanSupplier predicate) { 1.148 + this.optionName = optionName; 1.149 + this.predicate = predicate; 1.150 + } 1.151 + 1.152 + protected final void test() throws Throwable { 1.153 + String testCaseName = this.getClass().getName(); 1.154 + if (!predicate.getAsBoolean()) { 1.155 + System.out.println("Skipping " + testCaseName 1.156 + + " due to predicate failure."); 1.157 + return; 1.158 + } else { 1.159 + System.out.println("Running " + testCaseName); 1.160 + } 1.161 + 1.162 + verifyWarnings(); 1.163 + verifyOptionValues(); 1.164 + } 1.165 + 1.166 + protected void verifyWarnings() throws Throwable { 1.167 + } 1.168 + 1.169 + protected void verifyOptionValues() throws Throwable { 1.170 + } 1.171 + } 1.172 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnSupportedCPU.java Wed Sep 03 15:29:57 2014 +0400 2.3 @@ -0,0 +1,40 @@ 2.4 +/* 2.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +/** 2.28 + * @test 2.29 + * @bug 8035968 2.30 + * @summary Verify UseSHA1Intrinsics option processing on supported CPU, 2.31 + * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases 2.32 + * @build TestUseSHA1IntrinsicsOptionOnSupportedCPU 2.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 2.34 + * sun.hotspot.WhiteBox$WhiteBoxPermission 2.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 2.36 + * -XX:+WhiteBoxAPI TestUseSHA1IntrinsicsOptionOnSupportedCPU 2.37 + */ 2.38 +public class TestUseSHA1IntrinsicsOptionOnSupportedCPU { 2.39 + public static void main(String args[]) throws Throwable { 2.40 + new SHAOptionsBase(new GenericTestCaseForSupportedSparcCPU( 2.41 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION)).test(); 2.42 + } 2.43 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnUnsupportedCPU.java Wed Sep 03 15:29:57 2014 +0400 3.3 @@ -0,0 +1,48 @@ 3.4 +/* 3.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/** 3.28 + * @test 3.29 + * @bug 8035968 3.30 + * @summary Verify UseSHA1Intrinsics option processing on unsupported CPU, 3.31 + * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases 3.32 + * @build TestUseSHA1IntrinsicsOptionOnUnsupportedCPU 3.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 3.34 + * sun.hotspot.WhiteBox$WhiteBoxPermission 3.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 3.36 + * -XX:+WhiteBoxAPI 3.37 + * TestUseSHA1IntrinsicsOptionOnUnsupportedCPU 3.38 + */ 3.39 +public class TestUseSHA1IntrinsicsOptionOnUnsupportedCPU { 3.40 + public static void main(String args[]) throws Throwable { 3.41 + new SHAOptionsBase( 3.42 + new GenericTestCaseForUnsupportedSparcCPU( 3.43 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION), 3.44 + new UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU( 3.45 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION), 3.46 + new GenericTestCaseForUnsupportedX86CPU( 3.47 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION), 3.48 + new GenericTestCaseForOtherCPU( 3.49 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION)).test(); 3.50 + } 3.51 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnSupportedCPU.java Wed Sep 03 15:29:57 2014 +0400 4.3 @@ -0,0 +1,41 @@ 4.4 +/* 4.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. 4.11 + * 4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.15 + * version 2 for more details (a copy is included in the LICENSE file that 4.16 + * accompanied this code). 4.17 + * 4.18 + * You should have received a copy of the GNU General Public License version 4.19 + * 2 along with this work; if not, write to the Free Software Foundation, 4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.21 + * 4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.23 + * or visit www.oracle.com if you need additional information or have any 4.24 + * questions. 4.25 + */ 4.26 + 4.27 +/** 4.28 + * @test 4.29 + * @bug 8035968 4.30 + * @summary Verify UseSHA256Intrinsics option processing on supported CPU, 4.31 + * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases 4.32 + * @build TestUseSHA256IntrinsicsOptionOnSupportedCPU 4.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 4.34 + * sun.hotspot.WhiteBox$WhiteBoxPermission 4.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 4.36 + * -XX:+WhiteBoxAPI 4.37 + * TestUseSHA256IntrinsicsOptionOnSupportedCPU 4.38 + */ 4.39 +public class TestUseSHA256IntrinsicsOptionOnSupportedCPU { 4.40 + public static void main(String args[]) throws Throwable { 4.41 + new SHAOptionsBase(new GenericTestCaseForSupportedSparcCPU( 4.42 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION)).test(); 4.43 + } 4.44 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnUnsupportedCPU.java Wed Sep 03 15:29:57 2014 +0400 5.3 @@ -0,0 +1,48 @@ 5.4 +/* 5.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. 5.11 + * 5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 + * version 2 for more details (a copy is included in the LICENSE file that 5.16 + * accompanied this code). 5.17 + * 5.18 + * You should have received a copy of the GNU General Public License version 5.19 + * 2 along with this work; if not, write to the Free Software Foundation, 5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 + * 5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 5.23 + * or visit www.oracle.com if you need additional information or have any 5.24 + * questions. 5.25 + */ 5.26 + 5.27 +/** 5.28 + * @test 5.29 + * @bug 8035968 5.30 + * @summary Verify UseSHA256Intrinsics option processing on unsupported CPU, 5.31 + * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases 5.32 + * @build TestUseSHA256IntrinsicsOptionOnUnsupportedCPU 5.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 5.34 + * sun.hotspot.WhiteBox$WhiteBoxPermission 5.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 5.36 + * -XX:+WhiteBoxAPI 5.37 + * TestUseSHA256IntrinsicsOptionOnUnsupportedCPU 5.38 + */ 5.39 +public class TestUseSHA256IntrinsicsOptionOnUnsupportedCPU { 5.40 + public static void main(String args[]) throws Throwable { 5.41 + new SHAOptionsBase( 5.42 + new GenericTestCaseForUnsupportedSparcCPU( 5.43 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION), 5.44 + new UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU( 5.45 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION), 5.46 + new GenericTestCaseForUnsupportedX86CPU( 5.47 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION), 5.48 + new GenericTestCaseForOtherCPU( 5.49 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION)).test(); 5.50 + } 5.51 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java Wed Sep 03 15:29:57 2014 +0400 6.3 @@ -0,0 +1,41 @@ 6.4 +/* 6.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. 6.11 + * 6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.15 + * version 2 for more details (a copy is included in the LICENSE file that 6.16 + * accompanied this code). 6.17 + * 6.18 + * You should have received a copy of the GNU General Public License version 6.19 + * 2 along with this work; if not, write to the Free Software Foundation, 6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.21 + * 6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6.23 + * or visit www.oracle.com if you need additional information or have any 6.24 + * questions. 6.25 + */ 6.26 + 6.27 +/** 6.28 + * @test 6.29 + * @bug 8035968 6.30 + * @summary Verify UseSHA512Intrinsics option processing on supported CPU. 6.31 + * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases 6.32 + * @build TestUseSHA512IntrinsicsOptionOnSupportedCPU 6.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 6.34 + * sun.hotspot.WhiteBox$WhiteBoxPermission 6.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 6.36 + * -XX:+WhiteBoxAPI 6.37 + * TestUseSHA512IntrinsicsOptionOnSupportedCPU 6.38 + */ 6.39 +public class TestUseSHA512IntrinsicsOptionOnSupportedCPU { 6.40 + public static void main(String args[]) throws Throwable { 6.41 + new SHAOptionsBase(new GenericTestCaseForSupportedSparcCPU( 6.42 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION)).test(); 6.43 + } 6.44 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnUnsupportedCPU.java Wed Sep 03 15:29:57 2014 +0400 7.3 @@ -0,0 +1,48 @@ 7.4 +/* 7.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. 7.11 + * 7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.15 + * version 2 for more details (a copy is included in the LICENSE file that 7.16 + * accompanied this code). 7.17 + * 7.18 + * You should have received a copy of the GNU General Public License version 7.19 + * 2 along with this work; if not, write to the Free Software Foundation, 7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.21 + * 7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 7.23 + * or visit www.oracle.com if you need additional information or have any 7.24 + * questions. 7.25 + */ 7.26 + 7.27 +/** 7.28 + * @test 7.29 + * @bug 8035968 7.30 + * @summary Verify UseSHA512Intrinsics option processing on unsupported CPU, 7.31 + * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases 7.32 + * @build TestUseSHA512IntrinsicsOptionOnUnsupportedCPU 7.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 7.34 + * sun.hotspot.WhiteBox$WhiteBoxPermission 7.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 7.36 + * -XX:+WhiteBoxAPI 7.37 + * TestUseSHA512IntrinsicsOptionOnUnsupportedCPU 7.38 + */ 7.39 +public class TestUseSHA512IntrinsicsOptionOnUnsupportedCPU { 7.40 + public static void main(String args[]) throws Throwable { 7.41 + new SHAOptionsBase( 7.42 + new GenericTestCaseForUnsupportedSparcCPU( 7.43 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION), 7.44 + new UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU( 7.45 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION), 7.46 + new GenericTestCaseForUnsupportedX86CPU( 7.47 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION), 7.48 + new GenericTestCaseForOtherCPU( 7.49 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION)).test(); 7.50 + } 7.51 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnSupportedCPU.java Wed Sep 03 15:29:57 2014 +0400 8.3 @@ -0,0 +1,43 @@ 8.4 +/* 8.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 + * 8.8 + * This code is free software; you can redistribute it and/or modify it 8.9 + * under the terms of the GNU General Public License version 2 only, as 8.10 + * published by the Free Software Foundation. 8.11 + * 8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.15 + * version 2 for more details (a copy is included in the LICENSE file that 8.16 + * accompanied this code). 8.17 + * 8.18 + * You should have received a copy of the GNU General Public License version 8.19 + * 2 along with this work; if not, write to the Free Software Foundation, 8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.21 + * 8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.23 + * or visit www.oracle.com if you need additional information or have any 8.24 + * questions. 8.25 + */ 8.26 + 8.27 +/** 8.28 + * @test 8.29 + * @bug 8035968 8.30 + * @summary Verify UseSHA option processing on supported CPU, 8.31 + * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases 8.32 + * @build TestUseSHAOptionOnSupportedCPU 8.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 8.34 + * sun.hotspot.WhiteBox$WhiteBoxPermission 8.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 8.36 + * -XX:+WhiteBoxAPI TestUseSHAOptionOnSupportedCPU 8.37 + */ 8.38 +public class TestUseSHAOptionOnSupportedCPU { 8.39 + public static void main(String args[]) throws Throwable { 8.40 + new SHAOptionsBase( 8.41 + new GenericTestCaseForSupportedSparcCPU( 8.42 + SHAOptionsBase.USE_SHA_OPTION), 8.43 + new UseSHASpecificTestCaseForSupportedSparcCPU( 8.44 + SHAOptionsBase.USE_SHA_OPTION)).test(); 8.45 + } 8.46 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnUnsupportedCPU.java Wed Sep 03 15:29:57 2014 +0400 9.3 @@ -0,0 +1,47 @@ 9.4 +/* 9.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.23 + * or visit www.oracle.com if you need additional information or have any 9.24 + * questions. 9.25 + */ 9.26 + 9.27 +/** 9.28 + * @test 9.29 + * @bug 8035968 9.30 + * @summary Verify UseSHA option processing on unsupported CPU. 9.31 + * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases 9.32 + * @build TestUseSHAOptionOnUnsupportedCPU 9.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 9.34 + * sun.hotspot.WhiteBox$WhiteBoxPermission 9.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 9.36 + * -XX:+WhiteBoxAPI TestUseSHAOptionOnUnsupportedCPU 9.37 + */ 9.38 +public class TestUseSHAOptionOnUnsupportedCPU { 9.39 + public static void main(String args[]) throws Throwable { 9.40 + new SHAOptionsBase( 9.41 + new GenericTestCaseForUnsupportedSparcCPU( 9.42 + SHAOptionsBase.USE_SHA_OPTION), 9.43 + new UseSHASpecificTestCaseForUnsupportedSparcCPU( 9.44 + SHAOptionsBase.USE_SHA_OPTION), 9.45 + new GenericTestCaseForUnsupportedX86CPU( 9.46 + SHAOptionsBase.USE_SHA_OPTION), 9.47 + new GenericTestCaseForOtherCPU( 9.48 + SHAOptionsBase.USE_SHA_OPTION)).test(); 9.49 + } 9.50 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java Wed Sep 03 15:29:57 2014 +0400 10.3 @@ -0,0 +1,70 @@ 10.4 +/* 10.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 + * or visit www.oracle.com if you need additional information or have any 10.24 + * questions. 10.25 + */ 10.26 + 10.27 +import com.oracle.java.testlibrary.ExitCode; 10.28 +import com.oracle.java.testlibrary.Platform; 10.29 +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; 10.30 +import com.oracle.java.testlibrary.cli.predicate.NotPredicate; 10.31 +import com.oracle.java.testlibrary.cli.predicate.OrPredicate; 10.32 + 10.33 +/** 10.34 + * Generic test case for SHA-related options targeted to non-x86 and 10.35 + * non-SPARC CPUs. 10.36 + */ 10.37 +public class GenericTestCaseForOtherCPU extends 10.38 + SHAOptionsBase.TestCase { 10.39 + public GenericTestCaseForOtherCPU(String optionName) { 10.40 + // Execute the test case on any CPU except SPARC and X86 10.41 + super(optionName, new NotPredicate(new OrPredicate(Platform::isSparc, 10.42 + new OrPredicate(Platform::isX64, Platform::isX86)))); 10.43 + } 10.44 + 10.45 + @Override 10.46 + protected void verifyWarnings() throws Throwable { 10.47 + // Verify that on non-x86 and non-SPARC CPU usage of SHA-related 10.48 + // options will not cause any warnings. 10.49 + CommandLineOptionTest.verifySameJVMStartup(null, 10.50 + new String[] { ".*" + optionName + ".*" }, ExitCode.OK, 10.51 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 10.52 + 10.53 + CommandLineOptionTest.verifySameJVMStartup(null, 10.54 + new String[] { ".*" + optionName + ".*" }, ExitCode.OK, 10.55 + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); 10.56 + } 10.57 + 10.58 + @Override 10.59 + protected void verifyOptionValues() throws Throwable { 10.60 + // Verify that option is disabled by default. 10.61 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false"); 10.62 + 10.63 + // Verify that option is disabled even if it was explicitly enabled 10.64 + // using CLI options. 10.65 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 10.66 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 10.67 + 10.68 + // Verify that option is disabled when it explicitly disabled 10.69 + // using CLI options. 10.70 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 10.71 + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); 10.72 + } 10.73 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java Wed Sep 03 15:29:57 2014 +0400 11.3 @@ -0,0 +1,93 @@ 11.4 +/* 11.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.23 + * or visit www.oracle.com if you need additional information or have any 11.24 + * questions. 11.25 + */ 11.26 + 11.27 +import com.oracle.java.testlibrary.ExitCode; 11.28 +import com.oracle.java.testlibrary.Platform; 11.29 +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; 11.30 +import com.oracle.java.testlibrary.cli.predicate.AndPredicate; 11.31 + 11.32 +/** 11.33 + * Generic test case for SHA-related options targeted to SPARC CPUs which 11.34 + * support instructions required by the tested option. 11.35 + */ 11.36 +public class GenericTestCaseForSupportedSparcCPU extends 11.37 + SHAOptionsBase.TestCase { 11.38 + public GenericTestCaseForSupportedSparcCPU(String optionName) { 11.39 + super(optionName, new AndPredicate(Platform::isSparc, 11.40 + SHAOptionsBase.getPredicateForOption(optionName))); 11.41 + } 11.42 + 11.43 + @Override 11.44 + protected void verifyWarnings() throws Throwable { 11.45 + // Verify that there are no warning when option is explicitly enabled. 11.46 + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { 11.47 + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) 11.48 + }, ExitCode.OK, 11.49 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 11.50 + 11.51 + // Verify that option could be disabled even if +UseSHA was passed to 11.52 + // JVM. 11.53 + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { 11.54 + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) 11.55 + }, ExitCode.OK, 11.56 + CommandLineOptionTest.prepareBooleanFlag( 11.57 + SHAOptionsBase.USE_SHA_OPTION, true), 11.58 + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); 11.59 + 11.60 + // Verify that it is possible to enable the tested option and disable 11.61 + // all SHA intrinsics via -UseSHA without any warnings. 11.62 + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { 11.63 + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) 11.64 + }, ExitCode.OK, 11.65 + CommandLineOptionTest.prepareBooleanFlag( 11.66 + SHAOptionsBase.USE_SHA_OPTION, false), 11.67 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 11.68 + } 11.69 + 11.70 + @Override 11.71 + protected void verifyOptionValues() throws Throwable { 11.72 + // Verify that on supported CPU option is enabled by default. 11.73 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true"); 11.74 + 11.75 + // Verify that it is possible to explicitly enable the option. 11.76 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", 11.77 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 11.78 + 11.79 + // Verify that it is possible to explicitly disable the option. 11.80 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 11.81 + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); 11.82 + 11.83 + // verify that option is disabled when -UseSHA was passed to JVM. 11.84 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 11.85 + CommandLineOptionTest.prepareBooleanFlag(optionName, true), 11.86 + CommandLineOptionTest.prepareBooleanFlag( 11.87 + SHAOptionsBase.USE_SHA_OPTION, false)); 11.88 + 11.89 + // Verify that it is possible to explicitly disable the tested option 11.90 + // even if +UseSHA was passed to JVM. 11.91 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 11.92 + CommandLineOptionTest.prepareBooleanFlag( 11.93 + SHAOptionsBase.USE_SHA_OPTION, true), 11.94 + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); 11.95 + } 11.96 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java Wed Sep 03 15:29:57 2014 +0400 12.3 @@ -0,0 +1,66 @@ 12.4 +/* 12.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. 12.11 + * 12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.15 + * version 2 for more details (a copy is included in the LICENSE file that 12.16 + * accompanied this code). 12.17 + * 12.18 + * You should have received a copy of the GNU General Public License version 12.19 + * 2 along with this work; if not, write to the Free Software Foundation, 12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.21 + * 12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.23 + * or visit www.oracle.com if you need additional information or have any 12.24 + * questions. 12.25 + */ 12.26 + 12.27 +import com.oracle.java.testlibrary.ExitCode; 12.28 +import com.oracle.java.testlibrary.Platform; 12.29 +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; 12.30 +import com.oracle.java.testlibrary.cli.predicate.AndPredicate; 12.31 +import com.oracle.java.testlibrary.cli.predicate.NotPredicate; 12.32 + 12.33 +/** 12.34 + * Generic test case for SHA-related options targeted to SPARC CPUs which don't 12.35 + * support instruction required by the tested option. 12.36 + */ 12.37 +public class GenericTestCaseForUnsupportedSparcCPU extends 12.38 + SHAOptionsBase.TestCase { 12.39 + public GenericTestCaseForUnsupportedSparcCPU(String optionName) { 12.40 + super(optionName, new AndPredicate(Platform::isSparc, 12.41 + new NotPredicate(SHAOptionsBase.getPredicateForOption( 12.42 + optionName)))); 12.43 + } 12.44 + 12.45 + @Override 12.46 + protected void verifyWarnings() throws Throwable { 12.47 + //Verify that option could be disabled without any warnings. 12.48 + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { 12.49 + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) 12.50 + }, ExitCode.OK, 12.51 + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); 12.52 + } 12.53 + 12.54 + @Override 12.55 + protected void verifyOptionValues() throws Throwable { 12.56 + // Verify that option is disabled by default. 12.57 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false"); 12.58 + 12.59 + // Verify that option is disabled even if it was explicitly enabled 12.60 + // using CLI options. 12.61 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 12.62 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 12.63 + 12.64 + // Verify that option is disabled when +UseSHA was passed to JVM. 12.65 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 12.66 + CommandLineOptionTest.prepareBooleanFlag( 12.67 + SHAOptionsBase.USE_SHA_OPTION, true)); 12.68 + } 12.69 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java Wed Sep 03 15:29:57 2014 +0400 13.3 @@ -0,0 +1,71 @@ 13.4 +/* 13.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 + * 13.8 + * This code is free software; you can redistribute it and/or modify it 13.9 + * under the terms of the GNU General Public License version 2 only, as 13.10 + * published by the Free Software Foundation. 13.11 + * 13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.15 + * version 2 for more details (a copy is included in the LICENSE file that 13.16 + * accompanied this code). 13.17 + * 13.18 + * You should have received a copy of the GNU General Public License version 13.19 + * 2 along with this work; if not, write to the Free Software Foundation, 13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.21 + * 13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 13.23 + * or visit www.oracle.com if you need additional information or have any 13.24 + * questions. 13.25 + */ 13.26 + 13.27 +import com.oracle.java.testlibrary.ExitCode; 13.28 +import com.oracle.java.testlibrary.Platform; 13.29 +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; 13.30 +import com.oracle.java.testlibrary.cli.predicate.OrPredicate; 13.31 + 13.32 +/** 13.33 + * Generic test case for SHA-related options targeted to X86 CPUs that don't 13.34 + * support SHA-related instructions. 13.35 + */ 13.36 +public class GenericTestCaseForUnsupportedX86CPU 13.37 + extends SHAOptionsBase.TestCase { 13.38 + public GenericTestCaseForUnsupportedX86CPU(String optionName) { 13.39 + super(optionName, new OrPredicate(Platform::isX64, Platform::isX86)); 13.40 + } 13.41 + 13.42 + @Override 13.43 + protected void verifyWarnings() throws Throwable { 13.44 + // Verify that when the tested option is explicitly enabled, then 13.45 + // a warning will occur in VM output. 13.46 + CommandLineOptionTest.verifySameJVMStartup(new String[] { 13.47 + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) 13.48 + }, null, ExitCode.OK, 13.49 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 13.50 + 13.51 + // Verify that the tested option could be explicitly disabled without 13.52 + // a warning. 13.53 + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { 13.54 + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) 13.55 + }, ExitCode.OK, 13.56 + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); 13.57 + } 13.58 + 13.59 + @Override 13.60 + protected void verifyOptionValues() throws Throwable { 13.61 + // Verify that the tested option is disabled by default. 13.62 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false"); 13.63 + 13.64 + // Verify that it is not possible to explicitly enable the option. 13.65 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 13.66 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 13.67 + 13.68 + // Verify that the tested option is disabled even if +UseSHA was passed 13.69 + // to JVM. 13.70 + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", 13.71 + CommandLineOptionTest.prepareBooleanFlag( 13.72 + SHAOptionsBase.USE_SHA_OPTION, true)); 13.73 + } 13.74 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java Wed Sep 03 15:29:57 2014 +0400 14.3 @@ -0,0 +1,59 @@ 14.4 +/* 14.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.7 + * 14.8 + * This code is free software; you can redistribute it and/or modify it 14.9 + * under the terms of the GNU General Public License version 2 only, as 14.10 + * published by the Free Software Foundation. 14.11 + * 14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14.15 + * version 2 for more details (a copy is included in the LICENSE file that 14.16 + * accompanied this code). 14.17 + * 14.18 + * You should have received a copy of the GNU General Public License version 14.19 + * 2 along with this work; if not, write to the Free Software Foundation, 14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 14.21 + * 14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 14.23 + * or visit www.oracle.com if you need additional information or have any 14.24 + * questions. 14.25 + */ 14.26 + 14.27 +import com.oracle.java.testlibrary.ExitCode; 14.28 +import com.oracle.java.testlibrary.Platform; 14.29 +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; 14.30 +import com.oracle.java.testlibrary.cli.predicate.AndPredicate; 14.31 +import com.oracle.java.testlibrary.cli.predicate.NotPredicate; 14.32 +import sha.predicate.IntrinsicPredicates; 14.33 + 14.34 +/** 14.35 + * Test case specific to UseSHA*Intrinsics options targeted to SPARC CPUs which 14.36 + * don't support required instruction, but support other SHA-related 14.37 + * instructions. 14.38 + * 14.39 + * For example, CPU support sha1 instruction, but don't support sha256 or 14.40 + * sha512. 14.41 + */ 14.42 +public class UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU 14.43 + extends SHAOptionsBase.TestCase { 14.44 + public UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU( 14.45 + String optionName) { 14.46 + // execute test case on SPARC CPU that support any sha* instructions, 14.47 + // but does not support sha* instruction required by the tested option. 14.48 + super(optionName, new AndPredicate(Platform::isSparc, 14.49 + new AndPredicate( 14.50 + IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE, 14.51 + new NotPredicate(SHAOptionsBase.getPredicateForOption( 14.52 + optionName))))); 14.53 + } 14.54 + @Override 14.55 + protected void verifyWarnings() throws Throwable { 14.56 + // Verify that attempt to enable the tested option will cause a warning. 14.57 + CommandLineOptionTest.verifySameJVMStartup(new String[] { 14.58 + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) 14.59 + }, null, ExitCode.OK, 14.60 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 14.61 + } 14.62 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java Wed Sep 03 15:29:57 2014 +0400 15.3 @@ -0,0 +1,101 @@ 15.4 +/* 15.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 + * 15.8 + * This code is free software; you can redistribute it and/or modify it 15.9 + * under the terms of the GNU General Public License version 2 only, as 15.10 + * published by the Free Software Foundation. 15.11 + * 15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.15 + * version 2 for more details (a copy is included in the LICENSE file that 15.16 + * accompanied this code). 15.17 + * 15.18 + * You should have received a copy of the GNU General Public License version 15.19 + * 2 along with this work; if not, write to the Free Software Foundation, 15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.21 + * 15.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 15.23 + * or visit www.oracle.com if you need additional information or have any 15.24 + * questions. 15.25 + */ 15.26 + 15.27 +import com.oracle.java.testlibrary.Asserts; 15.28 +import com.oracle.java.testlibrary.ExitCode; 15.29 +import com.oracle.java.testlibrary.Platform; 15.30 +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; 15.31 +import com.oracle.java.testlibrary.cli.predicate.AndPredicate; 15.32 +import sha.predicate.IntrinsicPredicates; 15.33 + 15.34 +/** 15.35 + * UseSHA specific test case targeted to SPARC CPUs which support any sha* 15.36 + * instruction. 15.37 + */ 15.38 +public class UseSHASpecificTestCaseForSupportedSparcCPU 15.39 + extends SHAOptionsBase.TestCase { 15.40 + public UseSHASpecificTestCaseForSupportedSparcCPU(String optionName) { 15.41 + super(SHAOptionsBase.USE_SHA_OPTION, new AndPredicate(Platform::isSparc, 15.42 + IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE)); 15.43 + 15.44 + Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION, 15.45 + "Test case should be used for " + SHAOptionsBase.USE_SHA_OPTION 15.46 + + " option only."); 15.47 + } 15.48 + 15.49 + @Override 15.50 + protected void verifyWarnings() throws Throwable { 15.51 + // Verify that there will be no warnings when +UseSHA was passed and 15.52 + // all UseSHA*Intrinsics options were disabled. 15.53 + CommandLineOptionTest.verifySameJVMStartup( 15.54 + null, new String[] { ".*UseSHA.*" }, ExitCode.OK, 15.55 + CommandLineOptionTest.prepareBooleanFlag( 15.56 + SHAOptionsBase.USE_SHA_OPTION, true), 15.57 + CommandLineOptionTest.prepareBooleanFlag( 15.58 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), 15.59 + CommandLineOptionTest.prepareBooleanFlag( 15.60 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), 15.61 + CommandLineOptionTest.prepareBooleanFlag( 15.62 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); 15.63 + } 15.64 + 15.65 + @Override 15.66 + protected void verifyOptionValues() throws Throwable { 15.67 + // Verify that UseSHA is disabled when all UseSHA*Intrinscs are 15.68 + // disabled. 15.69 + CommandLineOptionTest.verifyOptionValueForSameVM( 15.70 + SHAOptionsBase.USE_SHA_OPTION, "false", 15.71 + CommandLineOptionTest.prepareBooleanFlag( 15.72 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), 15.73 + CommandLineOptionTest.prepareBooleanFlag( 15.74 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), 15.75 + CommandLineOptionTest.prepareBooleanFlag( 15.76 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); 15.77 + 15.78 + CommandLineOptionTest.verifyOptionValueForSameVM( 15.79 + // Verify that UseSHA is disabled when all UseSHA*Intrinscs are 15.80 + // disabled even if it was explicitly enabled. 15.81 + SHAOptionsBase.USE_SHA_OPTION, "false", 15.82 + CommandLineOptionTest.prepareBooleanFlag( 15.83 + SHAOptionsBase.USE_SHA_OPTION, true), 15.84 + CommandLineOptionTest.prepareBooleanFlag( 15.85 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), 15.86 + CommandLineOptionTest.prepareBooleanFlag( 15.87 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), 15.88 + CommandLineOptionTest.prepareBooleanFlag( 15.89 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); 15.90 + 15.91 + // Verify that explicitly disabled UseSHA option remains disabled even 15.92 + // if all UseSHA*Intrinsics options were enabled. 15.93 + CommandLineOptionTest.verifyOptionValueForSameVM( 15.94 + SHAOptionsBase.USE_SHA_OPTION, "false", 15.95 + CommandLineOptionTest.prepareBooleanFlag( 15.96 + SHAOptionsBase.USE_SHA_OPTION, false), 15.97 + CommandLineOptionTest.prepareBooleanFlag( 15.98 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), 15.99 + CommandLineOptionTest.prepareBooleanFlag( 15.100 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), 15.101 + CommandLineOptionTest.prepareBooleanFlag( 15.102 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); 15.103 + } 15.104 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java Wed Sep 03 15:29:57 2014 +0400 16.3 @@ -0,0 +1,83 @@ 16.4 +/* 16.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.7 + * 16.8 + * This code is free software; you can redistribute it and/or modify it 16.9 + * under the terms of the GNU General Public License version 2 only, as 16.10 + * published by the Free Software Foundation. 16.11 + * 16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16.15 + * version 2 for more details (a copy is included in the LICENSE file that 16.16 + * accompanied this code). 16.17 + * 16.18 + * You should have received a copy of the GNU General Public License version 16.19 + * 2 along with this work; if not, write to the Free Software Foundation, 16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 16.21 + * 16.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 16.23 + * or visit www.oracle.com if you need additional information or have any 16.24 + * questions. 16.25 + */ 16.26 + 16.27 +import com.oracle.java.testlibrary.Asserts; 16.28 +import com.oracle.java.testlibrary.ExitCode; 16.29 +import com.oracle.java.testlibrary.Platform; 16.30 +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; 16.31 +import com.oracle.java.testlibrary.cli.predicate.AndPredicate; 16.32 +import com.oracle.java.testlibrary.cli.predicate.NotPredicate; 16.33 +import sha.predicate.IntrinsicPredicates; 16.34 + 16.35 +/** 16.36 + * UseSHA specific test case targeted to SPARC CPUs which don't support all sha* 16.37 + * instructions. 16.38 + */ 16.39 +public class UseSHASpecificTestCaseForUnsupportedSparcCPU 16.40 + extends SHAOptionsBase.TestCase { 16.41 + public UseSHASpecificTestCaseForUnsupportedSparcCPU(String optionName) { 16.42 + super(SHAOptionsBase.USE_SHA_OPTION, new AndPredicate(Platform::isSparc, 16.43 + new NotPredicate( 16.44 + IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE))); 16.45 + 16.46 + Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION, 16.47 + "Test case should be used for " + SHAOptionsBase.USE_SHA_OPTION 16.48 + + " option only."); 16.49 + } 16.50 + 16.51 + @Override 16.52 + protected void verifyWarnings() throws Throwable { 16.53 + // Verify that attempt to use UseSHA option will cause a warning. 16.54 + CommandLineOptionTest.verifySameJVMStartup(new String[] { 16.55 + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) 16.56 + }, null, ExitCode.OK, 16.57 + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); 16.58 + } 16.59 + 16.60 + @Override 16.61 + protected void verifyOptionValues() throws Throwable { 16.62 + // Verify that UseSHA option remains disabled even if all 16.63 + // UseSHA*Intrincs options were enabled. 16.64 + CommandLineOptionTest.verifyOptionValueForSameVM( 16.65 + SHAOptionsBase.USE_SHA_OPTION, "false", 16.66 + CommandLineOptionTest.prepareBooleanFlag( 16.67 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), 16.68 + CommandLineOptionTest.prepareBooleanFlag( 16.69 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), 16.70 + CommandLineOptionTest.prepareBooleanFlag( 16.71 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); 16.72 + 16.73 + // Verify that UseSHA option remains disabled even if all 16.74 + // UseSHA*Intrincs options were enabled and UseSHA was enabled as well. 16.75 + CommandLineOptionTest.verifyOptionValueForSameVM( 16.76 + SHAOptionsBase.USE_SHA_OPTION, "false", 16.77 + CommandLineOptionTest.prepareBooleanFlag( 16.78 + SHAOptionsBase.USE_SHA_OPTION, true), 16.79 + CommandLineOptionTest.prepareBooleanFlag( 16.80 + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), 16.81 + CommandLineOptionTest.prepareBooleanFlag( 16.82 + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), 16.83 + CommandLineOptionTest.prepareBooleanFlag( 16.84 + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); 16.85 + } 16.86 +}