8194067: [Testbug] serviceability/sa/Jhsdb* tests can't tolerate unrelated warnings
authorsballal
Tue, 09 Jan 2018 15:21:19 +0530
changeset 48500 899a137688b8
parent 48499 239c7d9bb192
child 48501 f0e55fb9cfa3
8194067: [Testbug] serviceability/sa/Jhsdb* tests can't tolerate unrelated warnings Reviewed-by: dholmes, sspitsyn
test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java
test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java
--- a/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java	Mon Jan 08 17:32:54 2018 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java	Tue Jan 09 15:21:19 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -21,6 +21,11 @@
  * questions.
  */
 
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import jdk.test.lib.apps.LingeredApp;
 import jdk.test.lib.JDKToolLauncher;
 import jdk.test.lib.Platform;
@@ -69,7 +74,18 @@
             out.shouldMatch("   JavaThread state: _thread_.+");
 
             out.shouldNotContain("   java.lang.Thread.State: UNKNOWN");
-            out.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");
+                    }
+                }
+            }
 
             System.out.println("Test Completed");
         } catch (InterruptedException ie) {
--- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java	Mon Jan 08 17:32:54 2018 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java	Tue Jan 09 15:21:19 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -24,7 +24,11 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import jdk.test.lib.apps.LingeredApp;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.JDKToolLauncher;
@@ -76,7 +80,19 @@
             out.shouldMatch("^\\s+- waiting to lock <0x[0-9a-f]+> \\(a java\\.lang\\.Class for LingeredAppWithLock\\)$");
             out.shouldMatch("^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Thread\\)$");
             out.shouldMatch("^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Class for int\\)$");
-            out.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");
+                    }
+                }
+            }
+
 
             System.out.println("Test Completed");
         } finally {