8007890: [TESTBUG] JcmdWithNMTDisabled.java fails when invoked with NMT explicitly turned on
authorctornqvi
Thu, 27 Mar 2014 22:36:08 +0100
changeset 23516 b32d8f04648b
parent 23515 f4872ef5df09
child 23517 27c4307d6cda
8007890: [TESTBUG] JcmdWithNMTDisabled.java fails when invoked with NMT explicitly turned on Summary: Wrapped the test in another layer process creation to avoid NMT being turned on. Reviewed-by: coleenp, dcubed
hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java
--- a/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java	Wed Mar 26 21:47:45 2014 -0400
+++ b/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java	Thu Mar 27 22:36:08 2014 +0100
@@ -26,10 +26,7 @@
  * @key nmt jcmd
  * @summary Verify that jcmd correctly reports that NMT is not enabled
  * @library /testlibrary
- * First run without enabling NMT
- * @run main/othervm JcmdWithNMTDisabled
- * Then run with explicitly disabling NMT, should not be any difference
- * @run main/othervm -XX:NativeMemoryTracking=off JcmdWithNMTDisabled
+ * @run main JcmdWithNMTDisabled 1
  */
 
 import com.oracle.java.testlibrary.*;
@@ -39,6 +36,27 @@
   static String pid;
 
   public static void main(String args[]) throws Exception {
+
+    // This test explicitly needs to be run with the exact command lines below, not passing on
+    // arguments from the parent VM is a conscious choice to avoid NMT being turned on.
+    if (args.length > 0) {
+      ProcessBuilder pb;
+      OutputAnalyzer output;
+      String testjdkPath = System.getProperty("test.jdk");
+
+      // First run without enabling NMT
+      pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "JcmdWithNMTDisabled");
+      output = new OutputAnalyzer(pb.start());
+      output.shouldHaveExitValue(0);
+
+      // Then run with explicitly disabling NMT, should not be any difference
+      pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "-XX:NativeMemoryTracking=off", "JcmdWithNMTDisabled");
+      output = new OutputAnalyzer(pb.start());
+      output.shouldHaveExitValue(0);
+
+      return;
+    }
+
     // Grab my own PID
     pid = Integer.toString(ProcessTools.getProcessId());