8205541: serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java fails with Should not have any events stored yet.
authorjcbeyler
Tue, 17 Jul 2018 15:09:27 -0700
changeset 51136 6d6611346837
parent 51135 610d15624bdd
child 51137 e3bcc86855dd
8205541: serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java fails with Should not have any events stored yet. Summary: Fix StatArray and StatObject tests 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/HeapMonitorStatArrayCorrectnessTest.java
test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java
test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.c
--- a/test/hotspot/jtreg/ProblemList.txt	Tue Jul 17 11:20:16 2018 -0700
+++ b/test/hotspot/jtreg/ProblemList.txt	Tue Jul 17 15:09:27 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/HeapMonitorStatArrayCorrectnessTest.java 8205541 generic-all
 serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java 8205652 generic-all
 
 #############################################################################
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java	Tue Jul 17 11:20:16 2018 -0700
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java	Tue Jul 17 15:09:27 2018 -0700
@@ -46,8 +46,6 @@
   public static void main(String[] args) {
     int sizes[] = {1000, 10000, 100000};
 
-    HeapMonitor.enableSamplingEvents();
-
     for (int currentSize : sizes) {
       System.out.println("Testing size " + currentSize);
 
@@ -56,12 +54,16 @@
         throw new RuntimeException("Should not have any events stored yet.");
       }
 
+      HeapMonitor.enableSamplingEvents();
+
       // 111 is as good a number as any.
       final int samplingMultiplier = 111;
       HeapMonitor.setSamplingRate(samplingMultiplier * currentSize);
 
       allocate(currentSize);
 
+      HeapMonitor.disableSamplingEvents();
+
       // For simplifications, we ignore the array memory usage for array internals (with the array
       // sizes requested, it should be a negligible oversight).
       //
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java	Tue Jul 17 11:20:16 2018 -0700
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java	Tue Jul 17 15:09:27 2018 -0700
@@ -41,9 +41,13 @@
   private native static boolean statsHaveExpectedNumberSamples(int expected, int percentError);
 
   private static void allocate() {
+    emptyStorage();
+
+    HeapMonitor.enableSamplingEvents();
     for (int j = 0; j < maxIteration; j++) {
       obj = new BigObject();
     }
+    HeapMonitor.disableSamplingEvents();
   }
 
   private static void testBigAllocationRate() {
@@ -53,7 +57,6 @@
     final int samplingMultiplier = 111;
     HeapMonitor.setSamplingRate(samplingMultiplier * sizeObject);
 
-    emptyStorage();
     allocate();
 
     // For simplifications, the code is allocating:
@@ -96,7 +99,6 @@
     // 0 means sample every allocation.
     HeapMonitor.setSamplingRate(0);
 
-    emptyStorage();
     allocate();
 
     double expected = maxIteration;
@@ -111,8 +113,6 @@
   }
 
   public static void main(String[] args) {
-    HeapMonitor.enableSamplingEvents();
-
     testBigAllocationRate();
     testEveryAllocationSampled();
   }
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.c	Tue Jul 17 11:20:16 2018 -0700
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.c	Tue Jul 17 15:09:27 2018 -0700
@@ -45,7 +45,7 @@
 
 #define TRUE 1
 #define FALSE 0
-#define PRINT_OUT 0
+#define PRINT_OUT 1
 
 static jvmtiEnv *jvmti = NULL;
 static jvmtiEnv *second_jvmti = NULL;