1 /* |
|
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 import jdk.test.lib.Asserts; |
|
25 import jdk.test.lib.ExitCode; |
|
26 import jdk.test.lib.Platform; |
|
27 import jdk.test.lib.cli.CommandLineOptionTest; |
|
28 import jdk.test.lib.cli.predicate.AndPredicate; |
|
29 import jdk.test.lib.cli.predicate.NotPredicate; |
|
30 import sha.predicate.IntrinsicPredicates; |
|
31 |
|
32 /** |
|
33 * UseSHA specific test case targeted to SPARC CPUs which don't support all sha* |
|
34 * instructions. |
|
35 */ |
|
36 public class UseSHASpecificTestCaseForUnsupportedSparcCPU |
|
37 extends SHAOptionsBase.TestCase { |
|
38 public UseSHASpecificTestCaseForUnsupportedSparcCPU(String optionName) { |
|
39 super(SHAOptionsBase.USE_SHA_OPTION, new AndPredicate(Platform::isSparc, |
|
40 new NotPredicate( |
|
41 IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE))); |
|
42 |
|
43 Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION, |
|
44 "Test case should be used for " + SHAOptionsBase.USE_SHA_OPTION |
|
45 + " option only."); |
|
46 } |
|
47 |
|
48 @Override |
|
49 protected void verifyWarnings() throws Throwable { |
|
50 // Verify that attempt to use UseSHA option will cause a warning. |
|
51 String shouldPassMessage = String.format("JVM startup should pass with" |
|
52 + " '%s' option on unsupported SparcCPU, but there should be" |
|
53 + "the message shown.", optionName); |
|
54 CommandLineOptionTest.verifySameJVMStartup(new String[] { |
|
55 SHAOptionsBase.getWarningForUnsupportedCPU(optionName) |
|
56 }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, |
|
57 CommandLineOptionTest.prepareBooleanFlag(optionName, true)); |
|
58 } |
|
59 |
|
60 @Override |
|
61 protected void verifyOptionValues() throws Throwable { |
|
62 // Verify that UseSHA option remains disabled even if all |
|
63 // UseSHA*Intrinsics were enabled. |
|
64 CommandLineOptionTest.verifyOptionValueForSameVM( |
|
65 SHAOptionsBase.USE_SHA_OPTION, "false", String.format( |
|
66 "%s option should be disabled on unsupported SparcCPU" |
|
67 + " even if all UseSHA*Intrinsics options were enabled.", |
|
68 SHAOptionsBase.USE_SHA_OPTION), |
|
69 CommandLineOptionTest.prepareBooleanFlag( |
|
70 SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), |
|
71 CommandLineOptionTest.prepareBooleanFlag( |
|
72 SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), |
|
73 CommandLineOptionTest.prepareBooleanFlag( |
|
74 SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); |
|
75 |
|
76 // Verify that UseSHA option remains disabled even if all |
|
77 // UseSHA*Intrinsics options were enabled and UseSHA was enabled as well. |
|
78 CommandLineOptionTest.verifyOptionValueForSameVM( |
|
79 SHAOptionsBase.USE_SHA_OPTION, "false", String.format( |
|
80 "%s option should be disabled on unsupported SparcCPU" |
|
81 + " even if all UseSHA*Intrinsics options were enabled" |
|
82 + " and %s was enabled as well", |
|
83 SHAOptionsBase.USE_SHA_OPTION, |
|
84 SHAOptionsBase.USE_SHA_OPTION), |
|
85 CommandLineOptionTest.prepareBooleanFlag( |
|
86 SHAOptionsBase.USE_SHA_OPTION, true), |
|
87 CommandLineOptionTest.prepareBooleanFlag( |
|
88 SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), |
|
89 CommandLineOptionTest.prepareBooleanFlag( |
|
90 SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, true), |
|
91 CommandLineOptionTest.prepareBooleanFlag( |
|
92 SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); |
|
93 } |
|
94 } |
|