jdk.test.lib.cli.CommandLineOptionTest.verifySameJVMStartup() - java examples

Here are the examples of the java api jdk.test.lib.cli.CommandLineOptionTest.verifySameJVMStartup() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

32 Examples 7

18 View Complete Implementation : BMIUnsupportedCPUTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Run test cases common for all bit manipulation related VM options
 * targeted to X86 CPU that does not support required features.
 *
 * @throws Throwable if test failed.
 */
public void unsupportedX86CPUTestCases() throws Throwable {
    /*
          Verify that VM will successfully start up, but output will contain a
          warning. VM will be launched with following options:
          -XX:+<tested option> -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 }, errorString, String.format("Option '%s' is unsupported.%n" + "Warning expected to be shown.", optionName), ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, true));
    /*
          Verify that VM will successfully startup without any warnings.
          VM will be launched with following options:
          -XX:-<tested option> -version
        */
    errorString = String.format("JVM should start with '-XX:-%s' flag " + "without any warnings", optionName);
    CommandLineOptionTest.verifySameJVMStartup(null, 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", 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
          it was explicitly turned on by user. VM will be launched with
          following options: -XX:+<tested option> -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));
}

18 View Complete Implementation : BMIUnsupportedCPUTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Run test cases common for all bit manipulation related VM options
 * targeted to non-X86 CPU that does not support required features.
 *
 * @throws Throwable if test failed.
 */
public void unsupportedNonX86CPUTestCases() throws Throwable {
    /*
          Verify that VM known nothing about tested option. VM will be launched
          with following options: -XX:[+-]<tested option> -version
        */
    CommandLineOptionTest.verifySameJVMStartup(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, String.format("JVM startup should fail with '-XX:-%s' flag." + "%nOption should be unknown (non-X86CPU)", optionName), "", ExitCode.FAIL, CommandLineOptionTest.prepareBooleanFlag(optionName, false));
}

18 View Complete Implementation : JVMStartupRunner.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public void run(CodeCachereplacedestCase.Description testCaseDescription, CodeCacheOptions options) throws Throwable {
    // Everything should be fine when
    // sum(all code heap sizes) == reserved CC size
    CommandLineOptionTest.verifySameJVMStartup(/* expected messages */
    null, new String[] { INCONSISTENT_CH_SIZES_ERROR }, "JVM startup should not fail with consistent code heap sizes", "JVM output should not contain warning about inconsistent code " + "heap sizes", ExitCode.OK, options.prepareOptions());
    verifySingleInconsistentValue(options);
    verifyAllInconsistentValues(options);
}

18 View Complete Implementation : UseSHASpecificTestCaseForUnsupportedCPU.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected void verifyWarnings() throws Throwable {
    // Verify that attempt to use UseSHA option will cause a warning.
    String shouldPreplacedMessage = String.format("JVM startup should preplaced with" + " '%s' option on unsupported CPU, but there should be" + "the message shown.", optionName);
    CommandLineOptionTest.verifySameJVMStartup(new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, null, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, true));
}

18 View Complete Implementation : RTMGenericCommandLineOptionTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
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 shouldPreplacedMessage = String.format("VM option '%s' is " + "experimental%nVM startup should preplaced with " + "-XX:+UnlockExperimentalVMOptions option", optionName);
    if (isExperimental) {
        // verify that option is experimental
        CommandLineOptionTest.verifySameJVMStartup(new String[] { experimentalOptionError }, new String[] { errorMessage }, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, optionValue);
        // verify that it could be preplaceded if experimental options
        // are unlocked
        CommandLineOptionTest.verifySameJVMStartup(null, new String[] { experimentalOptionError, errorMessage }, shouldPreplacedMessage, "JVM should start without any warnings or errors", ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, optionValue);
    } else {
        // verify that option could be preplaceded
        CommandLineOptionTest.verifySameJVMStartup(null, new String[] { errorMessage }, String.format("VM startup shuld preplaced with '%s' option", optionName), "JVM should start without any warnings or errors", ExitCode.OK, optionValue);
    }
}

18 View Complete Implementation : RTMGenericCommandLineOptionTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Runs test cases on non-X86 CPU.
 * @throws Throwable
 */
protected void runNonX86TestCases() throws Throwable {
    CommandLineOptionTest.verifySameJVMStartup(new String[] { errorMessage }, null, String.format("Option '%s' should be unknown on non-X86CPUs.%n" + "JVM startup should fail", optionName), "", ExitCode.FAIL, prepareOptionValue(defaultValue));
}

17 View Complete Implementation : BMISupportedCPUTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public void runTestCases() throws Throwable {
    /*
          Verify that VM will successfully start up without warnings.
          VM will be launched with following flags:
          -XX:+<tested option> -version
        */
    String errorString = String.format("JVM should start with '-XX:+%s'" + " flag without any warnings", optionName);
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { warningMessage }, errorString, errorString, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, true));
    /*
          Verify that VM will successfully start up without warnings.
          VM will be launched with following flags:
          -XX:-<tested option> -version
        */
    errorString = String.format("JVM should start with '-XX:-%s'" + " flag without any warnings", optionName);
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { warningMessage }, errorString, errorString, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, false));
    /*
          Verify that on appropriate CPU option in on by default.
          VM will be launched with following flags:
          -version
        */
    CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", String.format("Option '%s' is expected to have default value " + "'true'", optionName));
    /*
          Verify that option could be explicitly turned off.
          VM will be launched with following flags:
          -XX:-<tested option> -version
        */
    CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' is set to have value 'false'", optionName), CommandLineOptionTest.prepareBooleanFlag(optionName, false));
}

17 View Complete Implementation : JVMStartupRunner.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private static void verifyHeapSizesSum(long reserved, long profiled, long nonProfiled, long nonNmethods) throws Throwable {
    // JVM startup expected to fail when
    // sum(all code heap sizes) != reserved CC size
    CommandLineOptionTest.verifySameJVMStartup(new String[] { INCONSISTENT_CH_SIZES_ERROR }, /* unexpected messages */
    null, "JVM startup should fail with inconsistent code heap size.", "JVM output should contain appropriate error message of code " + "heap sizes are inconsistent", ExitCode.FAIL, CommandLineOptionTest.prepareBooleanFlag(CodeCacheOptions.SEGMENTED_CODE_CACHE, true), CommandLineOptionTest.prepareNumericFlag(BlobType.All.sizeOptionName, reserved), CommandLineOptionTest.prepareNumericFlag(BlobType.MethodProfiled.sizeOptionName, profiled), CommandLineOptionTest.prepareNumericFlag(BlobType.MethodNonProfiled.sizeOptionName, nonProfiled), CommandLineOptionTest.prepareNumericFlag(BlobType.NonNMethod.sizeOptionName, nonNmethods));
}

17 View Complete Implementation : GenericTestCaseForOtherCPU.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected void verifyWarnings() throws Throwable {
    String shouldPreplacedMessage = String.format("JVM should start with " + "option '%s' without any warnings", optionName);
    // Verify that on non-x86, non-SPARC and non-AArch64 CPU usage of
    // SHA-related options will not cause any warnings.
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { ".*" + optionName + ".*" }, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true));
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { ".*" + optionName + ".*" }, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false));
}

17 View Complete Implementation : UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected void verifyWarnings() throws Throwable {
    String shouldPreplacedMessage = 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, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true));
}

17 View Complete Implementation : RTMLockingAwareTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private void verifyStartupWarning(String value, boolean useRTMLocking, boolean isWarningExpected) throws Throwable {
    String[] warnings = new String[] { warningMessage };
    List<String> options = new LinkedList<>();
    options.add(CommandLineOptionTest.prepareBooleanFlag("UseRTMLocking", useRTMLocking));
    if (isExperimental) {
        options.add(CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
    }
    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), errorString, errorString, ExitCode.OK, options.toArray(new String[options.size()]));
}

17 View Complete Implementation : TestUseRTMDeoptOptionOnSupportedConfig.java
Copyright GNU General Public License v2.0
Author : hzio
public void runTestCases() throws Throwable {
    String shouldPreplacedMessage = " JVM should startup with option '" + "-XX:+UseRTMDeopt' without any warnings";
    // verify that option could be turned on
    CommandLineOptionTest.verifySameJVMStartup(null, null, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, "-XX:+UseRTMDeopt");
    shouldPreplacedMessage = " JVM should startup with option '" + "-XX:-UseRTMDeopt' without any warnings";
    // verify that option could be turned off
    CommandLineOptionTest.verifySameJVMStartup(null, null, shouldPreplacedMessage, shouldPreplacedMessage, 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, 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", "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");
}

17 View Complete Implementation : TestUseRTMLockingOptionWithBiasedLocking.java
Copyright GNU General Public License v2.0
Author : hzio
public void runTestCases() throws Throwable {
    String warningMessage = RTMGenericCommandLineOptionTest.RTM_BIASED_LOCKING_WARNING;
    String shouldPreplacedMessage = "JVM startup should preplaced 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 }, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking", "-XX:-UseBiasedLocking");
    // verify that we will get a warning
    CommandLineOptionTest.verifySameJVMStartup(new String[] { warningMessage }, null, "JVM startup should preplaced 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", "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", "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");
}

16 View Complete Implementation : CodeCacheFreeSpaceRunner.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public void run(CodeCachereplacedestCase.Description testCaseDescription, CodeCacheOptions options) throws Throwable {
    long ccMinUseSpace = ((options.nonNmethods - 1) / MULTIPLIER + 1);
    String exitCodeErrorMessage = String.format("JVM startup should fail " + "if %s's value lower then %s.", BlobType.NonNMethod.sizeOptionName, CC_MIN_USE_SPACE);
    String vmOutputErrorMessage = String.format("JVM's output should " + "contain appropriate error message when %s lower " + "then %s.", BlobType.NonNMethod.sizeOptionName, CC_MIN_USE_SPACE);
    CommandLineOptionTest.verifySameJVMStartup(new String[] { TOO_SMALL_NMETHOD_CH_ERROR }, /* unexpected messages */
    null, exitCodeErrorMessage, vmOutputErrorMessage, ExitCode.FAIL, testCaseDescription.getTestOptions(options, CommandLineOptionTest.prepareNumericFlag(CC_MIN_USE_SPACE, ccMinUseSpace + 1)));
}

16 View Complete Implementation : PrintCodeCacheRunner.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public void run(CodeCachereplacedestCase.Description testCaseDescription, CodeCacheOptions options) throws Throwable {
    CodeCacheOptions expectedValues = testCaseDescription.expectedValues(options);
    String[] expectedMessages = testCaseDescription.involvedCodeHeaps.stream().map(heap -> CodeCacheInfoFormatter.forHeap(heap).withSize(expectedValues.sizeForHeap(heap))).map(CodeCacheInfoFormatter::getInfoString).toArray(String[]::new);
    EnumSet<BlobType> unexpectedHeapsSet = EnumSet.complementOf(testCaseDescription.involvedCodeHeaps);
    String[] unexpectedMessages = CodeCacheInfoFormatter.forHeaps(unexpectedHeapsSet.toArray(new BlobType[unexpectedHeapsSet.size()]));
    String description = String.format("JVM output should contain entries " + "for following code heaps: [%s] and should not contain " + "entries for following code heaps: [%s].", testCaseDescription.involvedCodeHeaps.stream().map(BlobType::name).collect(Collectors.joining(", ")), unexpectedHeapsSet.stream().map(BlobType::name).collect(Collectors.joining(", ")));
    CommandLineOptionTest.verifySameJVMStartup(expectedMessages, unexpectedMessages, "JVM startup failure is not expected, " + "since all options have allowed values", description, ExitCode.OK, testCaseDescription.getTestOptions(options, CommandLineOptionTest.prepareBooleanFlag("PrintCodeCache", printCodeCache), // Do not use large pages to avoid large page
    // alignment of code heaps affecting their size.
    "-XX:-UseLargePages"));
}

16 View Complete Implementation : GenericTestCaseForSupportedCPU.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected void verifyWarnings() throws Throwable {
    String shouldPreplacedMessage = 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) }, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true));
    // Verify that option could be disabled even if +UseSHA was preplaceded to
    // JVM.
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, shouldPreplacedMessage, String.format("It should be able to " + "disable option '%s' even if %s was preplaceded to JVM", optionName, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, true)), ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, true), CommandLineOptionTest.prepareBooleanFlag(optionName, false));
    if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
        // Verify that if -XX:-UseSHA is preplaceded to the JVM, it is not possible
        // to enable the tested option and a warning is printed.
        CommandLineOptionTest.verifySameJVMStartup(new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, null, shouldPreplacedMessage, String.format("Enabling option '%s' should not be possible and should result in a warning if %s was preplaceded to JVM", optionName, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false)), ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(optionName, true));
    }
}

16 View Complete Implementation : GenericTestCaseForUnsupportedAArch64CPU.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected void verifyWarnings() throws Throwable {
    String shouldPreplacedMessage = String.format("JVM startup should preplaced 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) }, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false));
    shouldPreplacedMessage = String.format("If JVM is started with '-XX:-" + "%s' '-XX:+%s', output should contain warning.", SHAOptionsBase.USE_SHA_OPTION, optionName);
    // Verify that when the tested option is enabled, then
    // a warning will occur in VM output if UseSHA is disabled.
    if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
        CommandLineOptionTest.verifySameJVMStartup(new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, null, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(optionName, true));
    }
}

16 View Complete Implementation : GenericTestCaseForUnsupportedSparcCPU.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected void verifyWarnings() throws Throwable {
    String shouldPreplacedMessage = String.format("JVM startup should preplaced 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) }, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false));
    // Verify that when the tested option is enabled, then
    // a warning will occur in VM output if UseSHA is disabled.
    if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
        CommandLineOptionTest.verifySameJVMStartup(new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, null, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(optionName, true));
    }
}

16 View Complete Implementation : GenericTestCaseForUnsupportedX86CPU.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected void verifyWarnings() throws Throwable {
    String shouldPreplacedMessage = 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) }, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false));
    // Verify that when the tested option is enabled, then
    // a warning will occur in VM output if UseSHA is disabled.
    if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) {
        CommandLineOptionTest.verifySameJVMStartup(new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, null, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(optionName, true));
    }
}

16 View Complete Implementation : TestUseRTMDeoptOptionOnSupportedConfig.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public void runTestCases() throws Throwable {
    String shouldPreplacedMessage = " JVM should startup with option '" + "-XX:+UseRTMDeopt' without any warnings";
    // verify that option could be turned on
    CommandLineOptionTest.verifySameJVMStartup(null, null, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, "-XX:+UseRTMDeopt");
    shouldPreplacedMessage = " JVM should startup with option '" + "-XX:-UseRTMDeopt' without any warnings";
    // verify that option could be turned off
    CommandLineOptionTest.verifySameJVMStartup(null, null, shouldPreplacedMessage, shouldPreplacedMessage, 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, 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", "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");
}

16 View Complete Implementation : TestUseRTMLockingOptionWithBiasedLocking.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public void runTestCases() throws Throwable {
    String warningMessage = RTMGenericCommandLineOptionTest.RTM_BIASED_LOCKING_WARNING;
    String shouldPreplacedMessage = "JVM startup should preplaced 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 }, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking", "-XX:-UseBiasedLocking");
    // verify that we will get a warning
    CommandLineOptionTest.verifySameJVMStartup(new String[] { warningMessage }, null, "JVM startup should preplaced 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", "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", "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");
}

16 View Complete Implementation : TestUseRTMLockingOptionOnSupportedConfig.java
Copyright GNU General Public License v2.0
Author : hzio
public void runTestCases() throws Throwable {
    String unrecongnizedOption = CommandLineOptionTest.getUnrecognizedOptionErrorMessage("UseRTMLocking");
    String shouldPreplacedMessage = "VM option 'UseRTMLocking' is experimental" + "%nJVM startup should preplaced 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 }, shouldPreplacedMessage, "There should not be any warning when use" + "with -XX:+UnlockExperimentalVMOptions", ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking");
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR, unrecongnizedOption }, shouldPreplacedMessage, "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", "Value of 'UseRTMLocking' should be set " + "to 'true' if -XX:+UseRTMLocking flag set", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking");
}

15 View Complete Implementation : TestUseRTMForStackLocksOptionOnUnsupportedConfig.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@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, shouldFailMessage, shouldFailMessage + "%nError message " + "should be shown", ExitCode.FAIL, prepareOptionValue("true"));
    CommandLineOptionTest.verifySameJVMStartup(new String[] { experimentalOptionError }, null, shouldFailMessage, shouldFailMessage + "%nError message " + "should be shown", ExitCode.FAIL, prepareOptionValue("false"));
    String shouldPreplacedMessage = String.format("VM option '%s' is " + " experimental%nJVM startup should preplaced 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, shouldPreplacedMessage, "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"));
}

15 View Complete Implementation : TestUseRTMLockingOptionOnSupportedConfig.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public void runTestCases() throws Throwable {
    String unrecongnizedOption = CommandLineOptionTest.getUnrecognizedOptionErrorMessage("UseRTMLocking");
    String shouldPreplacedMessage = "VM option 'UseRTMLocking' is experimental" + "%nJVM startup should preplaced 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 }, shouldPreplacedMessage, "There should not be any warning when use" + "with -XX:+UnlockExperimentalVMOptions", ExitCode.OK, CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking");
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR, unrecongnizedOption }, shouldPreplacedMessage, "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", "Value of 'UseRTMLocking' should be set " + "to 'true' if -XX:+UseRTMLocking flag set", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, "-XX:+UseRTMLocking");
}

15 View Complete Implementation : TestUseRTMForStackLocksOptionOnSupportedConfig.java
Copyright GNU General Public License v2.0
Author : hzio
public void runTestCases() throws Throwable {
    String errorMessage = CommandLineOptionTest.getExperimentalOptionErrorMessage("UseRTMForStackLocks");
    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, shouldFailMessage, shouldFailMessage + "%nError message expected", ExitCode.FAIL, "-XX:+UseRTMForStackLocks");
    String shouldPreplacedMessage = " VM option 'UseRTMForStackLocks'" + " is experimental%nJVM startup should preplaced 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, shouldPreplacedMessage, "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 }, shouldPreplacedMessage, "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 }, shouldPreplacedMessage, "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", "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");
}

15 View Complete Implementation : TestUseRTMLockingOptionOnUnsupportedCPU.java
Copyright GNU General Public License v2.0
Author : hzio
public void runTestCases() throws Throwable {
    String unrecongnizedOption = CommandLineOptionTest.getUnrecognizedOptionErrorMessage("UseRTMLocking");
    String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR;
    if (Platform.isX86() || Platform.isX64() || Platform.isPPC()) {
        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 }, shouldFailMessage, shouldFailMessage + ". Error message should be shown", ExitCode.FAIL, "-XX:+UseRTMLocking");
        String shouldPreplacedMessage = "JVM startup should preplaced with option " + "-XX:-UseRTMLocking even on unsupported CPU";
        // verify that we can preplaced -UseRTMLocking without
        // getting any error messages
        CommandLineOptionTest.verifySameJVMStartup(null, new String[] { errorMessage, unrecongnizedOption }, shouldPreplacedMessage, shouldPreplacedMessage + " without any warnings", ExitCode.OK, "-XX:-UseRTMLocking");
        // verify that UseRTMLocking is false by default
        CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", 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, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, "-XX:+UseRTMLocking");
        CommandLineOptionTest.verifySameJVMStartup(new String[] { unrecongnizedOption }, null, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, "-XX:-UseRTMLocking");
    }
}

15 View Complete Implementation : TestUseRTMLockingOptionOnUnsupportedVM.java
Copyright GNU General Public License v2.0
Author : hzio
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 shouldPreplacedMessage = "JVM startup should preplaced with option " + "-XX:-UseRTMLocking even on unsupported VM";
    // verify that we can't use +UseRTMLocking
    CommandLineOptionTest.verifySameJVMStartup(new String[] { errorMessage }, null, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, "-XX:+UseRTMLocking");
    // verify that we can turn it off
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { errorMessage }, shouldPreplacedMessage, shouldPreplacedMessage + " without any warnings", ExitCode.OK, "-XX:-UseRTMLocking");
    // verify that it is off by default
    CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE, String.format("Default value of option 'UseRTMLocking' should" + " be '%s'", DEFAULT_VALUE));
}

14 View Complete Implementation : TestPrintPreciseRTMLockingStatisticsBase.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
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 shouldPreplacedMessage = String.format("VM option '%s' is " + "diagnostic%nJVM startup should preplaced with " + "-XX:\\+UnlockDiagnosticVMOptions in debug build", optionName);
            String errorMessage = CommandLineOptionTest.getDiagnosticOptionErrorMessage(optionName);
            // verify that option is actually diagnostic
            CommandLineOptionTest.verifySameJVMStartup(new String[] { errorMessage }, null, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, prepareOptionValue("true"));
            CommandLineOptionTest.verifySameJVMStartup(null, new String[] { errorMessage }, shouldPreplacedMessage, shouldPreplacedMessage + "without any warnings", ExitCode.OK, CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, prepareOptionValue("true"));
        } else {
            String shouldPreplacedMessage = String.format("JVM startup should " + "preplaced with '%s' option in debug build", optionName);
            CommandLineOptionTest.verifySameJVMStartup(null, null, shouldPreplacedMessage, shouldPreplacedMessage, 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, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, prepareOptionValue("true"));
    }
}

14 View Complete Implementation : TestUseRTMForStackLocksOptionOnSupportedConfig.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public void runTestCases() throws Throwable {
    String errorMessage = CommandLineOptionTest.getExperimentalOptionErrorMessage("UseRTMForStackLocks");
    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, shouldFailMessage, shouldFailMessage + "%nError message expected", ExitCode.FAIL, "-XX:+UseRTMForStackLocks");
    String shouldPreplacedMessage = " VM option 'UseRTMForStackLocks'" + " is experimental%nJVM startup should preplaced 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, shouldPreplacedMessage, "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 }, shouldPreplacedMessage, "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 }, shouldPreplacedMessage, "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", "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");
}

14 View Complete Implementation : TestUseRTMLockingOptionOnUnsupportedCPU.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public void runTestCases() throws Throwable {
    String unrecongnizedOption = CommandLineOptionTest.getUnrecognizedOptionErrorMessage("UseRTMLocking");
    String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR;
    if (Platform.isX86() || Platform.isX64() || Platform.isPPC()) {
        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 }, shouldFailMessage, shouldFailMessage + ". Error message should be shown", ExitCode.FAIL, "-XX:+UseRTMLocking");
        String shouldPreplacedMessage = "JVM startup should preplaced with option " + "-XX:-UseRTMLocking even on unsupported CPU";
        // verify that we can preplaced -UseRTMLocking without
        // getting any error messages
        CommandLineOptionTest.verifySameJVMStartup(null, new String[] { errorMessage, unrecongnizedOption }, shouldPreplacedMessage, shouldPreplacedMessage + " without any warnings", ExitCode.OK, "-XX:-UseRTMLocking");
        // verify that UseRTMLocking is false by default
        CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", 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, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, "-XX:+UseRTMLocking");
        CommandLineOptionTest.verifySameJVMStartup(new String[] { unrecongnizedOption }, null, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, "-XX:-UseRTMLocking");
    }
}

14 View Complete Implementation : TestUseRTMLockingOptionOnUnsupportedVM.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
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 shouldPreplacedMessage = "JVM startup should preplaced with option " + "-XX:-UseRTMLocking even on unsupported VM";
    // verify that we can't use +UseRTMLocking
    CommandLineOptionTest.verifySameJVMStartup(new String[] { errorMessage }, null, shouldFailMessage, shouldFailMessage, ExitCode.FAIL, "-XX:+UseRTMLocking");
    // verify that we can turn it off
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { errorMessage }, shouldPreplacedMessage, shouldPreplacedMessage + " without any warnings", ExitCode.OK, "-XX:-UseRTMLocking");
    // verify that it is off by default
    CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking", TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE, String.format("Default value of option 'UseRTMLocking' should" + " be '%s'", DEFAULT_VALUE));
}

13 View Complete Implementation : UseSHASpecificTestCaseForSupportedCPU.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected void verifyWarnings() throws Throwable {
    String shouldPreplacedMessage = String.format("JVM startup should preplaced when" + " %s was preplaceded and all UseSHA*Intrinsics options " + "were disabled", CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, true));
    // Verify that there will be no warnings when +UseSHA was preplaceded and
    // all UseSHA*Intrinsics options were disabled.
    CommandLineOptionTest.verifySameJVMStartup(null, new String[] { ".*UseSHA.*" }, shouldPreplacedMessage, shouldPreplacedMessage, ExitCode.OK, SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, true), CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA256_INTRINSICS_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false));
}