Java Code Examples for jdk.test.lib.process.OutputAnalyzer#stderrShouldBeEmpty()

The following examples show how to use jdk.test.lib.process.OutputAnalyzer#stderrShouldBeEmpty() . 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: SetVMFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void setMutableFlagInternal(CommandExecutor executor, String flag,
                                    boolean val, boolean isNumeric) {
    String strFlagVal;
    if (isNumeric) {
        strFlagVal = val ? "1" : "0";
    } else {
        strFlagVal = val ? "true" : "false";
    }

    OutputAnalyzer out = executor.execute("VM.set_flag " + flag + " " + strFlagVal);
    out.stderrShouldBeEmpty();

    out = getAllFlags(executor);

    String newFlagVal = out.firstMatch(MANAGEABLE_PATTERN.replace("(\\S+)", flag), 1);

    assertNotEquals(newFlagVal, val ? "1" : "0");
}
 
Example 2
Source File: SetVMFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void setMutableFlagWithInvalidValue(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 + "' to an invalid value");

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

    // a boolean flag accepts only 0/1 as its value
    out = executor.execute("VM.set_flag " + flagName + " unexpected_value");
    out.stderrShouldBeEmpty();
    out.stdoutShouldContain("flag value must be a boolean (1/0 or true/false)");

    out = getAllFlags(executor);

    String newFlagVal = out.firstMatch(MANAGEABLE_PATTERN.replace("(\\S+)", flagName), 1);

    assertEquals(newFlagVal, flagVal);
}
 
Example 3
Source File: SetVMFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void setImmutableFlag(CommandExecutor executor) {
    OutputAnalyzer out = getAllFlags(executor);
    String flagName = out.firstMatch(IMMUTABLE_PATTERN, 1);
    String flagVal = out.firstMatch(IMMUTABLE_PATTERN, 2);

    System.out.println("### Setting an immutable flag '" + flagName + "'");

    if (flagVal == null) {
        System.err.println(out.getOutput());
        throw new Error("Can not find an immutable uintx flag");
    }

    Long numVal = Long.parseLong(flagVal);

    out = executor.execute("VM.set_flag " + flagName + " " + (numVal + 1));
    out.stderrShouldBeEmpty();
    out.stdoutShouldContain("only 'writeable' flags can be set");

    out = getAllFlags(executor);

    String newFlagVal = out.firstMatch(IMMUTABLE_PATTERN.replace("(\\S+)", flagName), 1);

    assertEquals(newFlagVal, flagVal);
}
 
Example 4
Source File: ClhsdbJstackXcompStress.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void runJstackInLoop(LingeredApp app) throws Exception {
    boolean anyMatchedCompiledFrame = false;
    for (int i = 0; i < MAX_ITERATIONS; i++) {
        JDKToolLauncher launcher = JDKToolLauncher
                .createUsingTestJDK("jhsdb");
        launcher.addToolArg("jstack");
        launcher.addToolArg("--pid");
        launcher.addToolArg(Long.toString(app.getPid()));

        ProcessBuilder pb = new ProcessBuilder();
        pb.command(launcher.getCommand());
        Process jhsdb = pb.start();
        OutputAnalyzer out = new OutputAnalyzer(jhsdb);

        jhsdb.waitFor();

        if (DEBUG) {
            System.out.println(out.getStdout());
            System.err.println(out.getStderr());
        }

        out.stderrShouldBeEmpty(); // NPE's are reported on the err stream
        out.stdoutShouldNotContain("Error occurred during stack walking:");
        out.stdoutShouldContain(LingeredAppWithRecComputation.THREAD_NAME);
        List<String> stdoutList = Arrays.asList(out.getStdout().split("\\R"));
        anyMatchedCompiledFrame = anyMatchedCompiledFrame || isMatchCompiledFrame(stdoutList);
    }
    if (!anyMatchedCompiledFrame) {
         throw new RuntimeException("Expected jstack output to contain 'Compiled frame'");
    }
    System.out.println("DEBUG: jhsdb jstack did not throw NPE, as expected.");
}
 
Example 5
Source File: LoadAgentDcmdTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void run(CommandExecutor executor)  {
    try{

        createJarFileForAgent();

        String libpath = getLibInstrumentPath();
        OutputAnalyzer output = null;

        // Test 1: Native agent, no arguments
        output = executor.execute("JVMTI.agent_load " +
                                      libpath + " agent.jar");
        output.stderrShouldBeEmpty();

        // Test 2: Native agent, with arguments
        output = executor.execute("JVMTI.agent_load " +
                                      libpath + " \"agent.jar=foo=bar\"");
        output.stderrShouldBeEmpty();

        // Test 3: Java agent, no arguments
        output = executor.execute("JVMTI.agent_load " +
                                      "agent.jar");
        output.stderrShouldBeEmpty();

        // Test 4: Java agent, with arguments
        output = executor.execute("JVMTI.agent_load " +
                                      "\"agent.jar=foo=bar\"");
        output.stderrShouldBeEmpty();

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 6
Source File: DataDumpDcmdTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void run(CommandExecutor executor) {
    OutputAnalyzer output = executor.execute("JVMTI.data_dump");

    output.stderrShouldBeEmpty();
}