< prev index next >

test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorVMEventsTest.java

Print this page
*** 29,17 ***
  
  // Graal is not tested here due to Graal not supporting DisableIntrinsic.
  /**
   * @test
   * @summary Verifies that when the VM event is sent, sampled events are also collected.
   * @build Frame HeapMonitor
!  * @compile HeapMonitorVMEventsTest.java
   * @requires vm.jvmti
   * @requires !vm.graal.enabled
!  * @run main/othervm/native -XX:+UnlockDiagnosticVMOptions
   *                          -XX:DisableIntrinsic=_clone
!  *                          -agentlib:HeapMonitorTest MyPackage.HeapMonitorVMEventsTest
   */
  
  public class HeapMonitorVMEventsTest implements Cloneable {
    private static native int vmEvents();
    private static final int ITERATIONS = 1 << 15;
--- 29,31 ---
  
  // Graal is not tested here due to Graal not supporting DisableIntrinsic.
  /**
   * @test
   * @summary Verifies that when the VM event is sent, sampled events are also collected.
+  * @requires vm.jvmti
+  * @requires !vm.graal.enabled
   * @build Frame HeapMonitor
!  * @compile --enable-preview -source ${jdk.version} HeapMonitorVMEventsTest.java
+  * @run main/othervm/native --enable-preview
+  *                          -XX:+UnlockDiagnosticVMOptions
+  *                          -XX:DisableIntrinsic=_clone
+  *                          -agentlib:HeapMonitorTest MyPackage.HeapMonitorVMEventsTest platform
+  */
+ 
+ /**
+  * @test
+  * @summary Verifies that when the VM event is sent, sampled events are also collected.
   * @requires vm.jvmti
   * @requires !vm.graal.enabled
!  * @build Frame HeapMonitor
+  * @compile --enable-preview -source ${jdk.version} HeapMonitorVMEventsTest.java
+  * @run main/othervm/native --enable-preview
+  *                          -XX:+UnlockDiagnosticVMOptions
   *                          -XX:DisableIntrinsic=_clone
!  *                          -agentlib:HeapMonitorTest MyPackage.HeapMonitorVMEventsTest virtual
   */
  
  public class HeapMonitorVMEventsTest implements Cloneable {
    private static native int vmEvents();
    private static final int ITERATIONS = 1 << 15;

*** 92,14 ***
      System.err.println("Obtained: " + onlySampleCount + " - " + sampleCount + " - "  + vmCount);
      checkDifference(onlySampleCount, sampleCount);
      checkDifference(onlySampleCount, vmCount);
    }
  
!   public static void main(String[] args) {
      if (!HeapMonitor.eventStorageIsEmpty()) {
        throw new RuntimeException("Storage is not empty at test start...");
      }
  
      HeapMonitor.sampleEverything();
!     compareSampledAndVM();
    }
  }
--- 106,22 ---
      System.err.println("Obtained: " + onlySampleCount + " - " + sampleCount + " - "  + vmCount);
      checkDifference(onlySampleCount, sampleCount);
      checkDifference(onlySampleCount, vmCount);
    }
  
!   public static void main(String[] args) throws Exception {
      if (!HeapMonitor.eventStorageIsEmpty()) {
        throw new RuntimeException("Storage is not empty at test start...");
      }
  
      HeapMonitor.sampleEverything();
! 
+     if(args[0].equals("virtual")) {
+         Thread t = Thread.ofVirtual().start(() -> {
+                 compareSampledAndVM();
+             });
+         t.join();
+     } else {
+         compareSampledAndVM();
+     }
    }
  }
< prev index next >