6971847: 4/4 jmap '-histo:live' option is necessary for proper leak detection
authordcubed
Mon, 26 Jul 2010 09:06:47 -0700
changeset 6125 f919e72613e5
parent 6124 ba148d56813d
child 6126 bf66999384ac
6971847: 4/4 jmap '-histo:live' option is necessary for proper leak detection Summary: Add work around for 6971851. Abort if 'histo:live' option isn't supported. Reviewed-by: alanb, darcy
jdk/test/java/util/logging/AnonLoggerWeakRefLeak.sh
jdk/test/java/util/logging/LoggerWeakRefLeak.sh
--- a/jdk/test/java/util/logging/AnonLoggerWeakRefLeak.sh	Mon Jul 26 08:17:50 2010 -0700
+++ b/jdk/test/java/util/logging/AnonLoggerWeakRefLeak.sh	Mon Jul 26 09:06:47 2010 -0700
@@ -59,9 +59,34 @@
 status="$?"
 set -e
 if [ "$status" != 0 ]; then
-    echo "INFO: switching jmap option from '$jmap_option'\c"
-    jmap_option="-histo"
-    echo " to '$jmap_option'."
+    # usage message doesn't show ':live' option
+
+    if $isWindows; then
+        # If SA isn't present, then jmap gives a different usage message
+        # that doesn't show the ':live' option. However, that's a bug that
+        # is covered by 6971851 so we try using the option just to be sure.
+        # For some reason, this problem has only been seen on OpenJDK6 on
+        # Windows. Not sure why.
+        set +e
+        # Note: Don't copy this code to try probing process 0 on Linux; it
+        # will kill the process group in strange ways.
+        "${JMAP}" "$jmap_option" 0 2>&1 | grep 'Usage' > /dev/null 2>&1
+        status="$?"
+        set -e
+        if [ "$status" = 0 ]; then
+            # Usage message generated so flag the problem.
+            status=1
+        else
+            # No usage message so clear the flag.
+            status=0
+        fi
+    fi
+
+    if [ "$status" != 0 ]; then
+        echo "ERROR: 'jmap $jmap_option' is not supported so this test"
+        echo "ERROR: cannot work reliably. Aborting!"
+        exit 2
+    fi
 fi
 
 # Start application and use TEST_NAME.port for coordination
--- a/jdk/test/java/util/logging/LoggerWeakRefLeak.sh	Mon Jul 26 08:17:50 2010 -0700
+++ b/jdk/test/java/util/logging/LoggerWeakRefLeak.sh	Mon Jul 26 09:06:47 2010 -0700
@@ -59,9 +59,34 @@
 status="$?"
 set -e
 if [ "$status" != 0 ]; then
-    echo "INFO: switching jmap option from '$jmap_option'\c"
-    jmap_option="-histo"
-    echo " to '$jmap_option'."
+    # usage message doesn't show ':live' option
+
+    if $isWindows; then
+        # If SA isn't present, then jmap gives a different usage message
+        # that doesn't show the ':live' option. However, that's a bug that
+        # is covered by 6971851 so we try using the option just to be sure.
+        # For some reason, this problem has only been seen on OpenJDK6 on
+        # Windows. Not sure why.
+        set +e
+        # Note: Don't copy this code to try probing process 0 on Linux; it
+        # will kill the process group in strange ways.
+        "${JMAP}" "$jmap_option" 0 2>&1 | grep 'Usage' > /dev/null 2>&1
+        status="$?"
+        set -e
+        if [ "$status" = 0 ]; then
+            # Usage message generated so flag the problem.
+            status=1
+        else
+            # No usage message so clear the flag.
+            status=0
+        fi
+    fi
+
+    if [ "$status" != 0 ]; then
+        echo "ERROR: 'jmap $jmap_option' is not supported so this test"
+        echo "ERROR: cannot work reliably. Aborting!"
+        exit 2
+    fi
 fi
 
 # Start application and use TEST_NAME.port for coordination