Java Code Examples for com.oracle.java.testlibrary.ProcessTools#createJavaProcessBuilder()

The following examples show how to use com.oracle.java.testlibrary.ProcessTools#createJavaProcessBuilder() . 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: 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 2
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 3
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 4
Source File: TestDynamicNumberOfGCThreads.java    From TencentKona-8 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 5
Source File: TestG1TraceEagerReclaimHumongousObjects.java    From hottub 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 6
Source File: TestEagerReclaimHumongousRegions.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",
        "-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 7
Source File: TestMetaspaceSizeFlags.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static OutputAnalyzer run(long maxMetaspaceSize, long metaspaceSize) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
      "-XX:MaxMetaspaceSize=" + maxMetaspaceSize,
      "-XX:MetaspaceSize=" + metaspaceSize,
      "-XX:-UseLargePages", // Prevent us from using 2GB large pages on solaris + sparc.
      "-XX:+PrintFlagsFinal",
      "-version");
  return new OutputAnalyzer(pb.start());
}
 
Example 8
Source File: TestParNewCMS.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:+UseParNewGC", "-XX:+UseConcMarkSweepGC", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldNotContain("deprecated");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 9
Source File: TestCMS.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:+UseConcMarkSweepGC", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldNotContain("deprecated");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 10
Source File: TestCMSNoIncrementalMode.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:+UseConcMarkSweepGC", "-XX:-CMSIncrementalMode", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldNotContain("deprecated");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 11
Source File: RTMTestBase.java    From jdk8u60 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 12
Source File: TestCMSForegroundFlags.java    From hottub 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 13
Source File: MaxMetaspaceSizeTest.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(
        "-Xmx1g",
        "-XX:InitialBootClassLoaderMetaspaceSize=4195328",
        "-XX:MaxMetaspaceSize=4195328",
        "-XX:+UseCompressedClassPointers",
        "-XX:CompressedClassSpaceSize=1g",
        "-version");
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldContain("MaxMetaspaceSize is too small.");
}
 
Example 14
Source File: TestDefNewCMS.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", "-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 15
Source File: TestCMSIncrementalMode.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:+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 16
Source File: TestParallelGC.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:+UseParallelGC", "-version");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldNotContain("deprecated");
  output.shouldNotContain("error");
  output.shouldHaveExitValue(0);
}
 
Example 17
Source File: TestDefNewCMS.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:-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 18
Source File: TestLargePagesFlags.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static OutputAnalyzer executeNewJVM(Flag... flags) throws Exception {
  ArrayList<String> args = new ArrayList<>();
  for (Flag flag : flags) {
    args.add(flag.flagString());
  }
  args.add("-XX:+PrintFlagsFinal");
  args.add("-version");

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  return output;
}
 
Example 19
Source File: TestMetaspaceSizeFlags.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static OutputAnalyzer run(long maxMetaspaceSize, long metaspaceSize) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
      "-XX:MaxMetaspaceSize=" + maxMetaspaceSize,
      "-XX:MetaspaceSize=" + metaspaceSize,
      "-XX:-UseLargePages", // Prevent us from using 2GB large pages on solaris + sparc.
      "-XX:+PrintFlagsFinal",
      "-version");
  return new OutputAnalyzer(pb.start());
}
 
Example 20
Source File: TestDefaultMaxRAMFraction.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("-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);
}