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

The following examples show how to use jdk.test.lib.process.OutputAnalyzer#reportDiagnosticSummary() . 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: TestLargePageUseForAuxMemory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void checkSize(OutputAnalyzer output, long expectedSize, String pattern) {
    String pageSizeStr = output.firstMatch(pattern, 1);

    if (pageSizeStr == null) {
        output.reportDiagnosticSummary();
        throw new RuntimeException("Match from '" + pattern + "' got 'null' expected: " + expectedSize);
    }

    long size = parseMemoryString(pageSizeStr);
    if (size != expectedSize) {
        output.reportDiagnosticSummary();
        throw new RuntimeException("Match from '" + pattern + "' got " + size + " expected: " + expectedSize);
    }
}
 
Example 2
Source File: TestCheckedJniExceptionCheck.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static void checkOuputForCorrectWarnings(OutputAnalyzer oa) throws RuntimeException {
    List<String> lines = oa.asLines();
    int expectedWarnings = 0;
    int warningCount = 0;
    int lineNo = 0;
    boolean testStartLine = false;
    for (String line : lines) {
        lineNo++;
        if (!testStartLine) { // Skip any warning before the actual test itself
            testStartLine = line.startsWith(TEST_START);
            continue;
        }
        if (line.startsWith(JNI_CHECK_EXCEPTION)) {
            if (expectedWarnings == 0) {
                oa.reportDiagnosticSummary();
                throw new RuntimeException("Unexpected warning at line " + lineNo);
            }
            warningCount++;
            if (warningCount > expectedWarnings) {
                oa.reportDiagnosticSummary();
                throw new RuntimeException("Unexpected warning at line " + lineNo);
            }
        }
        else if (line.startsWith(EXPECT_WARNING_START)) {
            String countStr = line.substring(EXPECT_WARNING_START.length() + 1);
            expectedWarnings = Integer.parseInt(countStr);
        }
        else if (line.startsWith(EXPECT_WARNING_END)) {
            if (warningCount != expectedWarnings) {
                oa.reportDiagnosticSummary();
                throw new RuntimeException("Missing warning at line " + lineNo);
            }
            warningCount = 0;
            expectedWarnings = 0;
        }
    }
    /*
    System.out.println("Output looks good...");
    oa.reportDiagnosticSummary();
    */
}
 
Example 3
Source File: CheckForProperDetailStackTrace.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:NativeMemoryTracking=detail",
        "-XX:+PrintNMTStatistics",
        "-version");
    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    output.shouldHaveExitValue(0);

    // We should never see either of these frames because they are supposed to be skipped. */
    output.shouldNotContain("NativeCallStack::NativeCallStack");
    output.shouldNotContain("os::get_native_stack");

    // AllocateHeap shouldn't be in the output because it is supposed to always be inlined.
    // We check for that here, but allow it for Aix, Solaris and Windows slowdebug builds
    // because the compiler ends up not inlining AllocateHeap.
    Boolean okToHaveAllocateHeap =
        Platform.isSlowDebugBuild() &&
        (Platform.isAix() || Platform.isSolaris() || Platform.isWindows());
    if (!okToHaveAllocateHeap) {
        output.shouldNotContain("AllocateHeap");
    }

    // See if we have any stack trace symbols in the output
    boolean hasSymbols =
        output.getStdout().contains(expectedSymbol) || output.getStderr().contains(expectedSymbol);
    if (!hasSymbols) {
        // It's ok for ARM not to have symbols, because it does not support NMT detail
        // when targeting thumb2. It's also ok for Windows not to have symbols, because
        // they are only available if the symbols file is included with the build.
        if (Platform.isWindows() || Platform.isARM()) {
            return; // we are done
        }
        output.reportDiagnosticSummary();
        throw new RuntimeException("Expected symbol missing missing from output: " + expectedSymbol);
    }

    /* Make sure the expected NMT detail stack trace is found. */
    String expectedStackTrace =
        (okToHaveAllocateHeap ? stackTraceAllocateHeap : stackTraceDefault);
    if (!stackTraceMatches(expectedStackTrace, output)) {
        output.reportDiagnosticSummary();
        throw new RuntimeException("Expected stack trace missing missing from output: " + expectedStackTrace);
    }
}