37 38 import com.oracle.java.testlibrary.ExitCode; 39 import com.oracle.java.testlibrary.cli.*; 40 import com.oracle.java.testlibrary.cli.predicate.AndPredicate; 41 import com.oracle.java.testlibrary.cli.predicate.NotPredicate; 42 import rtm.predicate.SupportedCPU; 43 import rtm.predicate.SupportedVM; 44 45 public class TestUseRTMLockingOptionOnUnsupportedVM 46 extends CommandLineOptionTest { 47 private static final String DEFAULT_VALUE = "false"; 48 49 private TestUseRTMLockingOptionOnUnsupportedVM() { 50 super(new AndPredicate(new SupportedCPU(), 51 new NotPredicate(new SupportedVM()))); 52 } 53 @Override 54 public void runTestCases() throws Throwable { 55 String errorMessage 56 = RTMGenericCommandLineOptionTest.RTM_UNSUPPORTED_VM_ERROR; 57 // verify that we can't use +UseRTMLocking 58 CommandLineOptionTest.verifySameJVMStartup( 59 new String[] { errorMessage }, null, ExitCode.FAIL, 60 "-XX:+UseRTMLocking"); 61 // verify that we can turn it off 62 CommandLineOptionTest.verifySameJVMStartup(null, 63 new String[] { errorMessage }, ExitCode.OK, 64 "-XX:-UseRTMLocking"); 65 // verify that it is off by default 66 CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", 67 TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE); 68 } 69 70 public static void main(String args[]) throws Throwable { 71 new TestUseRTMLockingOptionOnUnsupportedVM().test(); 72 } 73 } | 37 38 import com.oracle.java.testlibrary.ExitCode; 39 import com.oracle.java.testlibrary.cli.*; 40 import com.oracle.java.testlibrary.cli.predicate.AndPredicate; 41 import com.oracle.java.testlibrary.cli.predicate.NotPredicate; 42 import rtm.predicate.SupportedCPU; 43 import rtm.predicate.SupportedVM; 44 45 public class TestUseRTMLockingOptionOnUnsupportedVM 46 extends CommandLineOptionTest { 47 private static final String DEFAULT_VALUE = "false"; 48 49 private TestUseRTMLockingOptionOnUnsupportedVM() { 50 super(new AndPredicate(new SupportedCPU(), 51 new NotPredicate(new SupportedVM()))); 52 } 53 @Override 54 public void runTestCases() throws Throwable { 55 String errorMessage 56 = RTMGenericCommandLineOptionTest.RTM_UNSUPPORTED_VM_ERROR; 57 String shouldFailMessage = "JVM startup should fail with option " 58 + "-XX:+UseRTMLocking even on unsupported VM. Error message" 59 + " should be shown"; 60 String shouldPassMessage = "JVM startup should pass with option " 61 + "-XX:-UseRTMLocking even on unsupported VM"; 62 // verify that we can't use +UseRTMLocking 63 CommandLineOptionTest.verifySameJVMStartup( 64 new String[] { errorMessage }, null, shouldFailMessage, 65 shouldFailMessage, ExitCode.FAIL, 66 "-XX:+UseRTMLocking"); 67 // verify that we can turn it off 68 CommandLineOptionTest.verifySameJVMStartup(null, 69 new String[] { errorMessage }, shouldPassMessage, 70 shouldPassMessage + " without any warnings", ExitCode.OK, 71 "-XX:-UseRTMLocking"); 72 // verify that it is off by default 73 CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", 74 TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE, 75 String.format("Default value of option 'UseRTMLocking' should" 76 + " be '%s'", DEFAULT_VALUE)); 77 } 78 79 public static void main(String args[]) throws Throwable { 80 new TestUseRTMLockingOptionOnUnsupportedVM().test(); 81 } 82 } |