Java Code Examples for jdk.test.lib.process.ProcessTools#executeTestJvmAllArgs()

The following examples show how to use jdk.test.lib.process.ProcessTools#executeTestJvmAllArgs() . 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: DebugOutputTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void test() {
    for (TestCaseData testCase : TestCaseData.values()) {
        System.out.println(testCase);
        OutputAnalyzer oa;
        try {
            oa = ProcessTools.executeTestJvmAllArgs(
                    "-XX:+UnlockExperimentalVMOptions",
                    "-XX:+EnableJVMCI",
                    "-Xbootclasspath/a:.",
                    DebugOutputTest.Worker.class.getName(),
                    testCase.name());
           } catch (Throwable e) {
            e.printStackTrace();
            throw new Error("Problems running child process", e);
        }
        if (testCase.expectedException != null) {
            oa.shouldHaveExitValue(1);
            oa.shouldContain(testCase.expectedException.getName());
        } else {
            oa.shouldHaveExitValue(0);
            oa.shouldContain(new String(testCase.getExpected()));
        }
    }
}
 
Example 2
Source File: TestDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private List<String> executeApplication() throws Throwable {
    OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvmAllArgs(
        "-Xbatch",
        "-XX:-TieredCompilation",
        "-XX:+PrintCompilation",
        "-XX:+TraceNewVectors",
        TestIntVect.class.getName());
    outputAnalyzer.shouldHaveExitValue(0);
    return outputAnalyzer.asLines();
}
 
Example 3
Source File: Executor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Executes separate VM a gets an OutputAnalyzer instance with the results
 * of execution
 */
public List<OutputAnalyzer> execute() {
    // Add class name that would be executed in a separate VM
    vmOptions.add(execClass);
    OutputAnalyzer output;
    try (ServerSocket serverSocket = new ServerSocket(0)) {
        if (isValid) {
            // Get port test VM will connect to
            int port = serverSocket.getLocalPort();
            if (port == -1) {
                throw new Error("Socket is not bound: " + port);
            }
            vmOptions.add(String.valueOf(port));
            if (states != null) {
                // add flag to show that there should be state map passed
                vmOptions.add("states");
            }
            // Start separate thread to connect with test VM
            new Thread(() -> connectTestVM(serverSocket)).start();
        }
        // Start test VM
        output = ProcessTools.executeTestJvmAllArgs(
                vmOptions.toArray(new String[vmOptions.size()]));
    } catch (Throwable thr) {
        throw new Error("Execution failed: " + thr.getMessage(), thr);
    }

    List<OutputAnalyzer> outputList = new ArrayList<>();
    outputList.add(output);
    if (jcmdOutputAnalyzers != null) {
        Collections.addAll(outputList, jcmdOutputAnalyzers);
    }
    return outputList;
}