Skip to content

Commit

Permalink
8333765: [17u] Six sun/tools/jstatd testcases fail after JDK-8233725
Browse files Browse the repository at this point in the history
Signed-off-by: sendaoYan <yansendao.ysd@alibaba-inc.com>
  • Loading branch information
sendaoYan committed Jun 7, 2024
1 parent af699ff commit ac4ea5f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/jdk/sun/tools/jstatd/JstatdTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -356,7 +356,7 @@ private void runTest(boolean useShortSyntax) throws Throwable {

// Verify output from jstatd
OutputAnalyzer output = jstatdThread.getOutput();
List<String> stdout = output.asLinesWithoutVMWarnings();
List<String> stdout = output.asLinesWithoutAnythingWarnings();
output.reportDiagnosticSummary();
assertEquals(stdout.size(), 1, "Output should contain one line");
assertTrue(stdout.get(0).startsWith("jstatd started"), "List should start with 'jstatd started'");
Expand Down
16 changes: 15 additions & 1 deletion test/lib/jdk/test/lib/process/OutputAnalyzer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -40,6 +40,8 @@ public final class OutputAnalyzer {

private static final String jvmwarningmsg = ".* VM warning:.*";

private static final String anythingwarningmsg = ".*WARNING:.*";

private static final String deprecatedmsg = ".* VM warning:.* deprecated.*";

private final OutputBuffer buffer;
Expand Down Expand Up @@ -654,6 +656,18 @@ public List<String> asLinesWithoutVMWarnings() {
.collect(Collectors.toList());
}

/**
* Returns the contents of the output buffer (stdout and stderr), without anything
* warning msgs, as list of strings. Output is split by newlines.
*
* @return Contents of the output buffer as list of strings
*/
public List<String> asLinesWithoutAnythingWarnings() {
return Arrays.stream(getOutput().split("\\R"))
.filter(Pattern.compile(anythingwarningmsg).asPredicate().negate())
.collect(Collectors.toList());
}

/**
* @see #shouldMatchByLine(String, String, String)
*/
Expand Down

0 comments on commit ac4ea5f

Please sign in to comment.