test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java

Print this page




 104      * @throws Throwable
 105      */
 106     protected void runX86SupportedVMTestCases() throws Throwable {
 107         runGenericX86TestCases();
 108     }
 109 
 110     /**
 111      * Runs test cases on non-X86 CPU if VM does not support RTM locking.
 112      * @throws Throwable
 113      */
 114     protected void runX86UnsupportedVMTestCases() throws Throwable {
 115         runGenericX86TestCases();
 116     }
 117 
 118     /**
 119      * Runs test cases on non-X86 CPU.
 120      * @throws Throwable
 121      */
 122     protected void runNonX86TestCases() throws Throwable {
 123         CommandLineOptionTest.verifySameJVMStartup(
 124                 new String[] { errorMessage }, null, ExitCode.FAIL,


 125                 prepareOptionValue(defaultValue));
 126     }
 127 
 128     /**
 129      * Runs generic X86 test cases.
 130      * @throws Throwable
 131      */
 132     protected void runGenericX86TestCases() throws Throwable {
 133         verifyJVMStartup();
 134         verifyOptionValues();
 135     }
 136 
 137     protected void verifyJVMStartup() throws Throwable {
 138         String optionValue = prepareOptionValue(defaultValue);






 139         if (isExperimental) {
 140             // verify that option is experimental
 141             CommandLineOptionTest.verifySameJVMStartup(
 142                     new String[] { experimentalOptionError },
 143                     new String[] { errorMessage }, ExitCode.FAIL,
 144                     optionValue);
 145             // verify that it could be passed if experimental options
 146             // are unlocked
 147             CommandLineOptionTest.verifySameJVMStartup(null,
 148                     new String[] {
 149                             experimentalOptionError,
 150                             errorMessage
 151                     },


 152                     ExitCode.OK,
 153                     CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
 154                     optionValue);
 155         } else {
 156             // verify that option could be passed
 157             CommandLineOptionTest.verifySameJVMStartup(null,
 158                     new String[]{errorMessage}, ExitCode.OK, optionValue);




 159         }
 160     }
 161 
 162     protected void verifyOptionValues() throws Throwable {
 163         // verify default value
 164         if (isExperimental) {
 165             CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
 166                     defaultValue,


 167                     CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
 168         } else {
 169             CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
 170                     defaultValue);


 171         }
 172         // verify other specified option values
 173         if (optionValues == null) {
 174             return;
 175         }
 176 
 177         for (String value : optionValues) {
 178             if (isExperimental) {
 179                 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
 180                         value,


 181                         CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
 182                         prepareOptionValue(value));
 183             } else {
 184                 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
 185                         value, prepareOptionValue(value));


 186             }
 187         }
 188     }
 189 
 190     protected String prepareOptionValue(String value) {
 191         if (isBoolean) {
 192             return CommandLineOptionTest.prepareBooleanFlag(optionName,
 193                     Boolean.valueOf(value));
 194         } else {
 195             return String.format("-XX:%s=%s", optionName, value);
 196         }
 197     }
 198 }


 104      * @throws Throwable
 105      */
 106     protected void runX86SupportedVMTestCases() throws Throwable {
 107         runGenericX86TestCases();
 108     }
 109 
 110     /**
 111      * Runs test cases on non-X86 CPU if VM does not support RTM locking.
 112      * @throws Throwable
 113      */
 114     protected void runX86UnsupportedVMTestCases() throws Throwable {
 115         runGenericX86TestCases();
 116     }
 117 
 118     /**
 119      * Runs test cases on non-X86 CPU.
 120      * @throws Throwable
 121      */
 122     protected void runNonX86TestCases() throws Throwable {
 123         CommandLineOptionTest.verifySameJVMStartup(
 124                 new String[] { errorMessage }, null, 
 125                 String.format("Option '%s' should be unknown on non-X86CPUs.%n"
 126                 + "JVM startup should fail", optionName), "", ExitCode.FAIL,              
 127                 prepareOptionValue(defaultValue));
 128     }
 129 
 130     /**
 131      * Runs generic X86 test cases.
 132      * @throws Throwable
 133      */
 134     protected void runGenericX86TestCases() throws Throwable {
 135         verifyJVMStartup();
 136         verifyOptionValues();
 137     }
 138 
 139     protected void verifyJVMStartup() throws Throwable {
 140         String optionValue = prepareOptionValue(defaultValue);
 141         String shouldFailMessage = String.format("VM option '%s' is "
 142                 + "experimental.%nVM startup expected to fail without "
 143                 + "-XX:+UnlockExperimentalVMOptions option", optionName);
 144         String shouldPassMessage = String.format("VM option '%s' is "
 145                 + "experimental%nVM startup should pass with "
 146                 + "-XX:+UnlockExperimentalVMOptions option", optionName);
 147         if (isExperimental) {
 148             // verify that option is experimental
 149             CommandLineOptionTest.verifySameJVMStartup(
 150                     new String[] { experimentalOptionError },
 151                     new String[] { errorMessage }, shouldFailMessage,
 152                     shouldFailMessage, ExitCode.FAIL, optionValue);
 153             // verify that it could be passed if experimental options
 154             // are unlocked
 155             CommandLineOptionTest.verifySameJVMStartup(null,
 156                     new String[] {
 157                             experimentalOptionError,
 158                             errorMessage
 159                     },
 160                     shouldPassMessage,
 161                     "JVM should start without any warnings or errors",
 162                     ExitCode.OK, 
 163                     CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
 164                     optionValue);
 165         } else {
 166             // verify that option could be passed
 167             CommandLineOptionTest.verifySameJVMStartup(null,
 168                     new String[]{errorMessage},
 169                     String.format("VM startup shuld pass with '%s' option",
 170                             optionName),
 171                     "JVM should start without any warnings or errors",                    
 172                     ExitCode.OK, optionValue);
 173         }
 174     }
 175 
 176     protected void verifyOptionValues() throws Throwable {
 177         // verify default value
 178         if (isExperimental) {
 179             CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
 180                     defaultValue, 
 181                     String.format("Option '%s' is expected to have '%s' "
 182                             + "default value", optionName, defaultValue),
 183                     CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
 184         } else {
 185             CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
 186                     defaultValue,
 187                     String.format("Option '%s' is expected to have '%s' "
 188                             + "default value", optionName, defaultValue));
 189         }
 190         // verify other specified option values
 191         if (optionValues == null) {
 192             return;
 193         }
 194 
 195         for (String value : optionValues) {
 196             if (isExperimental) {
 197                 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
 198                         value, 
 199                         String.format("Option '%s' is set to have '%s' value",
 200                                 optionName, value),
 201                         CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
 202                         prepareOptionValue(value));
 203             } else {
 204                 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
 205                         value, 
 206                         String.format("Option '%s' is set to have '%s' value",
 207                                 optionName, value), prepareOptionValue(value));
 208             }
 209         }
 210     }
 211 
 212     protected String prepareOptionValue(String value) {
 213         if (isBoolean) {
 214             return CommandLineOptionTest.prepareBooleanFlag(optionName,
 215                     Boolean.valueOf(value));
 216         } else {
 217             return String.format("-XX:%s=%s", optionName, value);
 218         }
 219     }
 220 }