@Override
  protected void verifyWarnings() throws Throwable {
    String shouldPassMessage =
        String.format(
            "JVM startup should pass 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)},
        shouldPassMessage,
        shouldPassMessage,
        ExitCode.OK,
        SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
        CommandLineOptionTest.prepareBooleanFlag(optionName, false));

    shouldPassMessage =
        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,
          shouldPassMessage,
          shouldPassMessage,
          ExitCode.OK,
          SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
          CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false),
          CommandLineOptionTest.prepareBooleanFlag(optionName, true));
    }
  }
  @Override
  protected void verifyOptionValues() throws Throwable {
    // Verify that option is disabled by default.
    CommandLineOptionTest.verifyOptionValueForSameVM(
        optionName,
        "false",
        String.format("Option '%s' should be disabled by default", optionName),
        SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS);

    // Verify that option is disabled even if it was explicitly enabled
    // using CLI options.
    CommandLineOptionTest.verifyOptionValueForSameVM(
        optionName,
        "false",
        String.format(
            "Option '%s' should be off on unsupported " + "AArch64CPU even if set to true directly",
            optionName),
        SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
        CommandLineOptionTest.prepareBooleanFlag(optionName, true));

    // Verify that option is disabled when +UseSHA was passed to JVM.
    CommandLineOptionTest.verifyOptionValueForSameVM(
        optionName,
        "false",
        String.format(
            "Option '%s' should be off on unsupported " + "AArch64CPU even if %s flag set to JVM",
            optionName,
            CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, true)),
        SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
        CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, true));
  }
  @Override
  public void runTestCases() throws Throwable {

    super.runTestCases();

    /*
      Verify that option will be disabled if all BMI1 instructions
      are explicitly disabled. VM will be launched with following options:
      -XX:-UseBMI1Instructions -version
    */
    CommandLineOptionTest.verifyOptionValueForSameVM(
        optionName,
        "false",
        "Option 'UseCountTrailingZerosInstruction' should have "
            + "'false' value if all BMI1 instructions are explicitly"
            + " disabled (-XX:-UseBMI1Instructions flag used)",
        TestUseCountTrailingZerosInstructionOnSupportedCPU.DISABLE_BMI);

    /*
      Verify that option could be turned on even if other BMI1
      instructions were turned off. VM will be launched with following
      options: -XX:-UseBMI1Instructions
      -XX:+UseCountTrailingZerosInstruction -version
    */
    CommandLineOptionTest.verifyOptionValueForSameVM(
        optionName,
        "true",
        "Option 'UseCountTrailingZerosInstruction' should be able to "
            + "be turned on even if all BMI1 instructions are "
            + "disabled (-XX:-UseBMI1Instructions flag used)",
        TestUseCountTrailingZerosInstructionOnSupportedCPU.DISABLE_BMI,
        CommandLineOptionTest.prepareBooleanFlag(optionName, true));
  }
コード例 #4
0
  private void verifyOptionValues(String value, boolean useRTMLocking, String expectedValue)
      throws Throwable {
    List<String> options = new LinkedList<>();
    options.add(CommandLineOptionTest.prepareBooleanFlag("UseRTMLocking", useRTMLocking));

    if (isExperimental) {
      options.add(CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
    }
    options.add(prepareOptionValue(value));

    CommandLineOptionTest.verifyOptionValueForSameVM(
        optionName,
        expectedValue,
        String.format(
            "Option '%s' should have '%s' " + "value if '%s' flag set",
            optionName, expectedValue, prepareOptionValue(value)),
        options.toArray(new String[options.size()]));
  }
コード例 #5
0
  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()]));
  }