diff --git a/hotspot/test/compiler/arguments/BMISupportedCPUTest.java b/hotspot/test/compiler/arguments/BMISupportedCPUTest.java index df6e1540918f9797d44594cfaaa46186692266dc..c67deab9bbe78497447908b937b9c457d3f5e70f 100644 --- a/hotspot/test/compiler/arguments/BMISupportedCPUTest.java +++ b/hotspot/test/compiler/arguments/BMISupportedCPUTest.java @@ -60,8 +60,11 @@ public class BMISupportedCPUTest extends BMICommandLineOptionTestBase { VM will be launched with following flags: -XX:+ -version */ + String errorString = String.format("JVM should start with '-XX:+%s'" + + " flag without any warnings", optionName); CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { warningMessage }, ExitCode.OK, + new String[] { warningMessage }, errorString, errorString, + ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); /* @@ -69,8 +72,11 @@ public class BMISupportedCPUTest extends BMICommandLineOptionTestBase { VM will be launched with following flags: -XX:- -version */ + errorString = String.format("JVM should start with '-XX:-%s'" + + " flag without any warnings", optionName); CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { warningMessage }, ExitCode.OK, + new String[] { warningMessage }, errorString, + errorString, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); /* @@ -78,7 +84,9 @@ public class BMISupportedCPUTest extends BMICommandLineOptionTestBase { VM will be launched with following flags: -version */ - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true"); + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", + String.format("Option '%s' is expected to have default value " + + "'true'", optionName)); /* Verify that option could be explicitly turned off. @@ -86,6 +94,8 @@ public class BMISupportedCPUTest extends BMICommandLineOptionTestBase { -XX:- -version */ CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' is set to have value 'false'", + optionName), CommandLineOptionTest.prepareBooleanFlag(optionName, false)); } } diff --git a/hotspot/test/compiler/arguments/BMIUnsupportedCPUTest.java b/hotspot/test/compiler/arguments/BMIUnsupportedCPUTest.java index 93fbcb296874e02d534ed002f994ab3d8bf16092..bae0280162abe7d77eb9b81b75be49a27b7a29d4 100644 --- a/hotspot/test/compiler/arguments/BMIUnsupportedCPUTest.java +++ b/hotspot/test/compiler/arguments/BMIUnsupportedCPUTest.java @@ -75,9 +75,13 @@ public class BMIUnsupportedCPUTest extends BMICommandLineOptionTestBase { warning. VM will be launched with following options: -XX:+ -version */ + String errorString = String.format("JVM should start with '-XX:+%s' " + + "flag, but output should contain warning.", optionName); CommandLineOptionTest.verifySameJVMStartup( new String[] { warningMessage }, new String[] { errorMessage }, - ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag( + errorString, String.format("Option '%s' is unsupported.%n" + + "Warning expected to be shown.", optionName), ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag( optionName, true)); /* @@ -85,15 +89,21 @@ public class BMIUnsupportedCPUTest extends BMICommandLineOptionTestBase { VM will be launched with following options: -XX:- -version */ + errorString = String.format("JVM should start with '-XX:-%s' flag " + + "without any warnings", optionName); CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { warningMessage, errorMessage }, ExitCode.OK, + new String[] { warningMessage, errorMessage }, + errorString, errorString, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); /* - Verify that on unsupported CPUs option is off by default. - VM will be launched with following options: -version - */ - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false"); + * Verify that on unsupported CPUs option is off by default. VM will be + * launched with following options: -version + */ + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' is expected to have default value " + + "'false' since feature required is not supported " + + "on CPU", optionName)); /* Verify that on unsupported CPUs option will be off even if @@ -101,6 +111,9 @@ public class BMIUnsupportedCPUTest extends BMICommandLineOptionTestBase { following options: -XX:+ -version */ CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' is expected to have default value" + + " 'false' since feature required is not supported on" + + " CPU even if user set another value.", optionName), CommandLineOptionTest.prepareBooleanFlag(optionName, true)); } @@ -118,11 +131,17 @@ public class BMIUnsupportedCPUTest extends BMICommandLineOptionTestBase { with following options: -XX:[+-] -version */ CommandLineOptionTest.verifySameJVMStartup( - new String[] { errorMessage }, null, ExitCode.FAIL, + new String[] { errorMessage }, null, + String.format("JVM startup should fail with '-XX:+%s' flag." + + "%nOption should be unknown (non-X86CPU).", + optionName), "", ExitCode.FAIL, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); CommandLineOptionTest.verifySameJVMStartup( - new String[] { errorMessage }, null, ExitCode.FAIL, + new String[] { errorMessage }, null, + String.format("JVM startup should fail with '-XX:-%s' flag." + + "%nOption should be unknown (non-X86CPU)", + optionName), "", ExitCode.FAIL, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); } } diff --git a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java index 2a39ada6f18d6f3c19d383a299b41902618597e5..aadd3180d49bc5f056db7165ebac6e2d4f281d44 100644 --- a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java +++ b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java @@ -59,6 +59,9 @@ public class TestUseCountTrailingZerosInstructionOnSupportedCPU -XX:-UseBMI1Instructions -version */ CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + "Option 'UseCountTrailingZerosInstruction' should have " + + "'false' value if all BMI1 instructions are explicitly" + + " disabled (-XX:-UseBMI1Instructions flag used)", TestUseCountTrailingZerosInstructionOnSupportedCPU.DISABLE_BMI); /* @@ -68,6 +71,9 @@ public class TestUseCountTrailingZerosInstructionOnSupportedCPU -XX:+UseCountTrailingZerosInstruction -version */ CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", + "Option 'UseCountTrailingZerosInstruction' should be able to " + + "be turned on even if all BMI1 instructions are " + + "disabled (-XX:-UseBMI1Instructions flag used)", TestUseCountTrailingZerosInstructionOnSupportedCPU.DISABLE_BMI, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); } diff --git a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java index 1bd71a70a0a48abd6d3d39b0e4ed1dcb99309649..68483893a535275f9216a47fc8977cfe8520af44 100644 --- a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java +++ b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java @@ -59,6 +59,9 @@ public class TestUseCountTrailingZerosInstructionOnUnsupportedCPU -XX:+UseBMI1Instructions -version */ CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + "Feature bmi1 is not supported on current CPU. Option " + + "UseCountTrailingZerosInstruction should have 'false'" + + " value", TestUseCountTrailingZerosInstructionOnUnsupportedCPU. ENABLE_BMI); @@ -68,6 +71,9 @@ public class TestUseCountTrailingZerosInstructionOnUnsupportedCPU -version */ CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + "Feature bmi1 is not supported on current CPU. Option " + + "UseCountTrailingZerosInstruction should have 'false'" + + " value", CommandLineOptionTest.prepareBooleanFlag(optionName, true), TestUseCountTrailingZerosInstructionOnUnsupportedCPU. ENABLE_BMI); diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java index c5d21ed4baa31f8a7452b0dd797998618d24ddfd..a67883166bae18059b5f92746258abf8bdacfe65 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java @@ -41,30 +41,42 @@ public class GenericTestCaseForOtherCPU extends @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. CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { ".*" + optionName + ".*" }, ExitCode.OK, + new String[] { ".*" + optionName + ".*" }, shouldPassMessage, + shouldPassMessage, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { ".*" + optionName + ".*" }, ExitCode.OK, + new String[] { ".*" + optionName + ".*" }, shouldPassMessage, + shouldPassMessage, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); } @Override protected void verifyOptionValues() throws Throwable { // Verify that option is disabled by default. - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false"); + 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 " + + "CPU even if set to true directly", optionName), CommandLineOptionTest.prepareBooleanFlag(optionName, true)); // Verify that option is disabled when it explicitly disabled // using CLI options. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' should be off on unsupported CPU" + + " even if '%s' flag set to JVM", optionName, + CommandLineOptionTest.prepareBooleanFlag( + SHAOptionsBase.USE_SHA_OPTION, true)), CommandLineOptionTest.prepareBooleanFlag(optionName, false)); } } diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java index c8ce2d52ca0e275ebc825da1477f7d198f82a654..e87943d96552390676864c16fba069be74a9b2fc 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java @@ -39,17 +39,24 @@ public class GenericTestCaseForSupportedSparcCPU extends @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) - }, ExitCode.OK, + }, 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) - }, ExitCode.OK, + }, 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)); @@ -58,7 +65,11 @@ public class GenericTestCaseForSupportedSparcCPU extends // all SHA intrinsics via -UseSHA without any warnings. CommandLineOptionTest.verifySameJVMStartup(null, new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) - }, ExitCode.OK, + }, 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)); @@ -66,19 +77,30 @@ public class GenericTestCaseForSupportedSparcCPU extends @Override protected void verifyOptionValues() throws Throwable { - // Verify that on supported CPU option is enabled by default. - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true"); + // 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)); @@ -86,6 +108,10 @@ public class GenericTestCaseForSupportedSparcCPU extends // 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/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java index 43bda2fb07a9c48ae5bdce10bfe756e029449bb1..e2a85fe6271a548d98f25677f7b1fbbd4a97db80 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java @@ -41,25 +41,35 @@ public class GenericTestCaseForUnsupportedSparcCPU extends @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) - }, ExitCode.OK, + }, shouldPassMessage, shouldPassMessage, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); } @Override protected void verifyOptionValues() throws Throwable { // Verify that option is disabled by default. - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false"); + 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 " + + "SparcCPU 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 " + + "SparcCPU 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/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java index d7033e52448ef4db9dcb8a0aa1f0d1035361ec7c..5c5d3d32e644cc94cc679acd20a49f744315160b 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java @@ -38,33 +38,45 @@ public class GenericTestCaseForUnsupportedX86CPU @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 when the tested option is explicitly enabled, then // a warning will occur in VM output. CommandLineOptionTest.verifySameJVMStartup(new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) - }, null, ExitCode.OK, + }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); + shouldPassMessage = String.format("JVM should start with '-XX:-%s' " + + "flag without any warnings", optionName); // Verify that the tested option could be explicitly disabled without // a warning. CommandLineOptionTest.verifySameJVMStartup(null, new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) - }, ExitCode.OK, + }, shouldPassMessage, shouldPassMessage, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); } @Override protected void verifyOptionValues() throws Throwable { // Verify that the tested option is disabled by default. - CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false"); + CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' should be disabled by default", + optionName)); // Verify that it is not possible to explicitly enable the option. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' should be off on unsupported " + + "X86CPU even if set to true directly", optionName), CommandLineOptionTest.prepareBooleanFlag(optionName, true)); // Verify that the tested option is disabled even if +UseSHA was passed // to JVM. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", + String.format("Option '%s' should be off on unsupported " + + "X86CPU 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/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java index 4e208eec9586192faf71ccf10a4acb710ce6b5e4..16b925bafe58ae6a1736da78c63d146dbd2cc551 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java @@ -50,10 +50,13 @@ public class UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU } @Override protected void verifyWarnings() throws Throwable { - // Verify that attempt to enable the tested option will cause a warning. + 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, ExitCode.OK, + }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); } } diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java index f547568398a25cdea5fa665edfabeda115ad255d..95046ea125da9ff4b7998dbb18687be0d0f689f4 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java @@ -39,16 +39,22 @@ public class UseSHASpecificTestCaseForSupportedSparcCPU IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE)); Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION, - "Test case should be used for " + SHAOptionsBase.USE_SHA_OPTION - + " option only."); + 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.*" }, ExitCode.OK, + null, new String[] { ".*UseSHA.*" }, shouldPassMessage, + shouldPassMessage, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true), CommandLineOptionTest.prepareBooleanFlag( @@ -61,10 +67,12 @@ public class UseSHASpecificTestCaseForSupportedSparcCPU @Override protected void verifyOptionValues() throws Throwable { - // Verify that UseSHA is disabled when all UseSHA*Intrinscs are + // Verify that UseSHA is disabled when all UseSHA*Intrinsics are // disabled. CommandLineOptionTest.verifyOptionValueForSameVM( - SHAOptionsBase.USE_SHA_OPTION, "false", + 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( @@ -73,9 +81,14 @@ public class UseSHASpecificTestCaseForSupportedSparcCPU SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false)); CommandLineOptionTest.verifyOptionValueForSameVM( - // Verify that UseSHA is disabled when all UseSHA*Intrinscs are + // 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( @@ -89,6 +102,11 @@ public class UseSHASpecificTestCaseForSupportedSparcCPU // 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( diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java index 5aceed60715a2e7df6659f7671ceeb37f5ecee5a..fb81f6e3d7982560a954278c0289d4a232bb4ed9 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java @@ -48,18 +48,24 @@ public class UseSHASpecificTestCaseForUnsupportedSparcCPU @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, ExitCode.OK, + }, 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*Intrincs options were enabled. + // UseSHA*Intrinsics were enabled. CommandLineOptionTest.verifyOptionValueForSameVM( - SHAOptionsBase.USE_SHA_OPTION, "false", + 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( @@ -68,9 +74,14 @@ public class UseSHASpecificTestCaseForUnsupportedSparcCPU SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true)); // Verify that UseSHA option remains disabled even if all - // UseSHA*Intrincs options were enabled and UseSHA was enabled as well. + // UseSHA*Intrinsics options were enabled and UseSHA was enabled as well. CommandLineOptionTest.verifyOptionValueForSameVM( - SHAOptionsBase.USE_SHA_OPTION, "false", + 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( diff --git a/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java b/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java index 16177156958600cdb8719a228cda6e401fac09bf..5b9f50aef6b679dfd4cedd7ee41efbede0a87c43 100644 --- a/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java +++ b/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java @@ -121,7 +121,9 @@ public abstract class RTMGenericCommandLineOptionTest */ protected void runNonX86TestCases() throws Throwable { CommandLineOptionTest.verifySameJVMStartup( - new String[] { errorMessage }, null, ExitCode.FAIL, + new String[] { errorMessage }, null, + String.format("Option '%s' should be unknown on non-X86CPUs.%n" + + "JVM startup should fail", optionName), "", ExitCode.FAIL, prepareOptionValue(defaultValue)); } @@ -136,12 +138,18 @@ public abstract class RTMGenericCommandLineOptionTest protected void verifyJVMStartup() throws Throwable { String optionValue = prepareOptionValue(defaultValue); + String shouldFailMessage = String.format("VM option '%s' is " + + "experimental.%nVM startup expected to fail without " + + "-XX:+UnlockExperimentalVMOptions option", optionName); + String shouldPassMessage = String.format("VM option '%s' is " + + "experimental%nVM startup should pass with " + + "-XX:+UnlockExperimentalVMOptions option", optionName); if (isExperimental) { // verify that option is experimental CommandLineOptionTest.verifySameJVMStartup( new String[] { experimentalOptionError }, - new String[] { errorMessage }, ExitCode.FAIL, - optionValue); + new String[] { errorMessage }, shouldFailMessage, + shouldFailMessage, ExitCode.FAIL, optionValue); // verify that it could be passed if experimental options // are unlocked CommandLineOptionTest.verifySameJVMStartup(null, @@ -149,13 +157,19 @@ public abstract class RTMGenericCommandLineOptionTest experimentalOptionError, errorMessage }, + shouldPassMessage, + "JVM should start without any warnings or errors", ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, optionValue); } else { // verify that option could be passed CommandLineOptionTest.verifySameJVMStartup(null, - new String[]{errorMessage}, ExitCode.OK, optionValue); + new String[]{errorMessage}, + String.format("VM startup shuld pass with '%s' option", + optionName), + "JVM should start without any warnings or errors", + ExitCode.OK, optionValue); } } @@ -164,10 +178,14 @@ public abstract class RTMGenericCommandLineOptionTest if (isExperimental) { CommandLineOptionTest.verifyOptionValueForSameVM(optionName, defaultValue, + String.format("Option '%s' is expected to have '%s' " + + "default value", optionName, defaultValue), CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS); } else { CommandLineOptionTest.verifyOptionValueForSameVM(optionName, - defaultValue); + defaultValue, + String.format("Option '%s' is expected to have '%s' " + + "default value", optionName, defaultValue)); } // verify other specified option values if (optionValues == null) { @@ -178,11 +196,15 @@ public abstract class RTMGenericCommandLineOptionTest if (isExperimental) { CommandLineOptionTest.verifyOptionValueForSameVM(optionName, value, + String.format("Option '%s' is set to have '%s' value", + optionName, value), CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, prepareOptionValue(value)); } else { CommandLineOptionTest.verifyOptionValueForSameVM(optionName, - value, prepareOptionValue(value)); + value, + String.format("Option '%s' is set to have '%s' value", + optionName, value), prepareOptionValue(value)); } } } diff --git a/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java b/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java index bcc75ef4fbb3b8d5d08645a27f5a7d6981320b9d..baa6f6d8efc4c79918b66fdfcff2fa63377c2050 100644 --- a/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java +++ b/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java @@ -131,10 +131,14 @@ public abstract class RTMLockingAwareTest } options.add(prepareOptionValue(value)); + String errorString = String.format("JVM should start with option '%s'" + + "'%nWarnings should be shown: %s", optionName, + isWarningExpected); CommandLineOptionTest.verifySameJVMStartup( (isWarningExpected ? warnings : null), (isWarningExpected ? null : warnings), - ExitCode.OK, options.toArray(new String[options.size()])); + errorString, errorString, ExitCode.OK, + options.toArray(new String[options.size()])); } private void verifyOptionValues(String value, boolean useRTMLocking, @@ -149,6 +153,9 @@ public abstract class RTMLockingAwareTest options.add(prepareOptionValue(value)); CommandLineOptionTest.verifyOptionValueForSameVM(optionName, - expectedValue, options.toArray(new String[options.size()])); + expectedValue, String.format("Option '%s' should have '%s' " + + "value if '%s' flag set", + optionName, expectedValue, prepareOptionValue(value)), + options.toArray(new String[options.size()])); } } diff --git a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java index 2c7d56507ea496f2dc7b05005b43650566ab8a42..69a5fd354d50af4618721c5032e292e33b1eaaa8 100644 --- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java +++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java @@ -47,27 +47,42 @@ public abstract class TestPrintPreciseRTMLockingStatisticsBase protected void verifyJVMStartup() throws Throwable { if (Platform.isServer()) { if (!Platform.isDebugBuild()) { + String shouldFailMessage = String.format("VM option '%s' is " + + "diagnostic%nJVM startup should fail without " + + "-XX:\\+UnlockDiagnosticVMOptions flag", optionName); + String shouldPassMessage = String.format("VM option '%s' is " + + "diagnostic%nJVM startup should pass with " + + "-XX:\\+UnlockDiagnosticVMOptions in debug build", + optionName); String errorMessage = CommandLineOptionTest. getDiagnosticOptionErrorMessage(optionName); // verify that option is actually diagnostic CommandLineOptionTest.verifySameJVMStartup( - new String[] { errorMessage }, null, ExitCode.FAIL, + new String[] { errorMessage }, null, shouldFailMessage, + shouldFailMessage, ExitCode.FAIL, prepareOptionValue("true")); CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { errorMessage }, ExitCode.OK, + new String[] { errorMessage }, shouldPassMessage, + shouldPassMessage + "without any warnings", ExitCode.OK, CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, prepareOptionValue("true")); } else { - CommandLineOptionTest.verifySameJVMStartup( - null, null, ExitCode.OK, prepareOptionValue("true")); + String shouldPassMessage = String.format("JVM startup should " + + "pass with '%s' option in debug build", + optionName); + CommandLineOptionTest.verifySameJVMStartup(null, null, + shouldPassMessage, shouldPassMessage, + ExitCode.OK, prepareOptionValue("true")); } } else { String errorMessage = CommandLineOptionTest. getUnrecognizedOptionErrorMessage(optionName); - + String shouldFailMessage = String.format("JVM startup should fail" + + " with '%s' option in not debug build", optionName); CommandLineOptionTest.verifySameJVMStartup( - new String[]{errorMessage}, null, ExitCode.FAIL, + new String[]{errorMessage}, null, shouldFailMessage, + shouldFailMessage, ExitCode.FAIL, CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, prepareOptionValue("true")); } @@ -79,6 +94,9 @@ public abstract class TestPrintPreciseRTMLockingStatisticsBase // Verify default value CommandLineOptionTest.verifyOptionValueForSameVM(optionName, TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE, + String.format("Option '%s' should have '%s' default value", + optionName, + TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE), CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS); } } diff --git a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java index 42540645927453f7cac281de4bd5968f83ad8514..cf3ebabb925ec3ba714c6e3d0b5f0e043a454f5b 100644 --- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java +++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java @@ -53,18 +53,28 @@ public class TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig // verify default value CommandLineOptionTest.verifyOptionValueForSameVM(optionName, TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE, + String.format("Option '%s' should have '%s' default value on" + + " supported CPU", optionName, + TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE), CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking"); CommandLineOptionTest.verifyOptionValueForSameVM(optionName, TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE, + String.format("Option '%s' should have '%s' default value on" + + " supported CPU when -XX:-UseRTMLocking flag set", + optionName, + TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE), CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:-UseRTMLocking", prepareOptionValue("true")); // verify that option could be turned on CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", + String.format("Option '%s' should have 'true' value when set " + + "on supported CPU and -XX:+UseRTMLocking flag set", + optionName), CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking", prepareOptionValue("true")); diff --git a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java index 40be15012c4b86132e24ef932563baddc97bc1e3..de40746ec9f4a48569d94d6216c773e426feaa59 100644 --- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java +++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java @@ -51,26 +51,40 @@ public class TestUseRTMDeoptOptionOnSupportedConfig @Override public void runTestCases() throws Throwable { + String shouldPassMessage = " JVM should startup with option '" + + "-XX:+UseRTMDeopt' without any warnings"; // verify that option could be turned on CommandLineOptionTest.verifySameJVMStartup( - null, null, ExitCode.OK, "-XX:+UseRTMDeopt"); + null, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, + "-XX:+UseRTMDeopt"); + shouldPassMessage = " JVM should startup with option '" + + "-XX:-UseRTMDeopt' without any warnings"; // verify that option could be turned off CommandLineOptionTest.verifySameJVMStartup( - null, null, ExitCode.OK, "-XX:-UseRTMDeopt"); + null, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, + "-XX:-UseRTMDeopt"); + String defValMessage = String.format("UseRTMDeopt should have '%s'" + + "default value", + TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE); // verify default value CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt", - TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE); + TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE, + defValMessage); // verify default value CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt", TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE, + defValMessage, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking"); // verify that option is off when UseRTMLocking is off - CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt", "false", + CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt", + "false", "UseRTMDeopt should be off when UseRTMLocking is off", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:-UseRTMLocking", "-XX:+UseRTMDeopt"); // verify that option could be turned on CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt", "true", + "UseRTMDeopt should be on when UseRTMLocking is on and " + + "'-XX:+UseRTMDeopt' flag set", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking", "-XX:+UseRTMDeopt"); } diff --git a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java index 6183dfc51ff3d5c42ff78081118751a29698bf88..59f9f450feb3fab0ce86faf93f1645493881b825 100644 --- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java +++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java @@ -50,7 +50,8 @@ public class TestUseRTMDeoptOptionOnUnsupportedConfig super(new NotPredicate(new AndPredicate(new SupportedCPU(), new SupportedVM())), "UseRTMDeopt", true, false, - TestUseRTMDeoptOptionOnUnsupportedConfig.DEFAULT_VALUE, "true"); + TestUseRTMDeoptOptionOnUnsupportedConfig.DEFAULT_VALUE, + "true"); } @Override @@ -58,11 +59,16 @@ public class TestUseRTMDeoptOptionOnUnsupportedConfig super.verifyJVMStartup(); // verify default value CommandLineOptionTest.verifyOptionValueForSameVM(optionName, - defaultValue); + defaultValue, String.format("'%s' should have '%s' " + + "default value on unsupported configs.", + optionName, DEFAULT_VALUE)); // verify that until RTMLocking is not used, value // will be set to default false. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, - defaultValue, "-XX:+UseRTMDeopt"); + defaultValue, String.format("'%s' should be off on unsupported" + + " configs even if '-XX:+%s' flag set", optionName, + optionName), + "-XX:+UseRTMDeopt"); } public static void main(String args[]) throws Throwable { diff --git a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java index d4b7406ce8b7aaf8bb19e8cf741e0e48843c46e3..692c396354cb9b8eaf359f92330df98873c2aebc 100644 --- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java +++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java @@ -58,43 +58,67 @@ public class TestUseRTMForStackLocksOptionOnSupportedConfig String warningMessage = RTMGenericCommandLineOptionTest.RTM_FOR_STACK_LOCKS_WARNING; + String shouldFailMessage = " VM option 'UseRTMForStackLocks' is " + + "experimental%nJVM startup should fail without " + + "-XX:+UnlockExperimentalVMOptions flag"; + CommandLineOptionTest.verifySameJVMStartup( - new String[] { errorMessage }, null, ExitCode.FAIL, + new String[] { errorMessage }, null, shouldFailMessage, + shouldFailMessage + "%nError message expected", ExitCode.FAIL, "-XX:+UseRTMForStackLocks"); + String shouldPassMessage = " VM option 'UseRTMForStackLocks'" + + " is experimental%nJVM startup should pass with " + + "-XX:+UnlockExperimentalVMOptions flag"; // verify that we get a warning when trying to use rtm for stack // lock, but not using rtm locking. CommandLineOptionTest.verifySameJVMStartup( - new String[] { warningMessage }, null, ExitCode.OK, + new String[] { warningMessage }, null, shouldPassMessage, + "There should be warning when trying to use rtm for stack " + + "lock, but not using rtm locking", ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMForStackLocks", "-XX:-UseRTMLocking"); // verify that we don't get a warning when no using rtm for stack // lock and not using rtm locking. CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { warningMessage }, ExitCode.OK, + new String[] { warningMessage }, shouldPassMessage, + "There should not be any warning when use both " + + "-XX:-UseRTMForStackLocks and -XX:-UseRTMLocking " + + "flags", + ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:-UseRTMForStackLocks", "-XX:-UseRTMLocking"); // verify that we don't get a warning when using rtm for stack // lock and using rtm locking. CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { warningMessage }, ExitCode.OK, + new String[] { warningMessage }, shouldPassMessage, + "There should not be any warning when use both " + + "-XX:+UseRTMForStackLocks and -XX:+UseRTMLocking" + + " flags", + ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMForStackLocks", "-XX:+UseRTMLocking"); // verify that default value if false CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks", TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE, + "Default value of option 'UseRTMForStackLocks' should be false", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS); // verify that default value is false even with +UseRTMLocking CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks", TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE, + "Default value of option 'UseRTMForStackLocks' should be false", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking"); // verify that we can turn the option on CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks", - "true", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, - "-XX:+UseRTMLocking", "-XX:+UseRTMForStackLocks"); + "true", "Value of option 'UseRTMForStackLocks' should " + + "be able to be set as 'true' when both " + + "-XX:+UseRTMForStackLocks and " + + "-XX:+UseRTMLocking flags used", + CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, + "-XX:+UseRTMLocking", "-XX:+UseRTMForStackLocks"); } public static void main(String args[]) throws Throwable { diff --git a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java index d70f5ff39cf04ab947d9db3a8e72978fa53af21f..829cb560368aa094bfb1bef1d16cb7096eebab41 100644 --- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java +++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java @@ -57,33 +57,50 @@ public class TestUseRTMForStackLocksOptionOnUnsupportedConfig @Override protected void runX86SupportedVMTestCases() throws Throwable { + String shouldFailMessage = String.format("VM option '%s' is " + + "experimental%nJVM startup should fail without " + + "-XX:+UnlockExperimentalVMOptions flag", optionName); + // verify that option is experimental CommandLineOptionTest.verifySameJVMStartup( - new String[]{ experimentalOptionError }, - null, ExitCode.FAIL, prepareOptionValue("true")); + new String[] { experimentalOptionError }, null, + shouldFailMessage, shouldFailMessage + "%nError message " + + "should be shown", ExitCode.FAIL, + prepareOptionValue("true")); CommandLineOptionTest.verifySameJVMStartup( - new String[]{ experimentalOptionError }, - null, ExitCode.FAIL, prepareOptionValue("false")); + new String[]{ experimentalOptionError }, null, + shouldFailMessage, shouldFailMessage + "%nError message " + + "should be shown", ExitCode.FAIL, + prepareOptionValue("false")); + String shouldPassMessage = String.format("VM option '%s' is " + + " experimental%nJVM startup should pass with " + + "-XX:+UnlockExperimentalVMOptions flag", optionName); // verify that if we turn it on, then VM output will contain // warning saying that this option could be turned on only // when we use rtm locking CommandLineOptionTest.verifySameJVMStartup( new String[]{ RTMGenericCommandLineOptionTest.RTM_FOR_STACK_LOCKS_WARNING - }, - null, ExitCode.OK, + }, null, shouldPassMessage, "There should be warning when try " + + "to use rtm for stack lock, but not using rtm locking", + ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, prepareOptionValue("true") ); // verify that options is turned off by default CommandLineOptionTest.verifyOptionValueForSameVM(optionName, TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE, + String.format("Default value of option '%s' should be '%s'", + optionName, DEFAULT_VALUE), CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS); // verify that it could not be turned on without rtm locking CommandLineOptionTest.verifyOptionValueForSameVM(optionName, TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE, + String.format("Value of '%s' shouldn't able to be set to " + + "'true' without setting -XX:+UseRTMLocking flag", + optionName), CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, prepareOptionValue("true")); } diff --git a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java index d7d7e464057dce9e75fd8943a0151870f488dbaa..6012d56c11c5fe588ea5e4221fae82bd4659228e 100644 --- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java +++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java @@ -54,12 +54,16 @@ public class TestUseRTMLockingOptionOnSupportedConfig String unrecongnizedOption = CommandLineOptionTest.getUnrecognizedOptionErrorMessage( "UseRTMLocking"); + String shouldPassMessage = "VM option 'UseRTMLocking' is experimental" + + "%nJVM startup should pass with " + + "-XX:+UnlockExperimentalVMOptions flag"; // verify that there are no warning or error in VM output CommandLineOptionTest.verifySameJVMStartup(null, new String[]{ RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR, unrecongnizedOption - }, ExitCode.OK, + }, shouldPassMessage, "There should not be any warning when use" + + "with -XX:+UnlockExperimentalVMOptions", ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking" ); @@ -68,21 +72,28 @@ public class TestUseRTMLockingOptionOnSupportedConfig new String[]{ RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR, unrecongnizedOption - }, ExitCode.OK, + }, shouldPassMessage, "There should not be any warning when use" + + "with -XX:+UnlockExperimentalVMOptions", ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:-UseRTMLocking" ); // verify that UseRTMLocking is of by default CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", TestUseRTMLockingOptionOnSupportedConfig.DEFAULT_VALUE, + String.format("Default value of option 'UseRTMLocking' should " + + "be '%s'", DEFAULT_VALUE), CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS); // verify that we can change UseRTMLocking value CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", TestUseRTMLockingOptionOnSupportedConfig.DEFAULT_VALUE, + String.format("Default value of option 'UseRTMLocking' should " + + "be '%s'", DEFAULT_VALUE), CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:-UseRTMLocking"); CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", - "true", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, + "true", "Value of 'UseRTMLocking' should be set " + + "to 'true' if -XX:+UseRTMLocking flag set", + CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking"); } diff --git a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java index 65944b7260b10e15537b25c621916eb138d6a8f6..3fba16e1e0902990d81b5e3f81d3524377cafc59 100644 --- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java +++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java @@ -59,33 +59,44 @@ public class TestUseRTMLockingOptionOnUnsupportedCPU String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR; if (Platform.isX86() || Platform.isX64()) { + String shouldFailMessage = "JVM startup should fail with option " + + "-XX:+UseRTMLocking on unsupported CPU"; // verify that we get an error when use +UseRTMLocking // on unsupported CPU CommandLineOptionTest.verifySameJVMStartup( new String[] { errorMessage }, - new String[] { unrecongnizedOption }, + new String[] { unrecongnizedOption }, shouldFailMessage, + shouldFailMessage + ". Error message should be shown", ExitCode.FAIL, "-XX:+UseRTMLocking"); + + String shouldPassMessage = "JVM startup should pass with option " + + "-XX:-UseRTMLocking even on unsupported CPU"; // verify that we can pass -UseRTMLocking without // getting any error messages - CommandLineOptionTest.verifySameJVMStartup( - null, - new String[]{ - errorMessage, - unrecongnizedOption - }, ExitCode.OK, "-XX:-UseRTMLocking"); + CommandLineOptionTest.verifySameJVMStartup(null, new String[] { + errorMessage, unrecongnizedOption }, shouldPassMessage, + shouldPassMessage + " without any warnings", ExitCode.OK, + "-XX:-UseRTMLocking"); // verify that UseRTMLocking is false by default CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", - TestUseRTMLockingOptionOnUnsupportedCPU.DEFAULT_VALUE); + TestUseRTMLockingOptionOnUnsupportedCPU.DEFAULT_VALUE, + String.format("Default value of option 'UseRTMLocking' " + +"should be '%s'", DEFAULT_VALUE)); } else { + String shouldFailMessage = "RTMLocking should be unrecognized" + + " on non-x86 CPUs. JVM startup should fail." + + "Error message should be shown"; // verify that on non-x86 CPUs RTMLocking could not be used CommandLineOptionTest.verifySameJVMStartup( new String[] { unrecongnizedOption }, - null, ExitCode.FAIL, "-XX:+UseRTMLocking"); + null, shouldFailMessage, shouldFailMessage, + ExitCode.FAIL, "-XX:+UseRTMLocking"); CommandLineOptionTest.verifySameJVMStartup( new String[] { unrecongnizedOption }, - null, ExitCode.FAIL, "-XX:-UseRTMLocking"); + null, shouldFailMessage, shouldFailMessage, + ExitCode.FAIL, "-XX:-UseRTMLocking"); } } diff --git a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java index bb883fd5ec7bd4037e94976945c307ea03f296a1..a03122491d10767ff85eda45b56c381a7263d5d3 100644 --- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java +++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java @@ -54,17 +54,26 @@ public class TestUseRTMLockingOptionOnUnsupportedVM public void runTestCases() throws Throwable { String errorMessage = RTMGenericCommandLineOptionTest.RTM_UNSUPPORTED_VM_ERROR; + String shouldFailMessage = "JVM startup should fail with option " + + "-XX:+UseRTMLocking even on unsupported VM. Error message" + + " should be shown"; + String shouldPassMessage = "JVM startup should pass with option " + + "-XX:-UseRTMLocking even on unsupported VM"; // verify that we can't use +UseRTMLocking CommandLineOptionTest.verifySameJVMStartup( - new String[] { errorMessage }, null, ExitCode.FAIL, - "-XX:+UseRTMLocking"); + new String[] { errorMessage }, null, shouldFailMessage, + shouldFailMessage, ExitCode.FAIL, + "-XX:+UseRTMLocking"); // verify that we can turn it off CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { errorMessage }, ExitCode.OK, + new String[] { errorMessage }, shouldPassMessage, + shouldPassMessage + " without any warnings", ExitCode.OK, "-XX:-UseRTMLocking"); // verify that it is off by default CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", - TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE); + TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE, + String.format("Default value of option 'UseRTMLocking' should" + + " be '%s'", DEFAULT_VALUE)); } public static void main(String args[]) throws Throwable { diff --git a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java index f92dcac36165956b3cf2a4350ad219ea80338cec..ed82aec36c4fdac96d8e8d4a32948d1dd277a170 100644 --- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java +++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java @@ -51,25 +51,44 @@ public class TestUseRTMLockingOptionWithBiasedLocking public void runTestCases() throws Throwable { String warningMessage = RTMGenericCommandLineOptionTest.RTM_BIASED_LOCKING_WARNING; + String shouldPassMessage = "JVM startup should pass with both " + + "-XX:+UseRTMLocking and " + + "-XX:-UseBiasedLocking flags set without any warnings"; // verify that we will not get a warning CommandLineOptionTest.verifySameJVMStartup(null, - new String[] { warningMessage }, ExitCode.OK, + new String[] { warningMessage }, shouldPassMessage, + shouldPassMessage, ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking", "-XX:-UseBiasedLocking"); + // verify that we will get a warning CommandLineOptionTest.verifySameJVMStartup( - new String[] { warningMessage }, null, ExitCode.OK, + new String[] { warningMessage }, null, + "JVM startup should pass when both -XX:+UseRTMLocking and " + + "-XX:+UseBiasedLocking flags set", + "Flags -XX:+UseRTMLocking" + + " and -XX:+UseBiasedLocking conflicts. " + + "Warning should be shown.", ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking", "-XX:+UseBiasedLocking"); // verify that UseBiasedLocking is false when we use rtm locking CommandLineOptionTest.verifyOptionValueForSameVM("UseBiasedLocking", - "false", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, + "false", + "Value of option 'UseBiasedLocking' should be false if" + + "-XX:+UseRTMLocking flag set.", + CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking"); // verify that we can't turn on biased locking when // using rtm locking - CommandLineOptionTest.verifyOptionValueForSameVM("UseBiasedLocking", - "false", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, - "-XX:+UseRTMLocking", "-XX:+UseBiasedLocking"); + CommandLineOptionTest + .verifyOptionValueForSameVM( + "UseBiasedLocking", + "false", + "Value of option 'UseBiasedLocking' should be false if" + + "both -XX:+UseRTMLocking and " + + "-XX:+UseBiasedLocking flags set.", + CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, + "-XX:+UseRTMLocking", "-XX:+UseBiasedLocking"); } public static void main(String args[]) throws Throwable { diff --git a/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java b/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java index 8da6c0264ef1cd6b8a83b34cf12df27c98205193..807a3aba664a68619016e171cacd9754b7310764 100644 --- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java +++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java @@ -49,7 +49,7 @@ public abstract class CommandLineOptionTest { private static final String PRINT_FLAGS_FINAL_FORMAT = "%s\\s*:?=\\s*%s"; /** - * Verifies that JVM startup behaviour matches our expectations. + * Verifies that JVM startup behavior matches our expectations. * * @param option an option that should be passed to JVM * @param expectedMessages an array of patterns that should occur @@ -58,18 +58,24 @@ public abstract class CommandLineOptionTest { * @param unexpectedMessages an array of patterns that should not * occur in JVM output. If {@code null} then * JVM output could be empty. + * @param exitErrorMessage message that will be shown if exit code is not + * as expected. + * @param wrongWarningMessage message that will be shown if warning + * messages are not as expected. * @param exitCode expected exit code. * @throws Throwable if verification fails or some other issues occur. */ public static void verifyJVMStartup(String option, String expectedMessages[], String unexpectedMessages[], + String exitErrorMessage, String wrongWarningMessage, ExitCode exitCode) throws Throwable { CommandLineOptionTest.verifyJVMStartup(expectedMessages, - unexpectedMessages, exitCode, false, option); + unexpectedMessages, exitErrorMessage, + wrongWarningMessage, exitCode, false, option); } /** - * Verifies that JVM startup behaviour matches our expectations. + * Verifies that JVM startup behavior matches our expectations. * * @param expectedMessages an array of patterns that should occur * in JVM output. If {@code null} then @@ -77,6 +83,10 @@ public abstract class CommandLineOptionTest { * @param unexpectedMessages an array of patterns that should not * occur in JVM output. If {@code null} then * JVM output could be empty. + * @param exitErrorMessage message that will be shown if exit code is not + * as expected. + * @param wrongWarningMessage message that will be shown if warning + * messages are not as expected. * @param exitCode expected exit code. * @param addTestVMOptions if {@code true} then test VM options will be * passed to VM. @@ -85,8 +95,10 @@ public abstract class CommandLineOptionTest { * @throws Throwable if verification fails or some other issues occur. */ public static void verifyJVMStartup(String expectedMessages[], - String unexpectedMessages[], ExitCode exitCode, - boolean addTestVMOptions, String... options) throws Throwable { + String unexpectedMessages[], String exitErrorMessage, + String wrongWarningMessage, ExitCode exitCode, + boolean addTestVMOptions, String... options) + throws Throwable { List finalOptions = new ArrayList<>(); if (addTestVMOptions) { Collections.addAll(finalOptions, Utils.getTestJavaOpts()); @@ -99,23 +111,46 @@ public abstract class CommandLineOptionTest { new String[finalOptions.size()])); OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); - outputAnalyzer.shouldHaveExitValue(exitCode.value); + + try { + outputAnalyzer.shouldHaveExitValue(exitCode.value); + } catch (RuntimeException e) { + String errorMessage = String.format( + "JVM process should have exit value '%d'.%n%s", + exitCode.value, exitErrorMessage); + throw new AssertionError(errorMessage, e); + } + if (expectedMessages != null) { for (String expectedMessage : expectedMessages) { - outputAnalyzer.shouldMatch(expectedMessage); + try { + outputAnalyzer.shouldMatch(expectedMessage); + } catch (RuntimeException e) { + String errorMessage = String.format( + "Expected message not found: '%s'.%n%s", + expectedMessage, wrongWarningMessage); + throw new AssertionError(errorMessage, e); + } } } if (unexpectedMessages != null) { for (String unexpectedMessage : unexpectedMessages) { - outputAnalyzer.shouldNotMatch(unexpectedMessage); + try { + outputAnalyzer.shouldNotMatch(unexpectedMessage); + } catch (RuntimeException e) { + String errorMessage = String.format( + "Unexpected message found: '%s'.%n%s", + unexpectedMessage, wrongWarningMessage); + throw new AssertionError(errorMessage, e); + } } } } /** - * Verifies that JVM startup behaviour matches our expectations when type + * Verifies that JVM startup behavior matches our expectations when type * of newly started VM is the same as the type of current. * * @param expectedMessages an array of patterns that should occur @@ -124,20 +159,26 @@ public abstract class CommandLineOptionTest { * @param unexpectedMessages an array of patterns that should not * occur in JVM output. If {@code null} then * JVM output could be empty. + * @param exitErrorMessage Message that will be shown if exit value is not + * as expected. + * @param wrongWarningMessage message that will be shown if warning + * messages are not as expected. * @param exitCode expected exit code. * @param options options that should be passed to VM in addition to mode * flag. * @throws Throwable if verification fails or some other issues occur. */ public static void verifySameJVMStartup(String expectedMessages[], - String unexpectedMessages[], ExitCode exitCode, String... options) - throws Throwable { + String unexpectedMessages[], String exitErrorMessage, + String wrongWarningMessage, ExitCode exitCode, String... options) + throws Throwable { List finalOptions = new ArrayList<>(); finalOptions.add(CommandLineOptionTest.getVMTypeOption()); Collections.addAll(finalOptions, options); CommandLineOptionTest.verifyJVMStartup(expectedMessages, - unexpectedMessages, exitCode, false, + unexpectedMessages, exitErrorMessage, + wrongWarningMessage, exitCode, false, finalOptions.toArray(new String[finalOptions.size()])); } @@ -149,13 +190,17 @@ public abstract class CommandLineOptionTest { * * @param optionName a name of tested option. * @param expectedValue expected value of tested option. + * @param optionErrorString message will be shown if option value is not as + * expected. * @param additionalVMOpts additional options that should be * passed to JVM. * @throws Throwable if verification fails or some other issues occur. */ public static void verifyOptionValue(String optionName, - String expectedValue, String... additionalVMOpts) throws Throwable { - verifyOptionValue(optionName, expectedValue, true, additionalVMOpts); + String expectedValue, String optionErrorString, + String... additionalVMOpts) throws Throwable { + verifyOptionValue(optionName, expectedValue, optionErrorString, + true, additionalVMOpts); } /** @@ -168,14 +213,17 @@ public abstract class CommandLineOptionTest { * @param expectedValue expected value of tested option. * @param addTestVmOptions if {@code true}, then test VM options * will be used. + * @param optionErrorString message will be shown if option value is not as + * expected. * @param additionalVMOpts additional options that should be * passed to JVM. * @throws Throwable if verification fails or some other issues * occur. */ public static void verifyOptionValue(String optionName, - String expectedValue, boolean addTestVmOptions, - String... additionalVMOpts) throws Throwable { + String expectedValue, String optionErrorString, + boolean addTestVmOptions, String... additionalVMOpts) + throws Throwable { List vmOpts = new ArrayList<>(); if (addTestVmOptions) { @@ -191,10 +239,25 @@ public abstract class CommandLineOptionTest { OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); - outputAnalyzer.shouldHaveExitValue(0); + try { + outputAnalyzer.shouldHaveExitValue(0); + } catch (RuntimeException e) { + String errorMessage = String.format( + "JVM should start with option '%s' without errors.", + optionName); + throw new AssertionError(errorMessage, e); + } + try { outputAnalyzer.shouldMatch(String.format( CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT, optionName, expectedValue)); + } catch (RuntimeException e) { + String errorMessage = String.format( + "Option '%s' is expected to have '%s' value%n%s", + optionName, expectedValue, + optionErrorString); + throw new AssertionError(errorMessage, e); + } } /** @@ -207,18 +270,21 @@ public abstract class CommandLineOptionTest { * * @param optionName name of tested option. * @param expectedValue expected value of tested option. + * @param optionErrorString message to show if option has another value * @param additionalVMOpts additional options that should be * passed to JVM. * @throws Throwable if verification fails or some other issues occur. */ public static void verifyOptionValueForSameVM(String optionName, - String expectedValue, String... additionalVMOpts) throws Throwable { + String expectedValue, String optionErrorString, + String... additionalVMOpts) throws Throwable { List finalOptions = new ArrayList<>(); finalOptions.add(CommandLineOptionTest.getVMTypeOption()); Collections.addAll(finalOptions, additionalVMOpts); CommandLineOptionTest.verifyOptionValue(optionName, expectedValue, - false, finalOptions.toArray(new String[finalOptions.size()])); + optionErrorString, false, + finalOptions.toArray(new String[finalOptions.size()])); } /**