30 /**
31 * Generic test case for SHA-related options targeted to AArch64 CPUs
32 * which don't support instruction required by the tested option.
33 */
34 public class GenericTestCaseForUnsupportedAArch64CPU extends
35 SHAOptionsBase.TestCase {
36 public GenericTestCaseForUnsupportedAArch64CPU(String optionName) {
37 super(optionName, new AndPredicate(Platform::isAArch64,
38 new NotPredicate(SHAOptionsBase.getPredicateForOption(
39 optionName))));
40 }
41
42 @Override
43 protected void verifyWarnings() throws Throwable {
44 String shouldPassMessage = String.format("JVM startup should pass with"
45 + "option '-XX:-%s' without any warnings", optionName);
46 //Verify that option could be disabled without any warnings.
47 CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
48 SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
49 }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
50 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
51
52 shouldPassMessage = String.format("If JVM is started with '-XX:-"
53 + "%s' '-XX:+%s', output should contain warning.",
54 SHAOptionsBase.USE_SHA_OPTION, optionName);
55
56 // Verify that when the tested option is enabled, then
57 // a warning will occur in VM output if UseSHA is disabled.
58 if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
59 CommandLineOptionTest.verifySameJVMStartup(
60 new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) },
61 null,
62 shouldPassMessage,
63 shouldPassMessage,
64 ExitCode.OK,
65 CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
66 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
67 }
68 }
69
70 @Override
71 protected void verifyOptionValues() throws Throwable {
72 // Verify that option is disabled by default.
73 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
74 String.format("Option '%s' should be disabled by default",
75 optionName));
76
77 // Verify that option is disabled even if it was explicitly enabled
78 // using CLI options.
79 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
80 String.format("Option '%s' should be off on unsupported "
81 + "AArch64CPU even if set to true directly", optionName),
82 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
83
84 // Verify that option is disabled when +UseSHA was passed to JVM.
85 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
86 String.format("Option '%s' should be off on unsupported "
87 + "AArch64CPU even if %s flag set to JVM",
88 optionName, CommandLineOptionTest.prepareBooleanFlag(
89 SHAOptionsBase.USE_SHA_OPTION, true)),
90 CommandLineOptionTest.prepareBooleanFlag(
91 SHAOptionsBase.USE_SHA_OPTION, true));
92 }
93 }
|
30 /**
31 * Generic test case for SHA-related options targeted to AArch64 CPUs
32 * which don't support instruction required by the tested option.
33 */
34 public class GenericTestCaseForUnsupportedAArch64CPU extends
35 SHAOptionsBase.TestCase {
36 public GenericTestCaseForUnsupportedAArch64CPU(String optionName) {
37 super(optionName, new AndPredicate(Platform::isAArch64,
38 new NotPredicate(SHAOptionsBase.getPredicateForOption(
39 optionName))));
40 }
41
42 @Override
43 protected void verifyWarnings() throws Throwable {
44 String shouldPassMessage = String.format("JVM startup should pass with"
45 + "option '-XX:-%s' without any warnings", optionName);
46 //Verify that option could be disabled without any warnings.
47 CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
48 SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
49 }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
50 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
51 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
52
53 shouldPassMessage = String.format("If JVM is started with '-XX:-"
54 + "%s' '-XX:+%s', output should contain warning.",
55 SHAOptionsBase.USE_SHA_OPTION, optionName);
56
57 // Verify that when the tested option is enabled, then
58 // a warning will occur in VM output if UseSHA is disabled.
59 if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
60 CommandLineOptionTest.verifySameJVMStartup(
61 new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) },
62 null,
63 shouldPassMessage,
64 shouldPassMessage,
65 ExitCode.OK,
66 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
67 CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
68 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
69 }
70 }
71
72 @Override
73 protected void verifyOptionValues() throws Throwable {
74 // Verify that option is disabled by default.
75 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
76 String.format("Option '%s' should be disabled by default",
77 optionName),
78 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
79
80 // Verify that option is disabled even if it was explicitly enabled
81 // using CLI options.
82 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
83 String.format("Option '%s' should be off on unsupported "
84 + "AArch64CPU even if set to true directly", optionName),
85 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
86 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
87
88 // Verify that option is disabled when +UseSHA was passed to JVM.
89 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
90 String.format("Option '%s' should be off on unsupported "
91 + "AArch64CPU even if %s flag set to JVM",
92 optionName, CommandLineOptionTest.prepareBooleanFlag(
93 SHAOptionsBase.USE_SHA_OPTION, true)),
94 SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
95 CommandLineOptionTest.prepareBooleanFlag(
96 SHAOptionsBase.USE_SHA_OPTION, true));
97 }
98 }
|