com.oracle.java.testlibrary.ProcessTools Java Examples

The following examples show how to use com.oracle.java.testlibrary.ProcessTools. 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: TestVerifySilently.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  Collections.addAll(vmOpts, getTestJavaOpts());
  Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-XX:+VerifyBeforeGC",
                                           "-XX:+VerifyAfterGC",
                                           "-XX:" + (verifySilently ? "+":"-") + "VerifySilently",
                                           RunSystemGC.class.getName()});
  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());
  return output;
}
 
Example #2
Source File: TestGCId.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testGCId(String gcFlag, String logFlag) throws Exception {
  // GCID logging enabled
  ProcessBuilder pb_enabled =
    ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:+PrintGCID", GCTest.class.getName());
  verifyContainsGCIDs(new OutputAnalyzer(pb_enabled.start()));

  // GCID logging disabled
  ProcessBuilder pb_disabled =
    ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:-PrintGCID", GCTest.class.getName());
  verifyContainsNoGCIDs(new OutputAnalyzer(pb_disabled.start()));

  // GCID logging default
  ProcessBuilder pb_default =
    ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", GCTest.class.getName());
  verifyContainsNoGCIDs(new OutputAnalyzer(pb_default.start()));
}
 
Example #3
Source File: TestExcessGCLockerCollections.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 {
    if (args.length < 3) {
        System.out.println("usage: TestExcessGCLockerCollections" +
                           " <duration sec> <alloc threads>" +
                           " <jni critical threads>");
        throw new RuntimeException("Invalid arguments");
    }

    ArrayList<String> finalArgs = new ArrayList<String>();
    finalArgs.addAll(Arrays.asList(COMMON_OPTIONS));
    finalArgs.add(TestExcessGCLockerCollectionsAux.class.getName());
    finalArgs.addAll(Arrays.asList(args));

    // GC and other options obtained from test framework.
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        true, finalArgs.toArray(new String[0]));
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldHaveExitValue(0);
    //System.out.println("------------- begin stdout ----------------");
    //System.out.println(output.getStdout());
    //System.out.println("------------- end stdout ----------------");
    output.stdoutShouldMatch(USED_OK_LINE);
    output.stdoutShouldNotMatch(USED_TOO_LOW_LINE);
}
 
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: TestCMSClassUnloadingEnabledHWM.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static OutputAnalyzer run(boolean enableUnloading) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    "-Xbootclasspath/a:.",
    "-XX:+UnlockDiagnosticVMOptions",
    "-XX:+WhiteBoxAPI",
    "-Xmx128m",
    "-XX:CMSMaxAbortablePrecleanTime=1",
    "-XX:CMSWaitDuration=50",
    "-XX:MetaspaceSize=" + MetaspaceSize,
    "-Xmn" + YoungGenSize,
    "-XX:+UseConcMarkSweepGC",
    "-XX:" + (enableUnloading ? "+" : "-") + "CMSClassUnloadingEnabled",
    "-XX:+PrintHeapAtGC",
    "-XX:+PrintGCDetails",
    "-XX:+PrintGCTimeStamps",
    TestCMSClassUnloadingEnabledHWM.AllocateBeyondMetaspaceSize.class.getName(),
    "" + MetaspaceSize);
  return new OutputAnalyzer(pb.start());
}
 
Example #6
Source File: TestEagerReclaimHumongousRegionsWithRefs.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 {
    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 #7
Source File: UseCountedLoopSafepoints.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main (String args[]) throws Exception {
    if (args.length == 1) {
        final int loops = Integer.parseInt(args[0]);
        for (int i = 0; i < loops; i++) {
            _num.addAndGet(1);
        }
    } else {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
                "-XX:+IgnoreUnrecognizedVMOptions",
                "-XX:-TieredCompilation",
                "-XX:+UseBiasedLocking",
                "-XX:BiasedLockingStartupDelay=500",
                "-XX:+SafepointTimeout",
                "-XX:SafepointTimeoutDelay=2000",
                "-XX:+UseCountedLoopSafepoints",
                "UseCountedLoopSafepoints",
                "2000000000"
                );
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldNotContain("Timeout detected");
        output.shouldHaveExitValue(0);
    }
}
 
Example #8
Source File: TestDynamicNumberOfGCThreads.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception {
  // UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled
  String[] baseArgs = {"-XX:+" + gcFlag, "-Xmx10M", "-XX:+PrintGCDetails",  "-XX:+UseDynamicNumberOfGCThreads", "-XX:+TraceDynamicGCThreads", GCTest.class.getName()};

  // Base test with gc and +UseDynamicNumberOfGCThreads:
  ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(baseArgs);
  verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));

  // Ensure it also works on uniprocessors or if user specifies -XX:ParallelGCThreads=1:
  String[] extraArgs = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+ForceDynamicNumberOfGCThreads", "-XX:ParallelGCThreads=1"};
  String[] finalArgs = new String[baseArgs.length + extraArgs.length];
  System.arraycopy(extraArgs, 0, finalArgs, 0,                extraArgs.length);
  System.arraycopy(baseArgs,  0, finalArgs, extraArgs.length, baseArgs.length);
  pb_enabled = ProcessTools.createJavaProcessBuilder(finalArgs);
  verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
}
 
Example #9
Source File: TestG1TraceEagerReclaimHumongousObjects.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testHumongousObjectGCLogs() throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                             "-Xms128M",
                                             "-Xmx128M",
                                             "-Xmn16M",
                                             "-XX:G1HeapRegionSize=1M",
                                             "-XX:+PrintGC",
                                             "-XX:+UnlockExperimentalVMOptions",
                                             "-XX:G1LogLevel=finest",
                                             "-XX:+G1TraceEagerReclaimHumongousObjects",
                                             GCWithHumongousObjectTest.class.getName());

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

  // As G1ReclaimDeadHumongousObjectsAtYoungGC is set(default), below logs should be displayed.
  output.shouldContain("[Humongous Reclaim");
  output.shouldContain("[Humongous Total");
  output.shouldContain("[Humongous Candidate");
  output.shouldContain("[Humongous Reclaimed");

  // As G1TraceReclaimDeadHumongousObjectsAtYoungGC is set and GCWithHumongousObjectTest has humongous objects,
  // these logs should be displayed.
  output.shouldContain("Live humongous");
  output.shouldContain("Dead humongous region");
  output.shouldHaveExitValue(0);
}
 
Example #10
Source File: TestEagerReclaimHumongousRegions.java    From openjdk-jdk8u 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");
    Asserts.assertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");

    output.shouldHaveExitValue(0);
}
 
Example #11
Source File: TestVerifySilently.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  Collections.addAll(vmOpts, getTestJavaOpts());
  Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-XX:+VerifyBeforeGC",
                                           "-XX:+VerifyAfterGC",
                                           "-XX:" + (verifySilently ? "+":"-") + "VerifySilently",
                                           RunSystemGC.class.getName()});
  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());
  return output;
}
 
Example #12
Source File: TestG1ClassUnloadingHWM.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static OutputAnalyzer run(boolean enableUnloading) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    "-Xbootclasspath/a:.",
    "-XX:+UnlockDiagnosticVMOptions",
    "-XX:+WhiteBoxAPI",
    "-XX:MetaspaceSize=" + MetaspaceSize,
    "-Xmn" + YoungGenSize,
    "-XX:+UseG1GC",
    "-XX:" + (enableUnloading ? "+" : "-") + "ClassUnloadingWithConcurrentMark",
    "-XX:+PrintHeapAtGC",
    "-XX:+PrintGCDetails",
    TestG1ClassUnloadingHWM.AllocateBeyondMetaspaceSize.class.getName(),
    "" + MetaspaceSize,
    "" + YoungGenSize);
  return new OutputAnalyzer(pb.start());
}
 
Example #13
Source File: TestVerifySubSet.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static OutputAnalyzer runTest(String subset) throws Exception {
    ArrayList<String> vmOpts = new ArrayList();

    Collections.addAll(vmOpts, getTestJavaOpts());
    Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
                                             "-XX:+VerifyBeforeGC",
                                             "-XX:+VerifyAfterGC",
                                             "-XX:VerifySubSet="+subset,
                                             RunSystemGC.class.getName()});
    ProcessBuilder pb =
        ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    System.out.println("Output:\n" + output.getOutput());
    return output;
}
 
Example #14
Source File: TestVerifySubSet.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static OutputAnalyzer runTest(String subset) throws Exception {
    ArrayList<String> vmOpts = new ArrayList();

    Collections.addAll(vmOpts, getTestJavaOpts());
    Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
                                             "-XX:+VerifyBeforeGC",
                                             "-XX:+VerifyAfterGC",
                                             "-XX:VerifySubSet="+subset,
                                             RunSystemGC.class.getName()});
    ProcessBuilder pb =
        ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    System.out.println("Output:\n" + output.getOutput());
    return output;
}
 
Example #15
Source File: Test2GbHeap.java    From openjdk-jdk8u 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 #16
Source File: TestEagerReclaimHumongousRegionsClearMarkBits.java    From jdk8u60 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",
        "-Xmn2M",
        "-XX:G1HeapRegionSize=1M",
        "-XX:InitiatingHeapOccupancyPercent=0", // Want to have as much as possible initial marks.
        "-XX:+PrintGC",
        "-XX:+VerifyAfterGC",
        "-XX:ConcGCThreads=1", // Want to make marking as slow as possible.
        "-XX:+IgnoreUnrecognizedVMOptions", // G1VerifyBitmaps is develop only.
        "-XX:+G1VerifyBitmaps",
        ReclaimRegionFast.class.getName());
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldHaveExitValue(0);
}
 
Example #17
Source File: Test2GbHeap.java    From hottub 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 #18
Source File: Test2GbHeap.java    From jdk8u60 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 #19
Source File: TestEagerReclaimHumongousRegions.java    From openjdk-jdk8u-backup 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");
    Asserts.assertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");

    output.shouldHaveExitValue(0);
}
 
Example #20
Source File: TestGCId.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static void testGCId(String gcFlag, String logFlag) throws Exception {
  // GCID logging enabled
  ProcessBuilder pb_enabled =
    ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:+PrintGCID", GCTest.class.getName());
  verifyContainsGCIDs(new OutputAnalyzer(pb_enabled.start()));

  // GCID logging disabled
  ProcessBuilder pb_disabled =
    ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:-PrintGCID", GCTest.class.getName());
  verifyContainsNoGCIDs(new OutputAnalyzer(pb_disabled.start()));

  // GCID logging default
  ProcessBuilder pb_default =
    ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", GCTest.class.getName());
  verifyContainsNoGCIDs(new OutputAnalyzer(pb_default.start()));
}
 
Example #21
Source File: TestG1TraceEagerReclaimHumongousObjects.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void testGCLogs() throws Exception {

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                               "-Xms128M",
                                               "-Xmx128M",
                                               "-Xmn16M",
                                               "-XX:G1HeapRegionSize=1M",
                                               "-XX:+PrintGC",
                                               "-XX:+UnlockExperimentalVMOptions",
                                               "-XX:G1LogLevel=finest",
                                               "-XX:+G1TraceEagerReclaimHumongousObjects",
                                               GCTest.class.getName());

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

    // As G1EagerReclaimHumongousObjects is set(default), below logs should be displayed.
    // And GCTest doesn't have humongous objects, so values should be zero.
    output.shouldContain("[Humongous Reclaim");
    output.shouldContain("[Humongous Total: 0]");
    output.shouldContain("[Humongous Candidate: 0]");
    output.shouldContain("[Humongous Reclaimed: 0]");

    output.shouldHaveExitValue(0);
  }
 
Example #22
Source File: TestVerifySilently.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  Collections.addAll(vmOpts, getTestJavaOpts());
  Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-XX:+VerifyBeforeGC",
                                           "-XX:+VerifyAfterGC",
                                           "-XX:" + (verifySilently ? "+":"-") + "VerifySilently",
                                           RunSystemGC.class.getName()});
  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());
  return output;
}
 
Example #23
Source File: TestGCId.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void testGCId(String gcFlag, String logFlag) throws Exception {
  // GCID logging enabled
  ProcessBuilder pb_enabled =
    ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:+PrintGCID", GCTest.class.getName());
  verifyContainsGCIDs(new OutputAnalyzer(pb_enabled.start()));

  // GCID logging disabled
  ProcessBuilder pb_disabled =
    ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:-PrintGCID", GCTest.class.getName());
  verifyContainsNoGCIDs(new OutputAnalyzer(pb_disabled.start()));

  // GCID logging default
  ProcessBuilder pb_default =
    ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", GCTest.class.getName());
  verifyContainsNoGCIDs(new OutputAnalyzer(pb_default.start()));
}
 
Example #24
Source File: FinalizerInfoTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void run() throws Exception {
    try {
        lock.lock();
        for(int i = 0; i < objectsCount; ++i) {
            new MyObject();
        }
        System.out.println("Objects initialized: " + objectsCount);
        System.gc();

        while(wasTrapped < 1) {
            // Waiting for gc thread.
        }


        String pid = Integer.toString(ProcessTools.getProcessId());
        ProcessBuilder pb = new ProcessBuilder();
        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, cmd});
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldContain("MyObject");
    } finally {
        lock.unlock();
    }
}
 
Example #25
Source File: TestExitOnOutOfMemoryError.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (args.length == 1) {
        // This should guarantee to throw:
        // java.lang.OutOfMemoryError: Requested array size exceeds VM limit
        try {
            Object[] oa = new Object[Integer.MAX_VALUE];
            throw new Error("OOME not triggered");
        } catch (OutOfMemoryError err) {
            throw new Error("OOME didn't terminate JVM!");
        }
    }

    // else this is the main test
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+ExitOnOutOfMemoryError",
            "-Xmx64m", TestExitOnOutOfMemoryError.class.getName(), "throwOOME");
    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    /*
     * Actual output should look like this:
     * Terminating due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit
     */
    output.shouldHaveExitValue(3);
    output.shouldContain("Terminating due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit");
    System.out.println("PASSED");
}
 
Example #26
Source File: UseCountedLoopSafepoints.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main (String args[]) throws Exception {
    if (args.length == 1) {
        final int loops = Integer.parseInt(args[0]);
        for (int i = 0; i < loops; i++) {
            _num.addAndGet(1);
        }
    } else {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
                "-XX:+IgnoreUnrecognizedVMOptions",
                "-XX:-TieredCompilation",
                "-XX:+UseBiasedLocking",
                "-XX:BiasedLockingStartupDelay=500",
                "-XX:+SafepointTimeout",
                "-XX:SafepointTimeoutDelay=2000",
                "-XX:+UseCountedLoopSafepoints",
                "UseCountedLoopSafepoints",
                "2000000000"
                );
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldNotContain("Timeout detected");
        output.shouldHaveExitValue(0);
    }
}
 
Example #27
Source File: RTMTestBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Executes RTM test in a new JVM started with {@code options} cli options.
 *
 * @param test test case to execute.
 * @param options additional options for VM
 * @throws Exception when something went wrong.
 */
public static OutputAnalyzer executeRTMTest(CompilableTest test,
        String... options) throws Exception {
    ProcessBuilder processBuilder
            = ProcessTools.createJavaProcessBuilder(
            RTMTestBase.prepareTestOptions(test, options));
    OutputAnalyzer outputAnalyzer
            = new OutputAnalyzer(processBuilder.start());
    System.out.println(outputAnalyzer.getOutput());
    return outputAnalyzer;
}
 
Example #28
Source File: TestDefaultMaxRAMFraction.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("-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 #29
Source File: TestShrinkAuxiliaryData.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void performTest(List<String> opts) throws Exception {
    ProcessBuilder pb
            = ProcessTools.createJavaProcessBuilder(
                    opts.toArray(new String[opts.size()])
            );

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println(output.getStdout());
    System.err.println(output.getStderr());
    output.shouldHaveExitValue(0);
}
 
Example #30
Source File: TestStringSymbolTableStats.java    From jdk8u60 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:+UseG1GC",
                                                              "-XX:+UnlockExperimentalVMOptions",
                                                              "-XX:+G1TraceStringSymbolTableScrubbing",
                                                              SystemGCTest.class.getName());

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

    System.out.println("Output:\n" + output.getOutput());

    output.shouldContain("Cleaned string and symbol table");
    output.shouldHaveExitValue(0);
  }