8028647: Add instrumentation in GetSafepointSyncTime.java and remove it from ProblemList.txt
authormchung
Wed, 20 Nov 2013 10:00:54 -0800
changeset 21829 a3cac8b5ca51
parent 21828 5c9519eb783c
child 21830 668b2337f339
8028647: Add instrumentation in GetSafepointSyncTime.java and remove it from ProblemList.txt Reviewed-by: sla, chegar
jdk/test/ProblemList.txt
jdk/test/sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java
--- a/jdk/test/ProblemList.txt	Wed Nov 20 13:12:04 2013 +0100
+++ b/jdk/test/ProblemList.txt	Wed Nov 20 10:00:54 2013 -0800
@@ -129,9 +129,6 @@
 
 # jdk_management
 
-# 8010897
-sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java	macosx-all
-
 # 8028150
 sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh	windows-all
 
--- a/jdk/test/sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java	Wed Nov 20 13:12:04 2013 +0100
+++ b/jdk/test/sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java	Wed Nov 20 10:00:54 2013 -0800
@@ -45,12 +45,9 @@
     private static final long MIN_VALUE_FOR_PASS = 1;
     private static final long MAX_VALUE_FOR_PASS = Long.MAX_VALUE;
 
-    private static boolean trace = false;
-
     public static void main(String args[]) throws Exception {
-        if (args.length > 0 && args[0].equals("trace")) {
-            trace = true;
-        }
+        long count = mbean.getSafepointCount();
+        long value = mbean.getSafepointSyncTime();
 
         // Thread.getAllStackTraces() should cause safepoints.
         // If this test is failing because it doesn't,
@@ -59,15 +56,15 @@
             Thread.getAllStackTraces();
         }
 
-        long value = mbean.getSafepointSyncTime();
+        long count1 = mbean.getSafepointCount();
+        long value1 = mbean.getSafepointSyncTime();
 
-        if (trace) {
-            System.out.println("Safepoint sync time (ms): " + value);
-        }
+        System.out.format("Safepoint count=%d (diff=%d), sync time=%d ms (diff=%d)%n",
+                          count1, count1-count, value1, value1-value);
 
-        if (value < MIN_VALUE_FOR_PASS || value > MAX_VALUE_FOR_PASS) {
+        if (value1 < MIN_VALUE_FOR_PASS || value1 > MAX_VALUE_FOR_PASS) {
             throw new RuntimeException("Safepoint sync time " +
-                                       "illegal value: " + value + " ms " +
+                                       "illegal value: " + value1 + " ms " +
                                        "(MIN = " + MIN_VALUE_FOR_PASS + "; " +
                                        "MAX = " + MAX_VALUE_FOR_PASS + ")");
         }
@@ -76,16 +73,16 @@
             Thread.getAllStackTraces();
         }
 
+        long count2 = mbean.getSafepointCount();
         long value2 = mbean.getSafepointSyncTime();
 
-        if (trace) {
-            System.out.println("Safepoint sync time2 (ms): " + value2);
-        }
+        System.out.format("Safepoint count=%d (diff=%d), sync time=%d ms (diff=%d)%n",
+                          count2, count2-count1, value2, value2-value1);
 
-        if (value2 <= value) {
+        if (value2 <= value1) {
             throw new RuntimeException("Safepoint sync time " +
                                        "did not increase " +
-                                       "(value = " + value + "; " +
+                                       "(value1 = " + value1 + "; " +
                                        "value2 = " + value2 + ")");
         }