# HG changeset patch # User enevill # Date 1433319789 0 # Wed Jun 03 08:23:09 2015 +0000 # Node ID cf66832b5ad8660c99052e6b6a1f11bb9a6144ed # Parent 84c51a26d2017e56218c4acb8d84c1a2894bce42 8081790: aarch64: SHA tests fail Summary: Fix SHA tests in JTReg so they recognize aarch64 Reviewed-by: duke Contributed-by: alexander.alexeev@caviumnetworks.com diff --git a/src/cpu/aarch64/vm/vm_version_aarch64.cpp b/src/cpu/aarch64/vm/vm_version_aarch64.cpp --- a/src/cpu/aarch64/vm/vm_version_aarch64.cpp +++ b/src/cpu/aarch64/vm/vm_version_aarch64.cpp @@ -228,6 +228,9 @@ warning("SHA512 instruction (for SHA-384 and SHA-512) is not available on this CPU."); FLAG_SET_DEFAULT(UseSHA512Intrinsics, false); } + if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) { + FLAG_SET_DEFAULT(UseSHA, false); + } } // This machine allows unaligned memory accesses diff --git a/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java b/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java --- a/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java +++ b/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java @@ -71,7 +71,7 @@ * instructions required by the option are not supported. */ protected static String getWarningForUnsupportedCPU(String optionName) { - if (Platform.isSparc()) { + if (Platform.isSparc() || Platform.isAArch64()) { switch (optionName) { case SHAOptionsBase.USE_SHA_OPTION: return SHAOptionsBase.SHA_INSTRUCTIONS_ARE_NOT_AVAILABLE; diff --git a/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnSupportedCPU.java b/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnSupportedCPU.java --- a/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnSupportedCPU.java +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnSupportedCPU.java @@ -36,7 +36,7 @@ */ public class TestUseSHA1IntrinsicsOptionOnSupportedCPU { public static void main(String args[]) throws Throwable { - new SHAOptionsBase(new GenericTestCaseForSupportedSparcCPU( + new SHAOptionsBase(new GenericTestCaseForSupportedCPU( SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION)).test(); } } diff --git a/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnUnsupportedCPU.java b/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnUnsupportedCPU.java --- a/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnUnsupportedCPU.java +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnUnsupportedCPU.java @@ -40,9 +40,11 @@ new SHAOptionsBase( new GenericTestCaseForUnsupportedSparcCPU( SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION), - new UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU( + new GenericTestCaseForUnsupportedX86CPU( SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION), - new GenericTestCaseForUnsupportedX86CPU( + new GenericTestCaseForUnsupportedAArch64CPU( + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION), + new UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU( SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION), new GenericTestCaseForOtherCPU( SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION)).test(); diff --git a/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnSupportedCPU.java b/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnSupportedCPU.java --- a/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnSupportedCPU.java +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnSupportedCPU.java @@ -37,7 +37,7 @@ */ public class TestUseSHA256IntrinsicsOptionOnSupportedCPU { public static void main(String args[]) throws Throwable { - new SHAOptionsBase(new GenericTestCaseForSupportedSparcCPU( + new SHAOptionsBase(new GenericTestCaseForSupportedCPU( SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION)).test(); } } diff --git a/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnUnsupportedCPU.java b/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnUnsupportedCPU.java --- a/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnUnsupportedCPU.java +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnUnsupportedCPU.java @@ -40,9 +40,11 @@ new SHAOptionsBase( new GenericTestCaseForUnsupportedSparcCPU( SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION), - new UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU( + new GenericTestCaseForUnsupportedX86CPU( SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION), - new GenericTestCaseForUnsupportedX86CPU( + new GenericTestCaseForUnsupportedAArch64CPU( + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION), + new UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU( SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION), new GenericTestCaseForOtherCPU( SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION)).test(); diff --git a/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java b/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java --- a/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java @@ -37,7 +37,7 @@ */ public class TestUseSHA512IntrinsicsOptionOnSupportedCPU { public static void main(String args[]) throws Throwable { - new SHAOptionsBase(new GenericTestCaseForSupportedSparcCPU( + new SHAOptionsBase(new GenericTestCaseForSupportedCPU( SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION)).test(); } } diff --git a/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnUnsupportedCPU.java b/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnUnsupportedCPU.java --- a/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnUnsupportedCPU.java +++ b/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnUnsupportedCPU.java @@ -40,9 +40,11 @@ new SHAOptionsBase( new GenericTestCaseForUnsupportedSparcCPU( SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION), - new UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU( + new GenericTestCaseForUnsupportedX86CPU( SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION), - new GenericTestCaseForUnsupportedX86CPU( + new GenericTestCaseForUnsupportedAArch64CPU( + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION), + new UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU( SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION), new GenericTestCaseForOtherCPU( SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION)).test(); diff --git a/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnSupportedCPU.java b/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnSupportedCPU.java --- a/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnSupportedCPU.java +++ b/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnSupportedCPU.java @@ -37,9 +37,9 @@ public class TestUseSHAOptionOnSupportedCPU { public static void main(String args[]) throws Throwable { new SHAOptionsBase( - new GenericTestCaseForSupportedSparcCPU( + new GenericTestCaseForSupportedCPU( SHAOptionsBase.USE_SHA_OPTION), - new UseSHASpecificTestCaseForSupportedSparcCPU( + new UseSHASpecificTestCaseForSupportedCPU( SHAOptionsBase.USE_SHA_OPTION)).test(); } } diff --git a/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnUnsupportedCPU.java b/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnUnsupportedCPU.java --- a/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnUnsupportedCPU.java +++ b/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnUnsupportedCPU.java @@ -39,9 +39,11 @@ new SHAOptionsBase( new GenericTestCaseForUnsupportedSparcCPU( SHAOptionsBase.USE_SHA_OPTION), - new UseSHASpecificTestCaseForUnsupportedSparcCPU( + new GenericTestCaseForUnsupportedX86CPU( SHAOptionsBase.USE_SHA_OPTION), - new GenericTestCaseForUnsupportedX86CPU( + new GenericTestCaseForUnsupportedAArch64CPU( + SHAOptionsBase.USE_SHA_OPTION), + new UseSHASpecificTestCaseForUnsupportedCPU( SHAOptionsBase.USE_SHA_OPTION), new GenericTestCaseForOtherCPU( SHAOptionsBase.USE_SHA_OPTION)).test(); diff --git a/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java --- a/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java +++ b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java @@ -35,16 +35,18 @@ SHAOptionsBase.TestCase { public GenericTestCaseForOtherCPU(String optionName) { // Execute the test case on any CPU except SPARC and X86 - super(optionName, new NotPredicate(new OrPredicate(Platform::isSparc, - new OrPredicate(Platform::isX64, Platform::isX86)))); + super(optionName, new NotPredicate( + new OrPredicate( + new OrPredicate(Platform::isSparc, Platform::isAArch64), + new OrPredicate(Platform::isX64, Platform::isX86)))); } @Override protected void verifyWarnings() throws Throwable { String shouldPassMessage = String.format("JVM should start with " + "option '%s' without any warnings", optionName); - // Verify that on non-x86 and non-SPARC CPU usage of SHA-related - // options will not cause any warnings. + // Verify that on non-x86, non-SPARC and non-AArch64 CPU usage of + // SHA-related options will not cause any warnings. CommandLineOptionTest.verifySameJVMStartup(null, new String[] { ".*" + optionName + ".*" }, shouldPassMessage, shouldPassMessage, ExitCode.OK, diff --git a/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java new file mode 100644 --- /dev/null +++ b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.ExitCode; +import jdk.test.lib.Platform; +import jdk.test.lib.cli.CommandLineOptionTest; +import jdk.test.lib.cli.predicate.AndPredicate; +import jdk.test.lib.cli.predicate.OrPredicate; + +/** + * Generic test case for SHA-related options targeted to CPUs which + * support instructions required by the tested option. + */ +public class GenericTestCaseForSupportedCPU extends + SHAOptionsBase.TestCase { + public GenericTestCaseForSupportedCPU(String optionName) { + super(optionName, + new AndPredicate( + new OrPredicate(Platform::isSparc, Platform::isAArch64), + SHAOptionsBase.getPredicateForOption(optionName))); + } + + @Override + protected void verifyWarnings() throws Throwable { + + String shouldPassMessage = String.format("JVM should start with option" + + " '%s' without any warnings", optionName); + // Verify that there are no warning when option is explicitly enabled. + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) + }, shouldPassMessage, shouldPassMessage, ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); + + // Verify that option could be disabled even if +UseSHA was passed to + // JVM. + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) + }, shouldPassMessage, String.format("It should be able to " + + "disable option '%s' even if %s was passed to JVM", + optionName, CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true)), + ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); + + // Verify that it is possible to enable the tested option and disable + // all SHA intrinsics via -UseSHA without any warnings. + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) + }, shouldPassMessage, String.format("It should be able to " + + "enable option '%s' even if %s was passed to JVM", + optionName, CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, false)), + ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, false), + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); + } + + @Override + protected void verifyOptionValues() throws Throwable { + // Verify that "It should be able to disable option " + + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", + String.format("Option '%s' should be enabled by default", + optionName)); + + // Verify that it is possible to explicitly enable the option. + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", + String.format("Option '%s' was set to have value 'true'", + optionName), + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); + + // Verify that it is possible to explicitly disable the option. + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' was set to have value 'false'", + optionName), + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); + + // verify that option is disabled when -UseSHA was passed to JVM. + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' should have value 'false' when %s" + + " flag set to JVM", optionName, + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, false)), + CommandLineOptionTest.prepareBooleanFlag(optionName, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, false)); + + // Verify that it is possible to explicitly disable the tested option + // even if +UseSHA was passed to JVM. + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' should have value 'false' if set so" + + " even if %s flag set to JVM", optionName, + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true)), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); + } +} diff --git a/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java deleted file mode 100644 --- a/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import jdk.test.lib.ExitCode; -import jdk.test.lib.Platform; -import jdk.test.lib.cli.CommandLineOptionTest; -import jdk.test.lib.cli.predicate.AndPredicate; - -/** - * Generic test case for SHA-related options targeted to SPARC CPUs which - * support instructions required by the tested option. - */ -public class GenericTestCaseForSupportedSparcCPU extends - SHAOptionsBase.TestCase { - public GenericTestCaseForSupportedSparcCPU(String optionName) { - super(optionName, new AndPredicate(Platform::isSparc, - SHAOptionsBase.getPredicateForOption(optionName))); - } - - @Override - protected void verifyWarnings() throws Throwable { - - String shouldPassMessage = String.format("JVM should start with option" - + " '%s' without any warnings", optionName); - // Verify that there are no warning when option is explicitly enabled. - CommandLineOptionTest.verifySameJVMStartup(null, new String[] { - SHAOptionsBase.getWarningForUnsupportedCPU(optionName) - }, shouldPassMessage, shouldPassMessage, ExitCode.OK, - CommandLineOptionTest.prepareBooleanFlag(optionName, true)); - - // Verify that option could be disabled even if +UseSHA was passed to - // JVM. - CommandLineOptionTest.verifySameJVMStartup(null, new String[] { - SHAOptionsBase.getWarningForUnsupportedCPU(optionName) - }, shouldPassMessage, String.format("It should be able to " - + "disable option '%s' even if %s was passed to JVM", - optionName, CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, true)), - ExitCode.OK, - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag(optionName, false)); - - // Verify that it is possible to enable the tested option and disable - // all SHA intrinsics via -UseSHA without any warnings. - CommandLineOptionTest.verifySameJVMStartup(null, new String[] { - SHAOptionsBase.getWarningForUnsupportedCPU(optionName) - }, shouldPassMessage, String.format("It should be able to " - + "enable option '%s' even if %s was passed to JVM", - optionName, CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, false)), - ExitCode.OK, - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, false), - CommandLineOptionTest.prepareBooleanFlag(optionName, true)); - } - - @Override - protected void verifyOptionValues() throws Throwable { - // Verify that "It should be able to disable option " - - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", - String.format("Option '%s' should be enabled by default", - optionName)); - - // Verify that it is possible to explicitly enable the option. - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", - String.format("Option '%s' was set to have value 'true'", - optionName), - CommandLineOptionTest.prepareBooleanFlag(optionName, true)); - - // Verify that it is possible to explicitly disable the option. - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", - String.format("Option '%s' was set to have value 'false'", - optionName), - CommandLineOptionTest.prepareBooleanFlag(optionName, false)); - - // verify that option is disabled when -UseSHA was passed to JVM. - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", - String.format("Option '%s' should have value 'false' when %s" - + " flag set to JVM", optionName, - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, false)), - CommandLineOptionTest.prepareBooleanFlag(optionName, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, false)); - - // Verify that it is possible to explicitly disable the tested option - // even if +UseSHA was passed to JVM. - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", - String.format("Option '%s' should have value 'false' if set so" - + " even if %s flag set to JVM", optionName, - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, true)), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag(optionName, false)); - } -} diff --git a/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java new file mode 100644 --- /dev/null +++ b/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.ExitCode; +import jdk.test.lib.Platform; +import jdk.test.lib.cli.CommandLineOptionTest; +import jdk.test.lib.cli.predicate.AndPredicate; +import jdk.test.lib.cli.predicate.NotPredicate; + +/** + * Generic test case for SHA-related options targeted to AArch64 CPUs + * which don't support instruction required by the tested option. + */ +public class GenericTestCaseForUnsupportedAArch64CPU extends + SHAOptionsBase.TestCase { + public GenericTestCaseForUnsupportedAArch64CPU(String optionName) { + super(optionName, new AndPredicate(Platform::isAArch64, + new NotPredicate(SHAOptionsBase.getPredicateForOption( + optionName)))); + } + + @Override + protected void verifyWarnings() throws Throwable { + String shouldPassMessage = String.format("JVM startup should pass with" + + "option '-XX:-%s' without any warnings", optionName); + //Verify that option could be disabled without any warnings. + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) + }, shouldPassMessage, shouldPassMessage, ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag(optionName, false)); + + shouldPassMessage = String.format("JVM should start with '-XX:+" + + "%s' flag, but output should contain warning.", optionName); + // Verify that when the tested option is explicitly enabled, then + // a warning will occur in VM output. + CommandLineOptionTest.verifySameJVMStartup(new String[] { + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) + }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); + } + + @Override + protected void verifyOptionValues() throws Throwable { + // Verify that option is disabled by default. + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' should be disabled by default", + optionName)); + + // Verify that option is disabled even if it was explicitly enabled + // using CLI options. + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' should be off on unsupported " + + "AArch64CPU even if set to true directly", optionName), + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); + + // Verify that option is disabled when +UseSHA was passed to JVM. + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' should be off on unsupported " + + "AArch64CPU even if %s flag set to JVM", + optionName, CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true)), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true)); + } +} diff --git a/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java b/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java new file mode 100644 --- /dev/null +++ b/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.ExitCode; +import jdk.test.lib.Platform; +import jdk.test.lib.cli.CommandLineOptionTest; +import jdk.test.lib.cli.predicate.AndPredicate; +import jdk.test.lib.cli.predicate.OrPredicate; +import jdk.test.lib.cli.predicate.NotPredicate; +import sha.predicate.IntrinsicPredicates; + +/** + * Test case specific to UseSHA*Intrinsics options targeted to SPARC and AArch64 + * CPUs which don't support required instruction, but support other SHA-related + * instructions. + * + * For example, CPU support sha1 instruction, but don't support sha256 or + * sha512. + */ +public class UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU + extends SHAOptionsBase.TestCase { + public UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU( + String optionName) { + // execute test case on SPARC CPU that support any sha* instructions, + // but does not support sha* instruction required by the tested option. + super(optionName, new AndPredicate( + new OrPredicate(Platform::isSparc, Platform::isAArch64), + new AndPredicate( + IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE, + new NotPredicate(SHAOptionsBase.getPredicateForOption( + optionName))))); + } + @Override + protected void verifyWarnings() throws Throwable { + String shouldPassMessage = String.format("JVM should start with " + + "'-XX:+%s' flag, but output should contain warning.", + optionName); + // Verify that attempt to enable the tested option will cause a warning + CommandLineOptionTest.verifySameJVMStartup(new String[] { + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) + }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); + } +} diff --git a/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java b/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java deleted file mode 100644 --- a/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import jdk.test.lib.ExitCode; -import jdk.test.lib.Platform; -import jdk.test.lib.cli.CommandLineOptionTest; -import jdk.test.lib.cli.predicate.AndPredicate; -import jdk.test.lib.cli.predicate.NotPredicate; -import sha.predicate.IntrinsicPredicates; - -/** - * Test case specific to UseSHA*Intrinsics options targeted to SPARC CPUs which - * don't support required instruction, but support other SHA-related - * instructions. - * - * For example, CPU support sha1 instruction, but don't support sha256 or - * sha512. - */ -public class UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU - extends SHAOptionsBase.TestCase { - public UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU( - String optionName) { - // execute test case on SPARC CPU that support any sha* instructions, - // but does not support sha* instruction required by the tested option. - super(optionName, new AndPredicate(Platform::isSparc, - new AndPredicate( - IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE, - new NotPredicate(SHAOptionsBase.getPredicateForOption( - optionName))))); - } - @Override - protected void verifyWarnings() throws Throwable { - String shouldPassMessage = String.format("JVM should start with " - + "'-XX:+%s' flag, but output should contain warning.", - optionName); - // Verify that attempt to enable the tested option will cause a warning - CommandLineOptionTest.verifySameJVMStartup(new String[] { - SHAOptionsBase.getWarningForUnsupportedCPU(optionName) - }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, - CommandLineOptionTest.prepareBooleanFlag(optionName, true)); - } -} diff --git a/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java b/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java new file mode 100644 --- /dev/null +++ b/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.Asserts; +import jdk.test.lib.ExitCode; +import jdk.test.lib.Platform; +import jdk.test.lib.cli.CommandLineOptionTest; +import jdk.test.lib.cli.predicate.AndPredicate; +import jdk.test.lib.cli.predicate.OrPredicate; +import sha.predicate.IntrinsicPredicates; + +/** + * UseSHA specific test case targeted to SPARC and AArch64 CPUs which + * support any sha* instruction. + */ +public class UseSHASpecificTestCaseForSupportedCPU + extends SHAOptionsBase.TestCase { + public UseSHASpecificTestCaseForSupportedCPU(String optionName) { + super(SHAOptionsBase.USE_SHA_OPTION, new AndPredicate( + new OrPredicate(Platform::isSparc, Platform::isAArch64), + IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE)); + + Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION, + String.format("Test case should be used for '%s' option only.", + SHAOptionsBase.USE_SHA_OPTION)); + } + + @Override + protected void verifyWarnings() throws Throwable { + String shouldPassMessage = String.format("JVM startup should pass when" + + " %s was passed and all UseSHA*Intrinsics options " + + "were disabled", + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true)); + // Verify that there will be no warnings when +UseSHA was passed and + // all UseSHA*Intrinsics options were disabled. + CommandLineOptionTest.verifySameJVMStartup( + null, new String[] { ".*UseSHA.*" }, shouldPassMessage, + shouldPassMessage, ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); + } + + @Override + protected void verifyOptionValues() throws Throwable { + // Verify that UseSHA is disabled when all UseSHA*Intrinsics are + // disabled. + CommandLineOptionTest.verifyOptionValueForSameVM( + SHAOptionsBase.USE_SHA_OPTION, "false", String.format( + "'%s' option should be disabled when all UseSHA*Intrinsics are" + + " disabled", SHAOptionsBase.USE_SHA_OPTION), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); + + CommandLineOptionTest.verifyOptionValueForSameVM( + // Verify that UseSHA is disabled when all UseSHA*Intrinsics are + // disabled even if it was explicitly enabled. + SHAOptionsBase.USE_SHA_OPTION, "false", + String.format("'%s' option should be disabled when all " + + "UseSHA*Intrinsics are disabled even if %s flag set " + + "to JVM", SHAOptionsBase.USE_SHA_OPTION, + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true)), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); + + // Verify that explicitly disabled UseSHA option remains disabled even + // if all UseSHA*Intrinsics options were enabled. + CommandLineOptionTest.verifyOptionValueForSameVM( + SHAOptionsBase.USE_SHA_OPTION, "false", + String.format("'%s' option should be disabled if %s flag " + + "set even if all UseSHA*Intrinsics were enabled", + SHAOptionsBase.USE_SHA_OPTION, + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, false)), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, false), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); + } +} diff --git a/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java b/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java deleted file mode 100644 --- a/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import jdk.test.lib.Asserts; -import jdk.test.lib.ExitCode; -import jdk.test.lib.Platform; -import jdk.test.lib.cli.CommandLineOptionTest; -import jdk.test.lib.cli.predicate.AndPredicate; -import sha.predicate.IntrinsicPredicates; - -/** - * UseSHA specific test case targeted to SPARC CPUs which support any sha* - * instruction. - */ -public class UseSHASpecificTestCaseForSupportedSparcCPU - extends SHAOptionsBase.TestCase { - public UseSHASpecificTestCaseForSupportedSparcCPU(String optionName) { - super(SHAOptionsBase.USE_SHA_OPTION, new AndPredicate(Platform::isSparc, - IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE)); - - Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION, - String.format("Test case should be used for '%s' option only.", - SHAOptionsBase.USE_SHA_OPTION)); - } - - @Override - protected void verifyWarnings() throws Throwable { - String shouldPassMessage = String.format("JVM startup should pass when" - + " %s was passed and all UseSHA*Intrinsics options " - + "were disabled", - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, true)); - // Verify that there will be no warnings when +UseSHA was passed and - // all UseSHA*Intrinsics options were disabled. - CommandLineOptionTest.verifySameJVMStartup( - null, new String[] { ".*UseSHA.*" }, shouldPassMessage, - shouldPassMessage, ExitCode.OK, - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); - } - - @Override - protected void verifyOptionValues() throws Throwable { - // Verify that UseSHA is disabled when all UseSHA*Intrinsics are - // disabled. - CommandLineOptionTest.verifyOptionValueForSameVM( - SHAOptionsBase.USE_SHA_OPTION, "false", String.format( - "'%s' option should be disabled when all UseSHA*Intrinsics are" - + " disabled", SHAOptionsBase.USE_SHA_OPTION), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); - - CommandLineOptionTest.verifyOptionValueForSameVM( - // Verify that UseSHA is disabled when all UseSHA*Intrinsics are - // disabled even if it was explicitly enabled. - SHAOptionsBase.USE_SHA_OPTION, "false", - String.format("'%s' option should be disabled when all " - + "UseSHA*Intrinsics are disabled even if %s flag set " - + "to JVM", SHAOptionsBase.USE_SHA_OPTION, - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, true)), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); - - // Verify that explicitly disabled UseSHA option remains disabled even - // if all UseSHA*Intrinsics options were enabled. - CommandLineOptionTest.verifyOptionValueForSameVM( - SHAOptionsBase.USE_SHA_OPTION, "false", - String.format("'%s' option should be disabled if %s flag " - + "set even if all UseSHA*Intrinsics were enabled", - SHAOptionsBase.USE_SHA_OPTION, - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, false)), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, false), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); - } -} diff --git a/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java b/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java new file mode 100644 --- /dev/null +++ b/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.Asserts; +import jdk.test.lib.ExitCode; +import jdk.test.lib.Platform; +import jdk.test.lib.cli.CommandLineOptionTest; +import jdk.test.lib.cli.predicate.AndPredicate; +import jdk.test.lib.cli.predicate.OrPredicate; +import jdk.test.lib.cli.predicate.NotPredicate; +import sha.predicate.IntrinsicPredicates; + +/** + * UseSHA specific test case targeted to SPARC and AArch64 CPUs which don't + * support all sha* instructions./ + */ +public class UseSHASpecificTestCaseForUnsupportedCPU + extends SHAOptionsBase.TestCase { + public UseSHASpecificTestCaseForUnsupportedCPU(String optionName) { + super(SHAOptionsBase.USE_SHA_OPTION, new AndPredicate( + new OrPredicate(Platform::isSparc, Platform::isAArch64), + new NotPredicate( + IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE))); + + Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION, + "Test case should be used for " + SHAOptionsBase.USE_SHA_OPTION + + " option only."); + } + + @Override + protected void verifyWarnings() throws Throwable { + // Verify that attempt to use UseSHA option will cause a warning. + String shouldPassMessage = String.format("JVM startup should pass with" + + " '%s' option on unsupported CPU, but there should be" + + "the message shown.", optionName); + CommandLineOptionTest.verifySameJVMStartup(new String[] { + SHAOptionsBase.getWarningForUnsupportedCPU(optionName) + }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); + } + + @Override + protected void verifyOptionValues() throws Throwable { + // Verify that UseSHA option remains disabled even if all + // UseSHA*Intrinsics were enabled. + CommandLineOptionTest.verifyOptionValueForSameVM( + SHAOptionsBase.USE_SHA_OPTION, "false", String.format( + "%s option should be disabled on unsupported CPU" + + " even if all UseSHA*Intrinsics options were enabled.", + SHAOptionsBase.USE_SHA_OPTION), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); + + // Verify that UseSHA option remains disabled even if all + // UseSHA*Intrinsics options were enabled and UseSHA was enabled as well. + CommandLineOptionTest.verifyOptionValueForSameVM( + SHAOptionsBase.USE_SHA_OPTION, "false", String.format( + "%s option should be disabled on unsupported CPU" + + " even if all UseSHA*Intrinsics options were enabled" + + " and %s was enabled as well", + SHAOptionsBase.USE_SHA_OPTION, + SHAOptionsBase.USE_SHA_OPTION), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); + } +} diff --git a/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java b/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java deleted file mode 100644 --- a/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import jdk.test.lib.Asserts; -import jdk.test.lib.ExitCode; -import jdk.test.lib.Platform; -import jdk.test.lib.cli.CommandLineOptionTest; -import jdk.test.lib.cli.predicate.AndPredicate; -import jdk.test.lib.cli.predicate.NotPredicate; -import sha.predicate.IntrinsicPredicates; - -/** - * UseSHA specific test case targeted to SPARC CPUs which don't support all sha* - * instructions. - */ -public class UseSHASpecificTestCaseForUnsupportedSparcCPU - extends SHAOptionsBase.TestCase { - public UseSHASpecificTestCaseForUnsupportedSparcCPU(String optionName) { - super(SHAOptionsBase.USE_SHA_OPTION, new AndPredicate(Platform::isSparc, - new NotPredicate( - IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE))); - - Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION, - "Test case should be used for " + SHAOptionsBase.USE_SHA_OPTION - + " option only."); - } - - @Override - protected void verifyWarnings() throws Throwable { - // Verify that attempt to use UseSHA option will cause a warning. - String shouldPassMessage = String.format("JVM startup should pass with" - + " '%s' option on unsupported SparcCPU, but there should be" - + "the message shown.", optionName); - CommandLineOptionTest.verifySameJVMStartup(new String[] { - SHAOptionsBase.getWarningForUnsupportedCPU(optionName) - }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, - CommandLineOptionTest.prepareBooleanFlag(optionName, true)); - } - - @Override - protected void verifyOptionValues() throws Throwable { - // Verify that UseSHA option remains disabled even if all - // UseSHA*Intrinsics were enabled. - CommandLineOptionTest.verifyOptionValueForSameVM( - SHAOptionsBase.USE_SHA_OPTION, "false", String.format( - "%s option should be disabled on unsupported SparcCPU" - + " even if all UseSHA*Intrinsics options were enabled.", - SHAOptionsBase.USE_SHA_OPTION), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); - - // Verify that UseSHA option remains disabled even if all - // UseSHA*Intrinsics options were enabled and UseSHA was enabled as well. - CommandLineOptionTest.verifyOptionValueForSameVM( - SHAOptionsBase.USE_SHA_OPTION, "false", String.format( - "%s option should be disabled on unsupported SparcCPU" - + " even if all UseSHA*Intrinsics options were enabled" - + " and %s was enabled as well", - SHAOptionsBase.USE_SHA_OPTION, - SHAOptionsBase.USE_SHA_OPTION), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), - CommandLineOptionTest.prepareBooleanFlag( - SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); - } -} diff --git a/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java b/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java --- a/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java +++ b/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java @@ -59,16 +59,19 @@ }; public static final BooleanSupplier SHA1_INSTRUCTION_AVAILABLE - = new CPUSpecificPredicate("sparc.*", new String[] { "sha1" }, - null); + = new OrPredicate( + new CPUSpecificPredicate("sparc.*", new String[] { "sha1" },null), + new CPUSpecificPredicate("aarch64.*", new String[] { "sha1" },null)); public static final BooleanSupplier SHA256_INSTRUCTION_AVAILABLE - = new CPUSpecificPredicate("sparc.*", new String[] { "sha256" }, - null); + = new OrPredicate( + new CPUSpecificPredicate("sparc.*", new String[] { "sha256" },null), + new CPUSpecificPredicate("aarch64.*", new String[] { "sha256" },null)); public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE - = new CPUSpecificPredicate("sparc.*", new String[] { "sha512" }, - null); + = new OrPredicate( + new CPUSpecificPredicate("sparc.*", new String[] { "sha512" },null), + new CPUSpecificPredicate("aarch64.*", new String[] { "sha512" },null)); public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE,