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

The following examples show how to use com.oracle.java.testlibrary.OutputAnalyzer#shouldHaveExitValue() . 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: TestShrinkDefragmentedHeap.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception, Throwable {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            "-XX:InitialHeapSize=" + INITIAL_HEAP_SIZE,
            "-Xmn" + MINIMAL_YOUNG_SIZE,
            "-XX:MinHeapFreeRatio=10",
            "-XX:MaxHeapFreeRatio=11",
            "-XX:+UseG1GC",
            "-XX:G1HeapRegionSize=" + REGION_SIZE,
            "-XX:-ExplicitGCInvokesConcurrent",
            "-verbose:gc",
            GCTest.class.getName()
    );

    OutputAnalyzer output = ProcessTools.executeProcess(pb);
    output.shouldHaveExitValue(0);
}
 
Example 2
Source File: TestVerifySubSet.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {

        OutputAnalyzer output;

        output = runTest("heap, threads, codecache, metaspace");
        output.shouldContain("Heap");
        output.shouldContain("Threads");
        output.shouldContain("CodeCache");
        output.shouldContain("MetaspaceAux");
        output.shouldNotContain("SymbolTable");
        output.shouldNotContain("StringTable");
        output.shouldNotContain("SystemDictionary");
        output.shouldNotContain("CodeCache Oops");
        output.shouldHaveExitValue(0);

        output = runTest("hello, threads, codecache, metaspace");
        output.shouldContain("memory sub-system is unknown, please correct it");
        output.shouldNotContain("Threads");
        output.shouldNotContain("CodeCache");
        output.shouldNotContain("MetaspaceAux");
        output.shouldHaveExitValue(1);
    }
 
Example 3
Source File: TestEagerReclaimHumongousRegionsWithRefs.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UseG1GC",
        "-Xms128M",
        "-Xmx128M",
        "-Xmn16M",
        "-XX:+PrintGC",
        ReclaimRegionFast.class.getName());

    Pattern p = Pattern.compile("Full GC");

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

    int found = 0;
    Matcher m = p.matcher(output.getStdout());
    while (m.find()) {
        found++;
    }
    System.out.println("Issued " + found + " Full GCs");

    assertLessThan(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim of objects once referenced from old gen seems to not work at all");
    output.shouldHaveExitValue(0);
}
 
Example 4
Source File: Test2GbHeap.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
  ArrayList<String> testArguments = new ArrayList<String>();

  testArguments.add("-XX:+UseG1GC");
  testArguments.add("-Xmx2g");
  testArguments.add("-version");

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testArguments.toArray(new String[0]));

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

  // Avoid failing test for setups not supported.
  if (output.getOutput().contains("Could not reserve enough space for 2097152KB object heap")) {
    // Will fail on machines with too little memory (and Windows 32-bit VM), ignore such failures.
    output.shouldHaveExitValue(1);
  } else if (output.getOutput().contains("G1 GC is disabled in this release")) {
    // G1 is not supported on embedded, ignore such failures.
    output.shouldHaveExitValue(1);
  } else {
    // Normally everything should be fine.
    output.shouldHaveExitValue(0);
  }
}
 
Example 5
Source File: TestDefaultMaxRAMFraction.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:DefaultMaxRAMFraction=4", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldContain("warning: DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. Use MaxRAMFraction instead.");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 6
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 7
Source File: TestParallelGC.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParallelGC", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldNotContain("deprecated");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 8
Source File: TestDefNewCMS.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:-UseParNewGC", "-XX:+UseConcMarkSweepGC", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldContain("warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 9
Source File: TestCMSForegroundFlags.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  if (args.length != 2) {
    throw new Exception("Expected two arguments,flagValue and flagName");
  }
  String flagValue = args[0];
  String flagName = args[1];

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flagValue, "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldContain("warning: " + flagName + " is deprecated and will likely be removed in a future release.");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 10
Source File: TestAggressiveHeap.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testFlag() throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        option, "-XX:+PrintFlagsFinal", "-version");

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

    output.shouldHaveExitValue(0);

    String value = output.firstMatch(parallelGCPattern);
    if (value == null) {
        throw new RuntimeException(
            option + " didn't set UseParallelGC");
    }
}
 
Example 11
Source File: TestLargePageSizeInBytes.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void testLargePageSizeInBytes(long size) throws Exception {
    ProcessBuilder pb =
        ProcessTools.createJavaProcessBuilder("-XX:+UseLargePages",
                                              "-XX:LargePageSizeInBytes=" + size,
                                              "-version");

    OutputAnalyzer out = new OutputAnalyzer(pb.start());
    out.shouldNotContain("Attempt to use MPSS failed.");
    out.shouldHaveExitValue(0);
}
 
Example 12
Source File: TestIncGC.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xincgc", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldContain("warning: Using incremental CMS is deprecated and will likely be removed in a future release");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 13
Source File: TestParNewSerialOld.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParNewGC", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldContain("warning: Using the ParNew young collector with the Serial old collector is deprecated and will likely be removed in a future release");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 14
Source File: TestIncGC.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xincgc", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldContain("warning: Using incremental CMS is deprecated and will likely be removed in a future release");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 15
Source File: TestLargePageSizeInBytes.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void testLargePageSizeInBytes(long size) throws Exception {
    ProcessBuilder pb =
        ProcessTools.createJavaProcessBuilder("-XX:+UseLargePages",
                                              "-XX:LargePageSizeInBytes=" + size,
                                              "-version");

    OutputAnalyzer out = new OutputAnalyzer(pb.start());
    out.shouldNotContain("Attempt to use MPSS failed.");
    out.shouldHaveExitValue(0);
}
 
Example 16
Source File: TestCMSIncrementalMode.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseConcMarkSweepGC", "-XX:+CMSIncrementalMode", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldContain("warning: Using incremental CMS is deprecated and will likely be removed in a future release");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 17
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 18
Source File: OffTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest() throws Exception {
    String useTypeSpeculation = "-XX:" + (RNG.nextBoolean() ? "+" : "-") +  USE_TYPE_SPECULATION;
    String typeProfileLevel = "-XX:" + TYPE_PROFILE_LEVEL + "=" + randomTypeProfileLevel();
    ProfilingType type = randomProfileType();
    OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel;
    OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation;
    OPTIONS[PROFILING_TYPE_INDEX] = type.name();
    ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(/* addTestVmOptions= */ true, OPTIONS);
    OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start());
    outputAnalyzer.shouldHaveExitValue(0);
}
 
Example 19
Source File: TestGCId.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void verifyContainsNoGCIDs(OutputAnalyzer output) {
  output.shouldNotMatch("^#[0-9]+: \\[");
  output.shouldHaveExitValue(0);
}
 
Example 20
Source File: TestGCId.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void verifyContainsNoGCIDs(OutputAnalyzer output) {
  output.shouldNotMatch("^#[0-9]+: \\[");
  output.shouldHaveExitValue(0);
}