test/runtime/NMT/JcmdWithNMTDisabled.java
Print this page
@@ -24,23 +24,39 @@
/*
* @test
* @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.*;
public class JcmdWithNMTDisabled {
static ProcessBuilder pb = new ProcessBuilder();
static String pid;
public static void main(String args[]) throws Exception {
+
+ 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());
jcmdCommand("summary");
jcmdCommand("detail");