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 24 package compiler.rtm.cli; 25 26 import jdk.test.lib.process.ExitCode; 27 import jdk.test.lib.Platform; 28 import jdk.test.lib.cli.CommandLineOptionTest; 29 30 import java.util.function.BooleanSupplier; 31 32 /** 33 * Base for all RTM-related CLI tests. 34 */ 35 public abstract class RTMGenericCommandLineOptionTest 36 extends CommandLineOptionTest { 37 protected static final String RTM_INSTR_ERROR 38 = "RTM instructions are not available on this CPU"; 39 protected static final String RTM_UNSUPPORTED_VM_ERROR 40 = "RTM locking optimization is not supported in this VM"; 41 protected static final String RTM_ABORT_RATIO_WARNING 42 = "RTMAbortRatio must be in the range 0 to 100, resetting it to 50"; 43 protected static final String RTM_FOR_STACK_LOCKS_WARNING 44 = "UseRTMForStackLocks flag should be off when UseRTMLocking " 45 + "flag is off"; 46 protected static final String RTM_COUNT_INCR_WARNING 47 = "RTMTotalCountIncrRate must be a power of 2, resetting it to 64"; 48 protected static final String RTM_BIASED_LOCKING_WARNING 49 = "Biased locking is not supported with RTM locking; " 50 + "ignoring UseBiasedLocking flag"; 51 52 protected final String optionName; 53 protected final String errorMessage; 54 protected final String experimentalOptionError; 55 protected final boolean isExperimental; 56 protected final boolean isBoolean; 57 protected final String defaultValue; 58 protected final String[] optionValues; 59 60 /** 61 * Constructs new genetic RTM CLI test, for option {@code optionName} which 62 * has default value {@code defaultValue}. Test cases will use option's 63 * values passed via {@code optionValues} for verification of correct 64 * option processing. 65 * 66 * Test constructed using this ctor will be started on any cpu regardless 67 * it's architecture and supported/unsupported features. 68 * 69 * @param predicate predicate responsible for test's preconditions check 70 * @param optionName name of option to be tested 71 * @param isBoolean {@code true} if option is binary 72 * @param isExperimental {@code true} if option is experimental 73 * @param defaultValue default value of tested option 74 * @param optionValues different option values 75 */ 76 public RTMGenericCommandLineOptionTest(BooleanSupplier predicate, 77 String optionName, boolean isBoolean, boolean isExperimental, 78 String defaultValue, String... optionValues) { 79 super(predicate); 80 this.optionName = optionName; 81 this.isExperimental = isExperimental; 82 this.isBoolean = isBoolean; 83 this.defaultValue = defaultValue; 84 this.optionValues = optionValues; 85 this.errorMessage = CommandLineOptionTest. 86 getUnrecognizedOptionErrorMessage(optionName); 87 this.experimentalOptionError = CommandLineOptionTest. 88 getExperimentalOptionErrorMessage(optionName); 89 } 90 91 @Override 92 public void runTestCases() throws Throwable { 93 if (Platform.isX86() || Platform.isX64() || Platform.isPPC()) { 94 if (Platform.isServer()) { 95 runX86SupportedVMTestCases(); 96 } else { 97 runX86UnsupportedVMTestCases(); 98 } 99 } else { 100 runNonX86TestCases(); 101 } 102 } 103 104 /** 105 * Runs test cases on X86 CPU if VM supports RTM locking. 106 * @throws Throwable 107 */ 108 protected void runX86SupportedVMTestCases() throws Throwable { 109 runGenericX86TestCases(); 110 } 111 | 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 24 package compiler.rtm.cli; 25 26 import jdk.test.lib.process.ExitCode; 27 import jdk.test.lib.Platform; 28 import jdk.test.lib.cli.CommandLineOptionTest; 29 30 import java.util.function.BooleanSupplier; 31 32 /** 33 * Base for all RTM-related CLI tests. 34 */ 35 public abstract class RTMGenericCommandLineOptionTest { 36 37 protected static final String RTM_INSTR_ERROR 38 = "RTM instructions are not available on this CPU"; 39 protected static final String RTM_UNSUPPORTED_VM_ERROR 40 = "RTM locking optimization is not supported in this VM"; 41 protected static final String RTM_ABORT_RATIO_WARNING 42 = "RTMAbortRatio must be in the range 0 to 100, resetting it to 50"; 43 protected static final String RTM_FOR_STACK_LOCKS_WARNING 44 = "UseRTMForStackLocks flag should be off when UseRTMLocking " 45 + "flag is off"; 46 protected static final String RTM_COUNT_INCR_WARNING 47 = "RTMTotalCountIncrRate must be a power of 2, resetting it to 64"; 48 protected static final String RTM_BIASED_LOCKING_WARNING 49 = "Biased locking is not supported with RTM locking; " 50 + "ignoring UseBiasedLocking flag"; 51 52 protected final String optionName; 53 protected final String errorMessage; 54 protected final String experimentalOptionError; 55 protected final boolean isExperimental; 56 protected final boolean isBoolean; 57 protected final String defaultValue; 58 protected final String[] optionValues; 59 60 /** 61 * Constructs new genetic RTM CLI test, for option {@code optionName} which 62 * has default value {@code defaultValue}. Test cases will use option's 63 * values passed via {@code optionValues} for verification of correct 64 * option processing. 65 * 66 * Test constructed using this ctor will be started on any cpu regardless 67 * it's architecture and supported/unsupported features. 68 * 69 * @param optionName name of option to be tested 70 * @param isBoolean {@code true} if option is binary 71 * @param isExperimental {@code true} if option is experimental 72 * @param defaultValue default value of tested option 73 * @param optionValues different option values 74 */ 75 public RTMGenericCommandLineOptionTest( 76 String optionName, boolean isBoolean, boolean isExperimental, 77 String defaultValue, String... optionValues) { 78 this.optionName = optionName; 79 this.isExperimental = isExperimental; 80 this.isBoolean = isBoolean; 81 this.defaultValue = defaultValue; 82 this.optionValues = optionValues; 83 this.errorMessage = CommandLineOptionTest. 84 getUnrecognizedOptionErrorMessage(optionName); 85 this.experimentalOptionError = CommandLineOptionTest. 86 getExperimentalOptionErrorMessage(optionName); 87 } 88 89 public void runTestCases() throws Throwable { 90 if (Platform.isX86() || Platform.isX64() || Platform.isPPC()) { 91 if (Platform.isServer()) { 92 runX86SupportedVMTestCases(); 93 } else { 94 runX86UnsupportedVMTestCases(); 95 } 96 } else { 97 runNonX86TestCases(); 98 } 99 } 100 101 /** 102 * Runs test cases on X86 CPU if VM supports RTM locking. 103 * @throws Throwable 104 */ 105 protected void runX86SupportedVMTestCases() throws Throwable { 106 runGenericX86TestCases(); 107 } 108 |