jdk.test.lib.process.OutputAnalyzer Java Examples

The following examples show how to use jdk.test.lib.process.OutputAnalyzer. 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: TestMetaspaceCMSCancel.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Set a small MetaspaceSize so that a CMS concurrent collection will be
    // scheduled.  Set CMSWaitDuration to 5s so that the concurrent collection
    // start may be delayed.  It does not guarantee 5s before the start of the
    // concurrent collection but does increase the probability that it will
    // be started later.  System.gc() is used to invoke a full collection.  Set
    // ExplicitGCInvokesConcurrent to off so it is a STW collection.
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:.",
                                                              "-XX:+UnlockDiagnosticVMOptions",
                                                              "-XX:+WhiteBoxAPI",
                                                              "-XX:+UseConcMarkSweepGC",
                                                              "-XX:MetaspaceSize=2m",
                                                              "-XX:CMSWaitDuration=5000",
                                                              "-XX:-ExplicitGCInvokesConcurrent",
                                                              "-Xlog:gc*=debug",
                                                              MetaspaceGCTest.class.getName());

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldNotContain("Concurrent Reset");
    output.shouldHaveExitValue(0);
}
 
Example #2
Source File: ConfigFileParsing.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
  String testFileName = ".hotspotrc";

  // Create really long invalid option
  String reallyLongInvalidOption = "";
  for (int i=0; i<5000; i++)
    reallyLongInvalidOption+='a';

  // Populate the options file with really long string
  PrintWriter pw = new PrintWriter(testFileName);
  pw.println("-XX:+" + reallyLongInvalidOption);
  pw.close();

  // start VM
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
      "-XX:+IgnoreUnrecognizedVMOptions", "-XX:Flags=.hotspotrc", "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldHaveExitValue(0);
}
 
Example #3
Source File: NMT.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    ProcessBuilder pb;

    pb = ProcessTools.createJavaProcessBuilder("-minimal", "-XX:NativeMemoryTracking=detail", "-version");
    new OutputAnalyzer(pb.start())
            .shouldContain("Native Memory Tracking is not supported in this VM")
            .shouldHaveExitValue(1);

    pb = ProcessTools.createJavaProcessBuilder("-minimal", "-XX:NativeMemoryTracking=summary", "-version");
    new OutputAnalyzer(pb.start())
            .shouldContain("Native Memory Tracking is not supported in this VM")
            .shouldHaveExitValue(1);

    pb = ProcessTools.createJavaProcessBuilder("-minimal", "-XX:NativeMemoryTracking=off", "-version");
    new OutputAnalyzer(pb.start())
            .shouldContain("Native Memory Tracking is not supported in this VM")
            .shouldHaveExitValue(1);


}
 
Example #4
Source File: Agent.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    String jarName = args[0];
    String className = args[1];
    String manifestName = "manifest.mf";

    System.out.println("Creating " + manifestName);
    try (PrintStream out = new PrintStream(new File(manifestName))) {
        out.println("Premain-Class: " + className);
        out.println("Can-Redefine-Classes: true");
    }

    System.out.println("Building " + jarName);
    JDKToolLauncher jar = JDKToolLauncher
            .create("jar")
            .addToolArg("-cfm")
            .addToolArg(jarName)
            .addToolArg(manifestName);

    System.out.println("Running jar " + Arrays.toString(jar.getCommand()));

    ProcessBuilder pb = new ProcessBuilder(jar.getCommand());
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldHaveExitValue(0);
}
 
Example #5
Source File: SetVMFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void setMutableFlag(CommandExecutor executor) {
    OutputAnalyzer out = getAllFlags(executor);
    String flagName = out.firstMatch(MANAGEABLE_PATTERN, 1);
    String flagVal = out.firstMatch(MANAGEABLE_PATTERN, 2);

    System.out.println("### Setting a mutable flag '" + flagName + "'");

    if (flagVal == null) {
        System.err.println(out.getOutput());
        throw new Error("Can not find a boolean manageable flag");
    }

    Boolean blnVal = Boolean.parseBoolean(flagVal);
    setMutableFlagInternal(executor, flagName, !blnVal, true);
    setMutableFlagInternal(executor, flagName, blnVal, false);
}
 
Example #6
Source File: TestHeapDumpForInvokeDynamic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void attachDumpAndVerify(String heapDumpFileName,
                                        long lingeredAppPid) throws Exception {

    JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
    launcher.addToolArg("jmap");
    launcher.addToolArg("--binaryheap");
    launcher.addToolArg("--dumpfile");
    launcher.addToolArg(heapDumpFileName);
    launcher.addToolArg("--pid");
    launcher.addToolArg(Long.toString(lingeredAppPid));

    ProcessBuilder processBuilder = new ProcessBuilder();
    processBuilder.command(launcher.getCommand());
    System.out.println(
        processBuilder.command().stream().collect(Collectors.joining(" ")));

    OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
    SAOutput.shouldHaveExitValue(0);
    SAOutput.shouldContain("heap written to");
    SAOutput.shouldContain(heapDumpFileName);
    System.out.println(SAOutput.getOutput());

    verifyHeapDump(heapDumpFileName);
}
 
Example #7
Source File: DockerTestUtils.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Run Java inside the docker image with specified parameters and options.
 *
 * @param DockerRunOptions optins for running docker
 *
 * @return output of the run command
 * @throws Exception
 */
public static OutputAnalyzer dockerRunJava(DockerRunOptions opts) throws Exception {
    ArrayList<String> cmd = new ArrayList<>();

    cmd.add("docker");
    cmd.add("run");
    if (opts.tty)
        cmd.add("--tty=true");
    if (opts.removeContainerAfterUse)
        cmd.add("--rm");

    cmd.addAll(opts.dockerOpts);
    cmd.add(opts.imageNameAndTag);
    cmd.add(opts.command);

    cmd.addAll(opts.javaOpts);
    if (opts.appendTestJavaOptions) {
        Collections.addAll(cmd, Utils.getTestJavaOpts());
    }

    cmd.add(opts.classToRun);
    cmd.addAll(opts.classParams);

    return execute(cmd);
}
 
Example #8
Source File: BooleanTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void testFunctional(boolean value) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-Xbootclasspath/a:.",
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:+WhiteBoxAPI",
        "-Xcomp",
        "-XX:CompileCommand=compileonly," + METHOD + "*",
        "-XX:" + (value ? "-" : "+") + FLAG_NAME,
        TEST_NAME,
        "" + value);
    OutputAnalyzer out = new OutputAnalyzer(pb.start());
    if (value) {
        out.shouldNotContain(METHOD1);
        out.shouldContain(METHOD2);
    } else {
        out.shouldContain(METHOD1);
        out.shouldNotContain(METHOD2);
    }
}
 
Example #9
Source File: TestJcmdStartWithOptions.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void testRecordingNotStartedTooEarly() throws Exception {
    String name = "testRecordingNotStartedTooEarly";
    long delay = 2 * 1000;
    OutputAnalyzer output = JcmdHelper.jcmd("JFR.start",
            "name=" + name,
            "delay=" + delay + "ms");
    JcmdAsserts.assertRecordingIsScheduled(output, "1", "2 s");
    for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
        if (name.equals(r.getName())) {
            while(r.getState() != RecordingState.RUNNING) {
                Thread.sleep(10);
            }
            long currentTime = System.currentTimeMillis();
            long afterActualStart = currentTime + delay;
            JcmdAsserts.assertStartTimeGreaterOrEqualThanMBeanValue(name, afterActualStart);
            JcmdHelper.stopAndCheck(name);
            return;
        }
    }
    throw new Exception("Could not find recording with name " + name);
}
 
Example #10
Source File: CompileModuleTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    // compile only java.lang.String::length from java.base module to have reasonable compilation time
    try {
        Files.write(COMPILE_COMMAND_FILE, Arrays.asList(COMPILE_COMMAND),
                StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW);
    } catch (IOException e) {
        throw new Error("TESTBUG: can't write list file " + e, e);
    }
    OutputAnalyzer oa = JaotcTestHelper.compileLibrary("--compile-commands",
            COMPILE_COMMAND_FILE.toString(), "--module", "java.base");
    oa.shouldHaveExitValue(0);
    File compiledLibrary = new File(JaotcTestHelper.DEFAULT_LIB_PATH);
    Asserts.assertTrue(compiledLibrary.exists(), "Compiled library file missing");
    Asserts.assertGT(compiledLibrary.length(), 0L, "Unexpected compiled library size");
    JaotcTestHelper.checkLibraryUsage(TESTED_CLASS_NAME, EXPECTED, UNEXPECTED);
}
 
Example #11
Source File: CDSTestUtils.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Result(CDSOptions opts, OutputAnalyzer out) throws Exception {
    options = opts;
    output = out;
    hasMappingFailure = CDSTestUtils.checkCommonExecExceptions(output);
    hasAbnormalExit   = (!hasMappingFailure) && (output.getExitValue() != 0);
    hasNormalExit     = (!hasMappingFailure) && (output.getExitValue() == 0);

    if (hasNormalExit) {
        if ("on".equals(options.xShareMode) &&
            output.getStderr().contains("java version") &&
            !output.getStderr().contains(CDS_DISABLED)) {
            // "-showversion" is always passed in the command-line by the execXXX methods.
            // During normal exit, we require that the VM to show that sharing was enabled.
            output.shouldContain("sharing");
        }
    }
}
 
Example #12
Source File: TestAESIntrinsicsOnSupportedConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to false, UseSSE flag is set to 2,
 * Platform should support UseSSE (x86 or x64) <br/>
 * TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testNoUseAESUseSSE2() throws Throwable {
    if (Platform.isX86() || Platform.isX64()) {
        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
                prepareArguments(prepareBooleanFlag(AESIntrinsicsBase
                                .USE_AES, false),
                        prepareNumericFlag(AESIntrinsicsBase.USE_SSE, 2)));
        final String errorMessage = "Case testNoUseAESUseSSE2 failed";
        verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC,
                        AESIntrinsicsBase.AES_INTRINSIC},
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage,
                outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false",
                errorMessage, outputAnalyzer);
        verifyOptionValue(AESIntrinsicsBase.USE_SSE, "2", errorMessage,
                outputAnalyzer);
    }
}
 
Example #13
Source File: BootAppendTests.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void testBootAppendClass() throws Exception {
    for (String mode : modes) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            "-XX:+UnlockDiagnosticVMOptions",
            "-XX:SharedArchiveFile=./BootAppendTests.jsa",
            "-XX:+TraceClassLoading",
            "-cp", appJar,
            "-Xbootclasspath/a:" + bootAppendJar,
            "-Xshare:" + mode,
            APP_CLASS,
            BOOT_APPEND_CLASS_NAME);
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldContain("[class,load] nonjdk.myPackage.MyClass");

        // If CDS is enabled, the nonjdk.myPackage.MyClass should be loaded
        // from the shared archive.
        if (mode.equals("on")) {
            output.shouldContain(
                "[class,load] nonjdk.myPackage.MyClass source: shared objects file");
        }
    }
}
 
Example #14
Source File: TestMaxMinHeapFreeRatioFlags.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verify that VM will fail to start with specified ratios.
 *
 * @param minRatio value of MinHeapFreeRatio option
 * @param useXminf used Xminf option instead of MinHeapFreeRatio
 * @param maxRatio value of MaxHeapFreeRatio option
 * @param useXmaxf used Xmaxf option instead of MaxHeapFreeRatio
 * @param options additional options for JVM
 */
public static void negativeTest(int minRatio, boolean useXminf,
        int maxRatio, boolean useXmaxf,
        LinkedList<String> options) throws Exception {

    LinkedList<String> vmOptions = new LinkedList<>(options);
    Collections.addAll(vmOptions,
            (useXminf ? "-Xminf" + minRatio / 100.0 : "-XX:MinHeapFreeRatio=" + minRatio),
            (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio),
            "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
            "-version"
    );
    ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
    OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
    analyzer.shouldHaveExitValue(1);
    analyzer.shouldContain("Error: Could not create the Java Virtual Machine.");
}
 
Example #15
Source File: AssertSafepointCheckConsistency4.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    if (args.length > 0) {
        WhiteBox.getWhiteBox().assertMatchingSafepointCalls(true, false);
    }
    if (Platform.isDebugBuild()){
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
           "-Xbootclasspath/a:.",
           "-XX:+UnlockDiagnosticVMOptions",
           "-XX:+WhiteBoxAPI",
           "-XX:-TransmitErrorReport",
           "-XX:-CreateCoredumpOnCrash",
           "-Xmx32m",
           "AssertSafepointCheckConsistency4",
           "test");

        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldNotContain("assert");
        output.shouldNotContain("never");
        output.shouldNotContain("always");
    }
}
 
Example #16
Source File: TestExitOnOutOfMemoryError.java    From openjdk-jdk9 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.stdoutShouldNotBeEmpty();
    output.shouldContain("Terminating due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit");
    System.out.println("PASSED");
}
 
Example #17
Source File: TestInitialTenuringThreshold.java    From openjdk-jdk9 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(
    // some value below the default value of InitialTenuringThreshold of 7
    "-XX:MaxTenuringThreshold=1",
    "-version"
    );

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldHaveExitValue(0);
  // successful tests
  runWithThresholds(0, 10, false);
  runWithThresholds(5, 5, false);
  runWithThresholds(8, 16, false);
  // failing tests
  runWithThresholds(10, 0, true);
  runWithThresholds(9, 8, true);
  runWithThresholds(-1, 8, true);
  runWithThresholds(0, -1, true);
  runWithThresholds(8, -1, true);
  runWithThresholds(16, 8, true);
  runWithThresholds(8, 17, true);
}
 
Example #18
Source File: BootAppendTests.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void testBootAppendExcludedModuleClass() throws Exception {
    for (String mode : modes) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            "-XX:+UnlockDiagnosticVMOptions",
            "-XX:SharedArchiveFile=./BootAppendTests.jsa",
            "-XX:+TraceClassLoading",
            "-cp", appJar,
            "-Xbootclasspath/a:" + bootAppendJar,
            "--limit-modules=java.base",
            "-Xshare:" + mode,
            APP_CLASS,
            BOOT_APPEND_MODULE_CLASS_NAME);
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldContain("[class,load] javax.sound.sampled.MyClass");

        // When CDS is enabled, the shared class should be loaded from the archive.
        if (mode.equals("on")) {
            output.shouldContain("[class,load] javax.sound.sampled.MyClass source: shared objects file");
        }
    }
}
 
Example #19
Source File: FinalizerInfoTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void run(CommandExecutor executor) {
    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.
        }

        OutputAnalyzer output = executor.execute(cmd);
        output.shouldContain("MyObject");
    } finally {
        lock.unlock();
    }
}
 
Example #20
Source File: TestStartRecording.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 {
    final String recordingName = "TestStartRecording";
    OutputAnalyzer output = StartupHelper.jcmd("JFR.check");
    output.shouldContain(recordingName);

    Path path = Paths.get(".", "my.jfr");
    output = StartupHelper.jcmd("JFR.dump", "name=" + recordingName, "filename=" + path);
    Asserts.assertFalse(RecordingFile.readAllEvents(path).isEmpty(), "No events found");
}
 
Example #21
Source File: PrintNMTStatistics.java    From openjdk-jdk9 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:+UnlockDiagnosticVMOptions",
      "-XX:+PrintNMTStatistics",
      "-XX:NativeMemoryTracking=detail",
      "-version");

    OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
    output_detail.shouldContain("Virtual memory map:");
    output_detail.shouldContain("Details:");
    output_detail.shouldNotContain("error");
    output_detail.shouldHaveExitValue(0);

    // Make sure memory reserved for Module processing is recorded.
    output_detail.shouldContain(" Module (reserved=");

    ProcessBuilder pb1 = ProcessTools.createJavaProcessBuilder(
      "-XX:+UnlockDiagnosticVMOptions",
      "-XX:+PrintNMTStatistics",
      "-XX:NativeMemoryTracking=summary",
      "-version");

    OutputAnalyzer output_summary = new OutputAnalyzer(pb1.start());
    output_summary.shouldContain("Java Heap (reserved=");
    output_summary.shouldNotContain("Virtual memory map:");
    output_summary.shouldNotContain("Details:");
    output_summary.shouldNotContain("error");
    output_summary.shouldHaveExitValue(0);
    }
 
Example #22
Source File: TestDeprecatedPrintFlags.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void testPrintGC() throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintGC", "DoGC");
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldContain("-XX:+PrintGC is deprecated. Will use -Xlog:gc instead.");
    output.shouldNotContain("PrintGCDetails");
    output.stdoutShouldMatch("\\[info.*\\]\\[gc *\\]");
    output.stdoutShouldNotMatch("\\[info.*\\]\\[gc\\,");
    output.shouldHaveExitValue(0);
}
 
Example #23
Source File: TestMaxHeapSizeTools.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  shouldContainOrNot(output, hasWarning, "Warning");
  shouldContainOrNot(output, hasError, "Error");
  output.shouldHaveExitValue(errorcode);
}
 
Example #24
Source File: FlagWithInvalidValue.java    From openjdk-jdk9 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:MaxRAMFraction=v", "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  output.shouldContain("Improperly specified VM option 'MaxRAMFraction=v'");
  output.shouldHaveExitValue(1);
}
 
Example #25
Source File: Test6857159.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    String className = Test.class.getName();
    OutputAnalyzer analyzer = ProcessTools.executeTestJvm("-Xbatch",
            "-XX:+PrintCompilation",
            "-XX:CompileOnly="+ className + "$ct::run",
            className);
    analyzer.shouldNotContain("COMPILE SKIPPED");
    analyzer.shouldContain(className + "$ct0::run (16 bytes)");
    analyzer.shouldHaveExitValue(0);
}
 
Example #26
Source File: SASymbolTableTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void createArchive()  throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:SharedArchiveFile=" + jsaName,
        "-Xshare:dump");

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldContain("Loading classes to share");
    output.shouldHaveExitValue(0);
}
 
Example #27
Source File: CommandProcessor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void accept(OutputAnalyzer outputAnalyzer) {
    try {
        outputAnalyzer.asLines().stream()
                .filter(s -> s.startsWith("CompileCommand:"))
                .forEachOrdered(this::check);
    } catch (Exception e) {
        System.err.println(outputAnalyzer.getOutput());
        throw e;
    }
}
 
Example #28
Source File: TestDisableDefaultGC.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Start VM, disabling all possible default GCs
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:-UseSerialGC",
                                                              "-XX:-UseParallelGC",
                                                              "-XX:-UseG1GC",
                                                              "-XX:-UseConcMarkSweepGC",
                                                              "-version");
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldMatch("Garbage collector not selected");
    output.shouldHaveExitValue(1);
}
 
Example #29
Source File: StartupHelper.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static OutputAnalyzer jcmd(String... args) {
    String argsString = Arrays.stream(args).collect(Collectors.joining(" "));
    CommandExecutor executor = new PidJcmdExecutor();
    OutputAnalyzer oa = executor.execute(argsString);
    oa.shouldHaveExitValue(0);
    return oa;
}
 
Example #30
Source File: MaxMetaspaceSize.java    From openjdk-jdk9 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:MaxMetaspaceSize=10m", "-Xshare:dump");
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldContain("is not large enough.\nEither don't specify the -XX:MaxMetaspaceSize=<size>\nor increase the size to at least");
    output.shouldHaveExitValue(2);
}