Skip to content

Commit

Permalink
8258057: serviceability/attach/RemovingUnixDomainSocketTest.java does…
Browse files Browse the repository at this point in the history
…n't ignore VM warnings

Reviewed-by: cjplummer, amenkov, dholmes
  • Loading branch information
pchilano committed Dec 17, 2020
1 parent 143998e commit 7b05439
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Expand Up @@ -51,7 +51,8 @@ private static void runJCmd(long pid) throws InterruptedException, IOException {
jcmd.addToolArg(Long.toString(pid));
jcmd.addToolArg("VM.version");

Process jcmdProc = ProcessTools.startProcess("jcmd", new ProcessBuilder(jcmd.getCommand()));
ProcessBuilder pb = new ProcessBuilder(jcmd.getCommand());
Process jcmdProc = pb.start();

OutputAnalyzer out = new OutputAnalyzer(jcmdProc);

Expand All @@ -66,7 +67,7 @@ private static void runJCmd(long pid) throws InterruptedException, IOException {
"jcmd exitValue = " + out.getExitValue());

out.shouldHaveExitValue(0);
out.stderrShouldBeEmptyIgnoreVMWarnings();
out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
}

public static void main(String... args) throws Exception {
Expand Down
17 changes: 17 additions & 0 deletions test/lib/jdk/test/lib/process/OutputAnalyzer.java
Expand Up @@ -40,6 +40,8 @@ public final class OutputAnalyzer {

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

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

private final OutputBuffer buffer;
/**
* Create an OutputAnalyzer, a utility class for verifying output and exit
Expand Down Expand Up @@ -147,6 +149,21 @@ public OutputAnalyzer stderrShouldBeEmptyIgnoreVMWarnings() {
return this;
}

/**
* Verify that the stderr contents of output buffer is empty,
* after filtering out the Hotspot deprecation warning messages
*
* @throws RuntimeException
* If stderr was not empty
*/
public OutputAnalyzer stderrShouldBeEmptyIgnoreDeprecatedWarnings() {
if (!getStderr().replaceAll(deprecatedmsg + "\\R", "").isEmpty()) {
reportDiagnosticSummary();
throw new RuntimeException("stderr was not empty");
}
return this;
}

/**
* Verify that the stdout contents of output buffer is not empty
*
Expand Down

1 comment on commit 7b05439

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.