30 public abstract class TestPrintPreciseRTMLockingStatisticsBase 31 extends RTMGenericCommandLineOptionTest { 32 protected static final String DEFAULT_VALUE = "false"; 33 34 protected TestPrintPreciseRTMLockingStatisticsBase( 35 BooleanSupplier predicate) { 36 super(predicate, "PrintPreciseRTMLockingStatistics", true, false, 37 TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE); 38 } 39 40 @Override 41 protected void runNonX86TestCases() throws Throwable { 42 verifyJVMStartup(); 43 verifyOptionValues(); 44 } 45 46 @Override 47 protected void verifyJVMStartup() throws Throwable { 48 if (Platform.isServer()) { 49 if (!Platform.isDebugBuild()) { 50 String errorMessage = CommandLineOptionTest. 51 getDiagnosticOptionErrorMessage(optionName); 52 // verify that option is actually diagnostic 53 CommandLineOptionTest.verifySameJVMStartup( 54 new String[] { errorMessage }, null, ExitCode.FAIL, 55 prepareOptionValue("true")); 56 57 CommandLineOptionTest.verifySameJVMStartup(null, 58 new String[] { errorMessage }, ExitCode.OK, 59 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, 60 prepareOptionValue("true")); 61 } else { 62 CommandLineOptionTest.verifySameJVMStartup( 63 null, null, ExitCode.OK, prepareOptionValue("true")); 64 } 65 } else { 66 String errorMessage = CommandLineOptionTest. 67 getUnrecognizedOptionErrorMessage(optionName); 68 69 CommandLineOptionTest.verifySameJVMStartup( 70 new String[]{errorMessage}, null, ExitCode.FAIL, 71 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, 72 prepareOptionValue("true")); 73 } 74 } 75 76 @Override 77 protected void verifyOptionValues() throws Throwable { 78 if (Platform.isServer()) { 79 // Verify default value 80 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, 81 TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE, 82 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS); 83 } 84 } 85 } | 30 public abstract class TestPrintPreciseRTMLockingStatisticsBase 31 extends RTMGenericCommandLineOptionTest { 32 protected static final String DEFAULT_VALUE = "false"; 33 34 protected TestPrintPreciseRTMLockingStatisticsBase( 35 BooleanSupplier predicate) { 36 super(predicate, "PrintPreciseRTMLockingStatistics", true, false, 37 TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE); 38 } 39 40 @Override 41 protected void runNonX86TestCases() throws Throwable { 42 verifyJVMStartup(); 43 verifyOptionValues(); 44 } 45 46 @Override 47 protected void verifyJVMStartup() throws Throwable { 48 if (Platform.isServer()) { 49 if (!Platform.isDebugBuild()) { 50 String shouldFailMessage = String.format("VM option '%s' is " 51 + "diagnostic%nJVM startup should fail without " 52 + "-XX:\\+UnlockDiagnosticVMOptions flag", optionName); 53 String shouldPassMessage = String.format("VM option '%s' is " 54 + "diagnostic%nJVM startup should pass with " 55 + "-XX:\\+UnlockDiagnosticVMOptions in debug build", 56 optionName); 57 String errorMessage = CommandLineOptionTest. 58 getDiagnosticOptionErrorMessage(optionName); 59 // verify that option is actually diagnostic 60 CommandLineOptionTest.verifySameJVMStartup( 61 new String[] { errorMessage }, null, shouldFailMessage, 62 shouldFailMessage, ExitCode.FAIL, 63 prepareOptionValue("true")); 64 65 CommandLineOptionTest.verifySameJVMStartup(null, 66 new String[] { errorMessage }, shouldPassMessage, 67 shouldPassMessage + "without any warnings", ExitCode.OK, 68 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, 69 prepareOptionValue("true")); 70 } else { 71 String shouldPassMessage = String.format("JVM startup should " 72 + "pass with '%s' option in debug build", 73 optionName); 74 CommandLineOptionTest.verifySameJVMStartup(null, null, 75 shouldPassMessage, shouldPassMessage, 76 ExitCode.OK, prepareOptionValue("true")); 77 } 78 } else { 79 String errorMessage = CommandLineOptionTest. 80 getUnrecognizedOptionErrorMessage(optionName); 81 String shouldFailMessage = String.format("JVM startup should fail" 82 + " with '%s' option in not debug build", optionName); 83 CommandLineOptionTest.verifySameJVMStartup( 84 new String[]{errorMessage}, null, shouldFailMessage, 85 shouldFailMessage, ExitCode.FAIL, 86 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, 87 prepareOptionValue("true")); 88 } 89 } 90 91 @Override 92 protected void verifyOptionValues() throws Throwable { 93 if (Platform.isServer()) { 94 // Verify default value 95 CommandLineOptionTest.verifyOptionValueForSameVM(optionName, 96 TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE, 97 String.format("Option '%s' should have '%s' default value", 98 optionName, 99 TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE), 100 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS); 101 } 102 } 103 } |