8205652: serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java fails
authorjcbeyler
Tue, 17 Jul 2018 17:52:03 -0700
changeset 51137 e3bcc86855dd
parent 51136 6d6611346837
child 51138 914f305ba6fa
8205652: serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java fails Summary: Fix the StatRateTest test from the HeapMonitor package Reviewed-by: amenkov, sspitsyn Contributed-by: jcbeyler@google.com
test/hotspot/jtreg/ProblemList.txt
test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java
--- a/test/hotspot/jtreg/ProblemList.txt	Tue Jul 17 15:09:27 2018 -0700
+++ b/test/hotspot/jtreg/ProblemList.txt	Tue Jul 17 17:52:03 2018 -0700
@@ -81,7 +81,6 @@
 
 serviceability/sa/TestRevPtrsForInvokeDynamic.java   8191270 generic-all
 serviceability/sa/sadebugd/SADebugDTest.java         8163805 generic-all
-serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java 8205652 generic-all
 
 #############################################################################
 
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java	Tue Jul 17 15:09:27 2018 -0700
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java	Tue Jul 17 17:52:03 2018 -0700
@@ -43,24 +43,30 @@
     HeapMonitor.enableSamplingEvents();
 
     int allocationTotal = 10 * 1024 * 1024;
-    HeapMonitor.allocateSize(allocationTotal);
+    int allocationIterations = 10;
+
+    double actualCount = 0;
+    for (int i = 0; i < allocationIterations; i++) {
+      HeapMonitor.resetEventStorage();
+      HeapMonitor.allocateSize(allocationTotal);
+      actualCount += HeapMonitor.getEventStorageElementCount();
+    }
 
     HeapMonitor.disableSamplingEvents();
 
-    double actualCount = HeapMonitor.getEventStorageElementCount();
-    double expectedCount = allocationTotal / rate;
+    double expectedCount = allocationTotal * allocationIterations / rate;
 
     double error = Math.abs(actualCount - expectedCount);
     double errorPercentage = error / expectedCount * 100;
 
-    boolean failure = (errorPercentage > 10.0);
+    boolean success = (errorPercentage < 10.0);
 
-    if (failure && throwIfFailure) {
+    if (!success && throwIfFailure) {
       throw new RuntimeException("Rate average over 10% for rate " + rate + " -> " + actualCount
           + ", " + expectedCount);
     }
 
-    return failure;
+    return success;
   }