Java Code Examples for com.oracle.java.testlibrary.OutputAnalyzer#getStdout()

The following examples show how to use com.oracle.java.testlibrary.OutputAnalyzer#getStdout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSummarizeRSetStatsThreads.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(int refinementThreads, int workerThreads) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                                            "-XX:+UnlockDiagnosticVMOptions",
                                                            "-XX:+G1SummarizeRSetStats",
                                                            "-XX:G1ConcRefinementThreads=" + refinementThreads,
                                                            "-XX:ParallelGCThreads=" + workerThreads,
                                                            "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  // check output to contain the string "Concurrent RS threads times (s)" followed by
  // the correct number of values in the next line.

  // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
  // Additionally use at least one thread.
  int expectedNumRefinementThreads = refinementThreads;

  // create the pattern made up of n copies of a floating point number pattern
  String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0)
    .replace("0", "\\s+\\d+\\.\\d+");
  String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$";
  Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());

  if (!m.find()) {
    throw new Exception("Could not find correct output for concurrent RS threads times in stdout," +
      " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
  }
  output.shouldHaveExitValue(0);
}
 
Example 2
Source File: TestSummarizeRSetStatsThreads.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(int refinementThreads, int workerThreads) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                                            "-XX:+UnlockDiagnosticVMOptions",
                                                            "-XX:+G1SummarizeRSetStats",
                                                            "-XX:G1ConcRefinementThreads=" + refinementThreads,
                                                            "-XX:ParallelGCThreads=" + workerThreads,
                                                            "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  // check output to contain the string "Concurrent RS threads times (s)" followed by
  // the correct number of values in the next line.

  // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
  // Additionally use at least one thread.
  int expectedNumRefinementThreads = refinementThreads;

  // create the pattern made up of n copies of a floating point number pattern
  String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0)
    .replace("0", "\\s+\\d+\\.\\d+");
  String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$";
  Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());

  if (!m.find()) {
    throw new Exception("Could not find correct output for concurrent RS threads times in stdout," +
      " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
  }
  output.shouldHaveExitValue(0);
}
 
Example 3
Source File: TestSummarizeRSetStatsThreads.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(int refinementThreads, int workerThreads) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                                            "-XX:+UnlockDiagnosticVMOptions",
                                                            "-XX:+G1SummarizeRSetStats",
                                                            "-XX:G1ConcRefinementThreads=" + refinementThreads,
                                                            "-XX:ParallelGCThreads=" + workerThreads,
                                                            "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  // check output to contain the string "Concurrent RS threads times (s)" followed by
  // the correct number of values in the next line.

  // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
  // Additionally use at least one thread.
  int expectedNumRefinementThreads = refinementThreads;

  // create the pattern made up of n copies of a floating point number pattern
  String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0)
    .replace("0", "\\s+\\d+\\.\\d+");
  String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$";
  Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());

  if (!m.find()) {
    throw new Exception("Could not find correct output for concurrent RS threads times in stdout," +
      " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
  }
  output.shouldHaveExitValue(0);
}
 
Example 4
Source File: TestSummarizeRSetStatsThreads.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(int refinementThreads, int workerThreads) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                                            "-XX:+UnlockDiagnosticVMOptions",
                                                            "-XX:+G1SummarizeRSetStats",
                                                            "-XX:G1ConcRefinementThreads=" + refinementThreads,
                                                            "-XX:ParallelGCThreads=" + workerThreads,
                                                            "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  // check output to contain the string "Concurrent RS threads times (s)" followed by
  // the correct number of values in the next line.

  // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
  // Additionally use at least one thread.
  int expectedNumRefinementThreads = refinementThreads;

  // create the pattern made up of n copies of a floating point number pattern
  String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0)
    .replace("0", "\\s+\\d+\\.\\d+");
  String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$";
  Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());

  if (!m.find()) {
    throw new Exception("Could not find correct output for concurrent RS threads times in stdout," +
      " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
  }
  output.shouldHaveExitValue(0);
}
 
Example 5
Source File: TestSummarizeRSetStatsThreads.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(int refinementThreads, int workerThreads) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                                            "-XX:+UnlockDiagnosticVMOptions",
                                                            "-XX:+G1SummarizeRSetStats",
                                                            "-XX:G1ConcRefinementThreads=" + refinementThreads,
                                                            "-XX:ParallelGCThreads=" + workerThreads,
                                                            "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  // check output to contain the string "Concurrent RS threads times (s)" followed by
  // the correct number of values in the next line.

  // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
  // Additionally use at least one thread.
  int expectedNumRefinementThreads = refinementThreads;

  // create the pattern made up of n copies of a floating point number pattern
  String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0)
    .replace("0", "\\s+\\d+\\.\\d+");
  String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$";
  Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());

  if (!m.find()) {
    throw new Exception("Could not find correct output for concurrent RS threads times in stdout," +
      " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
  }
  output.shouldHaveExitValue(0);
}
 
Example 6
Source File: TestSummarizeRSetStatsThreads.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(int refinementThreads, int workerThreads) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                                            "-XX:+UnlockDiagnosticVMOptions",
                                                            "-XX:+G1SummarizeRSetStats",
                                                            "-XX:G1ConcRefinementThreads=" + refinementThreads,
                                                            "-XX:ParallelGCThreads=" + workerThreads,
                                                            "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  // check output to contain the string "Concurrent RS threads times (s)" followed by
  // the correct number of values in the next line.

  // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
  // Additionally use at least one thread.
  int expectedNumRefinementThreads = refinementThreads == 0 ? workerThreads : refinementThreads;
  expectedNumRefinementThreads = Math.max(1, expectedNumRefinementThreads);
  // create the pattern made up of n copies of a floating point number pattern
  String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0)
    .replace("0", "\\s+\\d+\\.\\d+");
  String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$";
  Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());

  if (!m.find()) {
    throw new Exception("Could not find correct output for concurrent RS threads times in stdout," +
      " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
  }
  output.shouldHaveExitValue(0);
}
 
Example 7
Source File: TestSummarizeRSetStatsThreads.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(int refinementThreads, int workerThreads) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                                            "-XX:+UnlockDiagnosticVMOptions",
                                                            "-XX:+G1SummarizeRSetStats",
                                                            "-XX:G1ConcRefinementThreads=" + refinementThreads,
                                                            "-XX:ParallelGCThreads=" + workerThreads,
                                                            "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  // check output to contain the string "Concurrent RS threads times (s)" followed by
  // the correct number of values in the next line.

  // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
  // Additionally use at least one thread.
  int expectedNumRefinementThreads = refinementThreads == 0 ? workerThreads : refinementThreads;
  expectedNumRefinementThreads = Math.max(1, expectedNumRefinementThreads);
  // create the pattern made up of n copies of a floating point number pattern
  String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0)
    .replace("0", "\\s+\\d+\\.\\d+");
  String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$";
  Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());

  if (!m.find()) {
    throw new Exception("Could not find correct output for concurrent RS threads times in stdout," +
      " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
  }
  output.shouldHaveExitValue(0);
}