8196534: [Testbug] serviceability/dcmd/jvmti/*DcmdTest tests can't tolerate unrelated warnings
Reviewed-by: sspitsyn
--- a/test/hotspot/jtreg/serviceability/dcmd/jvmti/DataDumpDcmdTest.java Thu Feb 01 15:53:51 2018 -0800
+++ b/test/hotspot/jtreg/serviceability/dcmd/jvmti/DataDumpDcmdTest.java Thu Feb 01 21:03:37 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -27,6 +27,11 @@
import jdk.test.lib.dcmd.PidJcmdExecutor;
import org.testng.annotations.Test;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/*
* @test
* @bug 8054890
@@ -43,9 +48,19 @@
*/
public class DataDumpDcmdTest {
public void run(CommandExecutor executor) {
- OutputAnalyzer output = executor.execute("JVMTI.data_dump");
+ OutputAnalyzer out = executor.execute("JVMTI.data_dump");
- output.stderrShouldBeEmpty();
+ // stderr should be empty except for VM warnings.
+ if (!out.getStderr().isEmpty()) {
+ List<String> lines = Arrays.asList(out.getStderr().split("(\\r\\n|\\n|\\r)"));
+ Pattern p = Pattern.compile(".*VM warning.*");
+ for (String line : lines) {
+ Matcher m = p.matcher(line);
+ if (!m.matches()) {
+ throw new RuntimeException("Stderr has output other than VM warnings");
+ }
+ }
+ }
}
@Test
--- a/test/hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java Thu Feb 01 15:53:51 2018 -0800
+++ b/test/hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java Thu Feb 01 21:03:37 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, 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
@@ -22,10 +22,14 @@
*/
import java.io.*;
import java.nio.file.*;
+import java.util.Arrays;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import jdk.test.lib.Platform;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.dcmd.*;
@@ -97,6 +101,20 @@
}
}
+ static void checkWarningsOnly(OutputAnalyzer out) {
+ // stderr should be empty except for VM warnings.
+ if (!out.getStderr().isEmpty()) {
+ List<String> lines = Arrays.asList(out.getStderr().split("(\\r\\n|\\n|\\r)"));
+ Pattern p = Pattern.compile(".*VM warning.*");
+ for (String line : lines) {
+ Matcher m = p.matcher(line);
+ if (!m.matches()) {
+ throw new RuntimeException("Stderr has output other than VM warnings");
+ }
+ }
+ }
+ }
+
public void run(CommandExecutor executor) {
try{
@@ -108,22 +126,22 @@
// Test 1: Native agent, no arguments
output = executor.execute("JVMTI.agent_load " +
libpath + " agent.jar");
- output.stderrShouldBeEmpty();
+ checkWarningsOnly(output);
// Test 2: Native agent, with arguments
output = executor.execute("JVMTI.agent_load " +
libpath + " \"agent.jar=foo=bar\"");
- output.stderrShouldBeEmpty();
+ checkWarningsOnly(output);
// Test 3: Java agent, no arguments
output = executor.execute("JVMTI.agent_load " +
"agent.jar");
- output.stderrShouldBeEmpty();
+ checkWarningsOnly(output);
// Test 4: Java agent, with arguments
output = executor.execute("JVMTI.agent_load " +
"\"agent.jar=foo=bar\"");
- output.stderrShouldBeEmpty();
+ checkWarningsOnly(output);
} catch (Exception e) {
throw new RuntimeException(e);