# HG changeset patch # User jcbeyler # Date 1531875123 25200 # Node ID e3bcc86855ddb6cf4fd39e6cda8f658918fe4be0 # Parent 6d6611346837867d0a8a9bfd0dc7574804220f90 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 diff -r 6d6611346837 -r e3bcc86855dd test/hotspot/jtreg/ProblemList.txt --- 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 ############################################################################# diff -r 6d6611346837 -r e3bcc86855dd test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java --- 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; }