author | tpivovarova |
Tue, 12 Jul 2016 18:24:48 +0300 | |
changeset 40059 | c2304140ed64 |
parent 38285 | 20b85a0ba796 |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
31230 | 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 |
||
40059 | 24 |
package compiler.intrinsics.sha.cli.testcases; |
25 |
||
26 |
import compiler.intrinsics.sha.cli.SHAOptionsBase; |
|
31230 | 27 |
import jdk.test.lib.ExitCode; |
28 |
import jdk.test.lib.Platform; |
|
29 |
import jdk.test.lib.cli.CommandLineOptionTest; |
|
30 |
import jdk.test.lib.cli.predicate.AndPredicate; |
|
31 |
import jdk.test.lib.cli.predicate.OrPredicate; |
|
32 |
||
33 |
/** |
|
34 |
* Generic test case for SHA-related options targeted to CPUs which |
|
35 |
* support instructions required by the tested option. |
|
36 |
*/ |
|
37 |
public class GenericTestCaseForSupportedCPU extends |
|
38 |
SHAOptionsBase.TestCase { |
|
39 |
public GenericTestCaseForSupportedCPU(String optionName) { |
|
40 |
super(optionName, |
|
41 |
new AndPredicate( |
|
42 |
new OrPredicate(Platform::isSparc, Platform::isAArch64), |
|
43 |
SHAOptionsBase.getPredicateForOption(optionName))); |
|
44 |
} |
|
45 |
||
46 |
@Override |
|
47 |
protected void verifyWarnings() throws Throwable { |
|
48 |
||
49 |
String shouldPassMessage = String.format("JVM should start with option" |
|
50 |
+ " '%s' without any warnings", optionName); |
|
51 |
// Verify that there are no warning when option is explicitly enabled. |
|
52 |
CommandLineOptionTest.verifySameJVMStartup(null, new String[] { |
|
53 |
SHAOptionsBase.getWarningForUnsupportedCPU(optionName) |
|
54 |
}, shouldPassMessage, shouldPassMessage, ExitCode.OK, |
|
38285
20b85a0ba796
8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents:
31588
diff
changeset
|
55 |
SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, |
31230 | 56 |
CommandLineOptionTest.prepareBooleanFlag(optionName, true)); |
57 |
||
58 |
// Verify that option could be disabled even if +UseSHA was passed to |
|
59 |
// JVM. |
|
60 |
CommandLineOptionTest.verifySameJVMStartup(null, new String[] { |
|
61 |
SHAOptionsBase.getWarningForUnsupportedCPU(optionName) |
|
62 |
}, shouldPassMessage, String.format("It should be able to " |
|
63 |
+ "disable option '%s' even if %s was passed to JVM", |
|
64 |
optionName, CommandLineOptionTest.prepareBooleanFlag( |
|
65 |
SHAOptionsBase.USE_SHA_OPTION, true)), |
|
66 |
ExitCode.OK, |
|
38285
20b85a0ba796
8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents:
31588
diff
changeset
|
67 |
SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, |
31230 | 68 |
CommandLineOptionTest.prepareBooleanFlag( |
69 |
SHAOptionsBase.USE_SHA_OPTION, true), |
|
70 |
CommandLineOptionTest.prepareBooleanFlag(optionName, false)); |
|
71 |
||
31588
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
72 |
if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) { |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
73 |
// Verify that if -XX:-UseSHA is passed to the JVM, it is not possible |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
74 |
// to enable the tested option and a warning is printed. |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
75 |
CommandLineOptionTest.verifySameJVMStartup( |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
76 |
new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
77 |
null, |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
78 |
shouldPassMessage, |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
79 |
String.format("Enabling option '%s' should not be possible and should result in a warning if %s was passed to JVM", |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
80 |
optionName, |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
81 |
CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false)), |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
82 |
ExitCode.OK, |
38285
20b85a0ba796
8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents:
31588
diff
changeset
|
83 |
SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, |
31588
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
84 |
CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
85 |
CommandLineOptionTest.prepareBooleanFlag(optionName, true)); |
2a864a4a414c
8130120: Handling of SHA intrinsics inconsistent across platforms
zmajo
parents:
31230
diff
changeset
|
86 |
} |
31230 | 87 |
} |
88 |
||
89 |
@Override |
|
90 |
protected void verifyOptionValues() throws Throwable { |
|
91 |
// Verify that "It should be able to disable option " |
|
92 |
||
93 |
CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", |
|
94 |
String.format("Option '%s' should be enabled by default", |
|
38285
20b85a0ba796
8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents:
31588
diff
changeset
|
95 |
optionName), |
20b85a0ba796
8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents:
31588
diff
changeset
|
96 |
SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS); |
31230 | 97 |
|
98 |
// Verify that it is possible to explicitly enable the option. |
|
99 |
CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", |
|
100 |
String.format("Option '%s' was set to have value 'true'", |
|
101 |
optionName), |
|
38285
20b85a0ba796
8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents:
31588
diff
changeset
|
102 |
SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, |
31230 | 103 |
CommandLineOptionTest.prepareBooleanFlag(optionName, true)); |
104 |
||
105 |
// Verify that it is possible to explicitly disable the option. |
|
106 |
CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", |
|
107 |
String.format("Option '%s' was set to have value 'false'", |
|
108 |
optionName), |
|
38285
20b85a0ba796
8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents:
31588
diff
changeset
|
109 |
SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, |
31230 | 110 |
CommandLineOptionTest.prepareBooleanFlag(optionName, false)); |
111 |
||
112 |
// verify that option is disabled when -UseSHA was passed to JVM. |
|
113 |
CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", |
|
114 |
String.format("Option '%s' should have value 'false' when %s" |
|
115 |
+ " flag set to JVM", optionName, |
|
116 |
CommandLineOptionTest.prepareBooleanFlag( |
|
117 |
SHAOptionsBase.USE_SHA_OPTION, false)), |
|
38285
20b85a0ba796
8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents:
31588
diff
changeset
|
118 |
SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, |
31230 | 119 |
CommandLineOptionTest.prepareBooleanFlag(optionName, true), |
120 |
CommandLineOptionTest.prepareBooleanFlag( |
|
121 |
SHAOptionsBase.USE_SHA_OPTION, false)); |
|
122 |
||
123 |
// Verify that it is possible to explicitly disable the tested option |
|
124 |
// even if +UseSHA was passed to JVM. |
|
125 |
CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", |
|
126 |
String.format("Option '%s' should have value 'false' if set so" |
|
127 |
+ " even if %s flag set to JVM", optionName, |
|
128 |
CommandLineOptionTest.prepareBooleanFlag( |
|
129 |
SHAOptionsBase.USE_SHA_OPTION, true)), |
|
38285
20b85a0ba796
8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options
rraghavan
parents:
31588
diff
changeset
|
130 |
SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, |
31230 | 131 |
CommandLineOptionTest.prepareBooleanFlag( |
132 |
SHAOptionsBase.USE_SHA_OPTION, true), |
|
133 |
CommandLineOptionTest.prepareBooleanFlag(optionName, false)); |
|
134 |
} |
|
135 |
} |