8231288: "jhsdb jmap" test needed to reproduce issues that used to be reproduced by JShellHeapDumpTest
authorcjplummer
Wed, 02 Oct 2019 17:56:46 -0700
changeset 58448 f45278353668
parent 58447 319173c62caa
child 58449 e606e9b6ba7a
8231288: "jhsdb jmap" test needed to reproduce issues that used to be reproduced by JShellHeapDumpTest Reviewed-by: sgehwolf, sspitsyn
test/jdk/ProblemList.txt
test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java
test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java
--- a/test/jdk/ProblemList.txt	Wed Oct 02 16:55:08 2019 -0700
+++ b/test/jdk/ProblemList.txt	Wed Oct 02 17:56:46 2019 -0700
@@ -861,6 +861,8 @@
 sun/tools/jstat/jstatClassloadOutput1.sh                        8173942 generic-all
 sun/tools/jhsdb/BasicLauncherTest.java                          8193639,8211767 solaris-all,linux-ppc64,linux-ppc64le
 sun/tools/jhsdb/HeapDumpTest.java                               8193639 solaris-all
+sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java              8230731,8001227 windows-all
+sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java              8231635,8231634 generic-all
 
 
 ############################################################################
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java	Wed Oct 02 17:56:46 2019 -0700
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2019, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug  8230731 8001227 8231635 8231634 8196969
+ * @requires vm.hasSAandCanAttach
+ * @library /test/lib
+ * @compile JShellHeapDumpTest.java
+ * @run main/timeout=240 JShellHeapDumpTest nosleep
+ */
--- a/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java	Wed Oct 02 16:55:08 2019 -0700
+++ b/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java	Wed Oct 02 17:56:46 2019 -0700
@@ -48,7 +48,8 @@
 
 public class JShellHeapDumpTest {
 
-    protected static Process jShellProcess;
+    static Process jShellProcess;
+    static boolean doSleep = true; // By default do a short sleep when app starts up
 
     public static void launch(String expectedMessage, List<String> toolArgs)
         throws IOException {
@@ -141,13 +142,23 @@
 
         // Give jshell a chance to fully start up. This makes SA more stable for the jmap dump.
         try {
-            Thread.sleep(2000);
+            if (doSleep) {
+                Thread.sleep(2000);
+            }
         } catch (Exception e) {
         }
     }
 
     public static void main(String[] args) throws Exception {
-
+        if (args.length == 1) {
+            if (args[0].equals("nosleep")) {
+                doSleep = false;
+            } else {
+                throw new RuntimeException("Invalid arg: " + args[0]);
+            }
+        } else if (args.length != 0) {
+            throw new RuntimeException("Too many args: " + args.length);
+        }
         testHeapDump();
 
         // The test throws RuntimeException on error.