Exemplo n.º 1
0
  private void verifyRTMRetryCount(int retryCount) throws Throwable {
    CompilableTest busyLock = new BusyLock();
    long expectedAborts = retryCount + 1L;

    OutputAnalyzer outputAnalyzer =
        RTMTestBase.executeRTMTest(
            busyLock,
            "-XX:-UseRTMXendForLockBusy",
            "-XX:RTMTotalCountIncrRate=1",
            CommandLineOptionTest.prepareNumericFlag("RTMRetryCount", retryCount),
            "-XX:RTMTotalCountIncrRate=1",
            "-XX:+PrintPreciseRTMLockingStatistics",
            BusyLock.class.getName(),
            Boolean.toString(TestRTMRetryCount.INFLATE_MONITOR),
            Integer.toString(TestRTMRetryCount.LOCKING_TIME));

    outputAnalyzer.shouldHaveExitValue(0);

    List<RTMLockingStatistics> statistics =
        RTMLockingStatistics.fromString(
            busyLock.getMethodWithLockName(), outputAnalyzer.getStdout());

    Asserts.assertEQ(
        statistics.size(),
        1,
        "VM output should contain "
            + "exactly one rtm locking statistics entry for method "
            + busyLock.getMethodWithLockName());

    Asserts.assertEQ(
        statistics.get(0).getTotalAborts(),
        expectedAborts,
        String.format("It is expected to get %d aborts", expectedAborts));
  }
Exemplo n.º 2
0
 /**
  * Used to log command line, stdout, stderr and exit code from an executed process.
  *
  * @param pb The executed process.
  * @param output The output from the process.
  */
 public static String getProcessLog(ProcessBuilder pb, OutputAnalyzer output) {
   String stderr = output == null ? "null" : output.getStderr();
   String stdout = output == null ? "null" : output.getStdout();
   String exitValue = output == null ? "null" : Integer.toString(output.getExitValue());
   StringBuilder logMsg = new StringBuilder();
   final String nl = System.getProperty("line.separator");
   logMsg.append("--- ProcessLog ---" + nl);
   logMsg.append("cmd: " + getCommandLine(pb) + nl);
   logMsg.append("exitvalue: " + exitValue + nl);
   logMsg.append("stderr: " + stderr + nl);
   logMsg.append("stdout: " + stdout + nl);
   return logMsg.toString();
 }
Exemplo n.º 3
0
  public static void main(String args[]) throws Exception {
    if (!Platform.is64bit()) {
      System.out.println(
          "ReadFromNoaccessArea tests is useful only on 64bit architecture. Passing silently.");
      return;
    }

    ProcessBuilder pb =
        ProcessTools.createJavaProcessBuilder(
            "-Xbootclasspath/a:.",
            "-XX:+UnlockDiagnosticVMOptions",
            "-XX:+WhiteBoxAPI",
            "-XX:+UseCompressedOops",
            "-XX:HeapBaseMinAddress=33G",
            "-XX:-CreateCoredumpOnCrash",
            "-Xmx32m",
            DummyClassWithMainTryingToReadFromNoaccessArea.class.getName());

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("******* Printing stdout for analysis in case of failure *******");
    System.out.println(output.getStdout());
    System.out.println("******* Printing stderr for analysis in case of failure *******");
    System.out.println(output.getStderr());
    System.out.println("***************************************************************");
    if (output.getStdout() != null
        && output.getStdout().contains("WB_ReadFromNoaccessArea method is useless")) {
      // Test conditions broken. There is no protected page in ReservedHeapSpace in these
      // circumstances. Silently passing test.
      return;
    }
    if (Platform.isWindows()) {
      output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
    } else if (Platform.isOSX()) {
      output.shouldContain("SIGBUS");
    } else {
      output.shouldContain("SIGSEGV");
    }
  }