8005013: Add NMT tests

Sat, 02 Feb 2013 16:34:10 +0100

author
ctornqvi
date
Sat, 02 Feb 2013 16:34:10 +0100
changeset 4518
879c6de913d6
parent 4517
ff5401ad5635
child 4519
a7f9a1195d86

8005013: Add NMT tests
Summary: Add tests for the Native Memory Tracking feature, includes regression tests for 8005936 and 8004802
Reviewed-by: zgu, coleenp

test/TEST.ROOT file | annotate | diff | comparison | revisions
test/runtime/NMT/AllocTestType.java file | annotate | diff | comparison | revisions
test/runtime/NMT/BaselineWithParameter.java file | annotate | diff | comparison | revisions
test/runtime/NMT/CommandLineDetail.java file | annotate | diff | comparison | revisions
test/runtime/NMT/CommandLineEmptyArgument.java file | annotate | diff | comparison | revisions
test/runtime/NMT/CommandLineInvalidArgument.java file | annotate | diff | comparison | revisions
test/runtime/NMT/CommandLineSummary.java file | annotate | diff | comparison | revisions
test/runtime/NMT/CommandLineTurnOffNMT.java file | annotate | diff | comparison | revisions
test/runtime/NMT/JcmdScale.java file | annotate | diff | comparison | revisions
test/runtime/NMT/JcmdWithNMTDisabled.java file | annotate | diff | comparison | revisions
test/runtime/NMT/PrintNMTStatistics.java file | annotate | diff | comparison | revisions
test/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java file | annotate | diff | comparison | revisions
test/runtime/NMT/ShutdownTwice.java file | annotate | diff | comparison | revisions
test/runtime/NMT/SummaryAfterShutdown.java file | annotate | diff | comparison | revisions
test/runtime/NMT/SummarySanityCheck.java file | annotate | diff | comparison | revisions
     1.1 --- a/test/TEST.ROOT	Sat Feb 02 03:51:01 2013 -0800
     1.2 +++ b/test/TEST.ROOT	Sat Feb 02 16:34:10 2013 +0100
     1.3 @@ -28,4 +28,4 @@
     1.4  # DO NOT EDIT without first contacting hotspot-regtest@sun.com
     1.5  
     1.6  # The list of keywords supported in this test suite
     1.7 -keys=cte_test
     1.8 +keys=cte_test jcmd nmt regression
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/runtime/NMT/AllocTestType.java	Sat Feb 02 16:34:10 2013 +0100
     2.3 @@ -0,0 +1,72 @@
     2.4 +/*
     2.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test
    2.29 + * @summary Test consistency of NMT by leaking a few select allocations of the Test type and then verify visibility with jcmd
    2.30 + * @key nmt jcmd
    2.31 + * @library /testlibrary
    2.32 + * @run compile -J-XX:+UnlockDiagnosticVMOptions -J-XX:+WhiteBoxAPI AllocTestType.java
    2.33 + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail AllocTestType
    2.34 + */
    2.35 +
    2.36 +import com.oracle.java.testlibrary.*;
    2.37 +import sun.hotspot.WhiteBox;
    2.38 +
    2.39 +public class AllocTestType {
    2.40 +
    2.41 +  public static void main(String args[]) throws Exception {
    2.42 +    OutputAnalyzer output;
    2.43 +
    2.44 +    // Grab my own PID
    2.45 +    String pid = Integer.toString(ProcessTools.getProcessId());
    2.46 +    ProcessBuilder pb = new ProcessBuilder();
    2.47 +
    2.48 +    // Use WB API to alloc with the mtTest type
    2.49 +    if (!WhiteBox.getWhiteBox().NMTAllocTest()) {
    2.50 +      throw new Exception("Call to WB API NMTAllocTest() failed");
    2.51 +    }
    2.52 +
    2.53 +    // Use WB API to ensure that all data has been merged before we continue
    2.54 +    if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
    2.55 +      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
    2.56 +    }
    2.57 +
    2.58 +    // Run 'jcmd <pid> VM.native_memory summary'
    2.59 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
    2.60 +    output = new OutputAnalyzer(pb.start());
    2.61 +    output.shouldContain("Test (reserved=512KB, committed=512KB)");
    2.62 +
    2.63 +    // Free the memory allocated by NMTAllocTest
    2.64 +    if (!WhiteBox.getWhiteBox().NMTFreeTestMemory()) {
    2.65 +      throw new Exception("Call to WB API NMTFreeTestMemory() failed");
    2.66 +    }
    2.67 +
    2.68 +    // Use WB API to ensure that all data has been merged before we continue
    2.69 +    if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
    2.70 +      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
    2.71 +    }
    2.72 +    output = new OutputAnalyzer(pb.start());
    2.73 +    output.shouldNotContain("Test (reserved=");
    2.74 +  }
    2.75 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/runtime/NMT/BaselineWithParameter.java	Sat Feb 02 16:34:10 2013 +0100
     3.3 @@ -0,0 +1,54 @@
     3.4 +/*
     3.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +/*
    3.28 + * @test
    3.29 + * @bug 8004802
    3.30 + * @key nmt jcmd regression
    3.31 + * @summary Regression test for invoking a jcmd with baseline=false, result was that the target VM crashed
    3.32 + * @library /testlibrary
    3.33 + * @run main/othervm -XX:NativeMemoryTracking=detail BaselineWithParameter
    3.34 + */
    3.35 +
    3.36 +import com.oracle.java.testlibrary.*;
    3.37 +
    3.38 +public class BaselineWithParameter {
    3.39 +
    3.40 +  public static void main(String args[]) throws Exception {
    3.41 +    // Grab my own PID
    3.42 +    String pid = Integer.toString(ProcessTools.getProcessId());
    3.43 +    OutputAnalyzer output;
    3.44 +
    3.45 +    ProcessBuilder pb = new ProcessBuilder();
    3.46 +
    3.47 +    // Run 'jcmd <pid> VM.native_memory baseline=false'
    3.48 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "baseline=false"});
    3.49 +    pb.start();
    3.50 +
    3.51 +    // Run 'jcmd <pid> VM.native_memory summary=false'
    3.52 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary=false"});
    3.53 +    output = new OutputAnalyzer(pb.start());
    3.54 +    output.shouldContain("No command to execute");
    3.55 +
    3.56 +  }
    3.57 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/runtime/NMT/CommandLineDetail.java	Sat Feb 02 16:34:10 2013 +0100
     4.3 @@ -0,0 +1,45 @@
     4.4 +/*
     4.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.
    4.11 + *
    4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.15 + * version 2 for more details (a copy is included in the LICENSE file that
    4.16 + * accompanied this code).
    4.17 + *
    4.18 + * You should have received a copy of the GNU General Public License version
    4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.21 + *
    4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.23 + * or visit www.oracle.com if you need additional information or have any
    4.24 + * questions.
    4.25 + */
    4.26 +
    4.27 + /*
    4.28 + * @test
    4.29 + * @key nmt
    4.30 + * @summary Running with NMT detail should not result in an error or warning
    4.31 + * @library /testlibrary
    4.32 + */
    4.33 +
    4.34 +import com.oracle.java.testlibrary.*;
    4.35 +
    4.36 +public class CommandLineDetail {
    4.37 +
    4.38 +  public static void main(String args[]) throws Exception {
    4.39 +
    4.40 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    4.41 +      "-XX:NativeMemoryTracking=detail",
    4.42 +      "-version");
    4.43 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    4.44 +    output.shouldNotContain("error");
    4.45 +    output.shouldNotContain("warning");
    4.46 +    output.shouldHaveExitValue(0);
    4.47 +  }
    4.48 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/runtime/NMT/CommandLineEmptyArgument.java	Sat Feb 02 16:34:10 2013 +0100
     5.3 @@ -0,0 +1,41 @@
     5.4 +/*
     5.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.
    5.11 + *
    5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.15 + * version 2 for more details (a copy is included in the LICENSE file that
    5.16 + * accompanied this code).
    5.17 + *
    5.18 + * You should have received a copy of the GNU General Public License version
    5.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.21 + *
    5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.23 + * or visit www.oracle.com if you need additional information or have any
    5.24 + * questions.
    5.25 + */
    5.26 +
    5.27 + /*
    5.28 + * @test
    5.29 + * @key nmt
    5.30 + * @summary Empty argument to NMT should result in an informative error message
    5.31 + * @library /testlibrary
    5.32 + */
    5.33 +
    5.34 +import com.oracle.java.testlibrary.*;
    5.35 +
    5.36 +public class CommandLineEmptyArgument {
    5.37 +
    5.38 +  public static void main(String args[]) throws Exception {
    5.39 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:NativeMemoryTracking=");
    5.40 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    5.41 +    output.shouldContain("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]");
    5.42 +    output.shouldHaveExitValue(1);
    5.43 +  }
    5.44 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/runtime/NMT/CommandLineInvalidArgument.java	Sat Feb 02 16:34:10 2013 +0100
     6.3 @@ -0,0 +1,41 @@
     6.4 +/*
     6.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.
    6.11 + *
    6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 + * version 2 for more details (a copy is included in the LICENSE file that
    6.16 + * accompanied this code).
    6.17 + *
    6.18 + * You should have received a copy of the GNU General Public License version
    6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 + *
    6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.23 + * or visit www.oracle.com if you need additional information or have any
    6.24 + * questions.
    6.25 + */
    6.26 +
    6.27 + /*
    6.28 + * @test
    6.29 + * @key nmt
    6.30 + * @summary Invalid argument to NMT should result in an informative error message
    6.31 + * @library /testlibrary
    6.32 + */
    6.33 +
    6.34 +import com.oracle.java.testlibrary.*;
    6.35 +
    6.36 +public class CommandLineInvalidArgument {
    6.37 +
    6.38 +  public static void main(String args[]) throws Exception {
    6.39 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:NativeMemoryTracking=apa");
    6.40 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    6.41 +    output.shouldContain("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]");
    6.42 +    output.shouldHaveExitValue(1);
    6.43 +  }
    6.44 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/test/runtime/NMT/CommandLineSummary.java	Sat Feb 02 16:34:10 2013 +0100
     7.3 @@ -0,0 +1,45 @@
     7.4 +/*
     7.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 + *
     7.8 + * This code is free software; you can redistribute it and/or modify it
     7.9 + * under the terms of the GNU General Public License version 2 only, as
    7.10 + * published by the Free Software Foundation.
    7.11 + *
    7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.15 + * version 2 for more details (a copy is included in the LICENSE file that
    7.16 + * accompanied this code).
    7.17 + *
    7.18 + * You should have received a copy of the GNU General Public License version
    7.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.21 + *
    7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    7.23 + * or visit www.oracle.com if you need additional information or have any
    7.24 + * questions.
    7.25 + */
    7.26 +
    7.27 + /*
    7.28 + * @test
    7.29 + * @key nmt
    7.30 + * @summary Running with NMT summary should not result in an error or warning
    7.31 + * @library /testlibrary
    7.32 + */
    7.33 +
    7.34 +import com.oracle.java.testlibrary.*;
    7.35 +
    7.36 +public class CommandLineSummary {
    7.37 +
    7.38 +  public static void main(String args[]) throws Exception {
    7.39 +
    7.40 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    7.41 +      "-XX:NativeMemoryTracking=summary",
    7.42 +      "-version");
    7.43 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    7.44 +    output.shouldNotContain("error");
    7.45 +    output.shouldNotContain("warning");
    7.46 +    output.shouldHaveExitValue(0);
    7.47 +  }
    7.48 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/runtime/NMT/CommandLineTurnOffNMT.java	Sat Feb 02 16:34:10 2013 +0100
     8.3 @@ -0,0 +1,44 @@
     8.4 +/*
     8.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 + *
     8.8 + * This code is free software; you can redistribute it and/or modify it
     8.9 + * under the terms of the GNU General Public License version 2 only, as
    8.10 + * published by the Free Software Foundation.
    8.11 + *
    8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.15 + * version 2 for more details (a copy is included in the LICENSE file that
    8.16 + * accompanied this code).
    8.17 + *
    8.18 + * You should have received a copy of the GNU General Public License version
    8.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.21 + *
    8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    8.23 + * or visit www.oracle.com if you need additional information or have any
    8.24 + * questions.
    8.25 + */
    8.26 +
    8.27 + /*
    8.28 + * @test
    8.29 + * @key nmt
    8.30 + * @summary Turning off NMT should not result in an error or warning
    8.31 + * @library /testlibrary
    8.32 + */
    8.33 +
    8.34 +import com.oracle.java.testlibrary.*;
    8.35 +
    8.36 +public class CommandLineTurnOffNMT {
    8.37 +
    8.38 +  public static void main(String args[]) throws Exception {
    8.39 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    8.40 +              "-XX:NativeMemoryTracking=off",
    8.41 +              "-version");
    8.42 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    8.43 +    output.shouldNotContain("error");
    8.44 +    output.shouldNotContain("warning");
    8.45 +    output.shouldHaveExitValue(0);
    8.46 +  }
    8.47 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/test/runtime/NMT/JcmdScale.java	Sat Feb 02 16:34:10 2013 +0100
     9.3 @@ -0,0 +1,67 @@
     9.4 +/*
     9.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 + *
     9.8 + * This code is free software; you can redistribute it and/or modify it
     9.9 + * under the terms of the GNU General Public License version 2 only, as
    9.10 + * published by the Free Software Foundation.
    9.11 + *
    9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.15 + * version 2 for more details (a copy is included in the LICENSE file that
    9.16 + * accompanied this code).
    9.17 + *
    9.18 + * You should have received a copy of the GNU General Public License version
    9.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.21 + *
    9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    9.23 + * or visit www.oracle.com if you need additional information or have any
    9.24 + * questions.
    9.25 + */
    9.26 +
    9.27 +/*
    9.28 + * @test
    9.29 + * @key nmt jcmd
    9.30 + * @summary Test the NMT scale parameter
    9.31 + * @library /testlibrary
    9.32 + * @run main/othervm -XX:NativeMemoryTracking=summary JcmdScale
    9.33 + */
    9.34 +
    9.35 +import com.oracle.java.testlibrary.*;
    9.36 +
    9.37 +public class JcmdScale {
    9.38 +
    9.39 +  public static void main(String args[]) throws Exception {
    9.40 +    ProcessBuilder pb = new ProcessBuilder();
    9.41 +    OutputAnalyzer output;
    9.42 +    // Grab my own PID
    9.43 +    String pid = Integer.toString(ProcessTools.getProcessId());
    9.44 +
    9.45 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"});
    9.46 +    output = new OutputAnalyzer(pb.start());
    9.47 +    output.shouldContain("KB,  committed=");
    9.48 +
    9.49 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=MB"});
    9.50 +    output = new OutputAnalyzer(pb.start());
    9.51 +    output.shouldContain("MB,  committed=");
    9.52 +
    9.53 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=GB"});
    9.54 +    output = new OutputAnalyzer(pb.start());
    9.55 +    output.shouldContain("GB,  committed=");
    9.56 +
    9.57 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=apa"});
    9.58 +    output = new OutputAnalyzer(pb.start());
    9.59 +    output.shouldContain("Incorrect scale value: apa");
    9.60 +
    9.61 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=GB"});
    9.62 +    output = new OutputAnalyzer(pb.start());
    9.63 +    output.shouldContain("GB,  committed=");
    9.64 +
    9.65 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=apa"});
    9.66 +    output = new OutputAnalyzer(pb.start());
    9.67 +    output.shouldContain("Incorrect scale value: apa");
    9.68 +
    9.69 +  }
    9.70 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/runtime/NMT/JcmdWithNMTDisabled.java	Sat Feb 02 16:34:10 2013 +0100
    10.3 @@ -0,0 +1,63 @@
    10.4 +/*
    10.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 + *
    10.8 + * This code is free software; you can redistribute it and/or modify it
    10.9 + * under the terms of the GNU General Public License version 2 only, as
   10.10 + * published by the Free Software Foundation.
   10.11 + *
   10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.15 + * version 2 for more details (a copy is included in the LICENSE file that
   10.16 + * accompanied this code).
   10.17 + *
   10.18 + * You should have received a copy of the GNU General Public License version
   10.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.21 + *
   10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.23 + * or visit www.oracle.com if you need additional information or have any
   10.24 + * questions.
   10.25 + */
   10.26 +
   10.27 +/*
   10.28 + * @test
   10.29 + * @key nmt jcmd
   10.30 + * @summary Verify that jcmd correctly reports that NMT is not enabled
   10.31 + * @library /testlibrary
   10.32 + * First run without enabling NMT
   10.33 + * @run main/othervm JcmdWithNMTDisabled
   10.34 + * Then run with explicitly disabling NMT, should not be any difference
   10.35 + * @run main/othervm -XX:NativeMemoryTracking=off JcmdWithNMTDisabled
   10.36 + */
   10.37 +
   10.38 +import com.oracle.java.testlibrary.*;
   10.39 +
   10.40 +public class JcmdWithNMTDisabled {
   10.41 +  static ProcessBuilder pb = new ProcessBuilder();
   10.42 +  static String pid;
   10.43 +
   10.44 +  public static void main(String args[]) throws Exception {
   10.45 +    // Grab my own PID
   10.46 +    pid = Integer.toString(ProcessTools.getProcessId());
   10.47 +
   10.48 +    jcmdCommand("summary");
   10.49 +    jcmdCommand("detail");
   10.50 +    jcmdCommand("baseline");
   10.51 +    jcmdCommand("summary.diff");
   10.52 +    jcmdCommand("detail.diff");
   10.53 +    jcmdCommand("scale=GB");
   10.54 +    jcmdCommand("shutdown");
   10.55 +  }
   10.56 +
   10.57 +  // Helper method for invoking different jcmd calls, all should fail with the same message saying NMT is not enabled
   10.58 +  public static void jcmdCommand(String command) throws Exception {
   10.59 +
   10.60 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", command});
   10.61 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
   10.62 +
   10.63 +    // Verify that jcmd reports that NMT is not enabled
   10.64 +    output.shouldContain("Native memory tracking is not enabled");
   10.65 +  }
   10.66 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/runtime/NMT/PrintNMTStatistics.java	Sat Feb 02 16:34:10 2013 +0100
    11.3 @@ -0,0 +1,66 @@
    11.4 +/*
    11.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * This code is free software; you can redistribute it and/or modify it
    11.9 + * under the terms of the GNU General Public License version 2 only, as
   11.10 + * published by the Free Software Foundation.
   11.11 + *
   11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 + * version 2 for more details (a copy is included in the LICENSE file that
   11.16 + * accompanied this code).
   11.17 + *
   11.18 + * You should have received a copy of the GNU General Public License version
   11.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 + *
   11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 + * or visit www.oracle.com if you need additional information or have any
   11.24 + * questions.
   11.25 + */
   11.26 +
   11.27 +/*
   11.28 + * @test
   11.29 + * @key nmt regression
   11.30 + * @bug 8005936
   11.31 + * @summary Make sure PrintNMTStatistics works on normal JVM exit
   11.32 + * @library /testlibrary
   11.33 + * @run compile -J-XX:+UnlockDiagnosticVMOptions -J-XX:+WhiteBoxAPI PrintNMTStatistics.java
   11.34 + */
   11.35 +
   11.36 +import com.oracle.java.testlibrary.*;
   11.37 +
   11.38 +import java.util.regex.Matcher;
   11.39 +import java.util.regex.Pattern;
   11.40 +import sun.hotspot.WhiteBox;
   11.41 +
   11.42 +public class PrintNMTStatistics {
   11.43 +
   11.44 +  public static void main(String args[]) throws Exception {
   11.45 +
   11.46 +    // We start a new java process running with an argument and use WB API to ensure
   11.47 +    // we have data for NMT on VM exit
   11.48 +    if (args.length > 0) {
   11.49 +      // Use WB API to ensure that all data has been merged before we continue
   11.50 +      if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
   11.51 +        throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
   11.52 +      }
   11.53 +      return;
   11.54 +    }
   11.55 +
   11.56 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
   11.57 +        "-XX:+UnlockDiagnosticVMOptions",
   11.58 +        "-XX:NativeMemoryTracking=summary",
   11.59 +        "+XX:+PrintNMTStatistics",
   11.60 +        "PrintNMTStatistics",
   11.61 +        "test");
   11.62 +
   11.63 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
   11.64 +    output.shouldContain("Java Heap  (reserved=");
   11.65 +    output.shouldNotContain("error");
   11.66 +    output.shouldNotContain("warning");
   11.67 +    output.shouldHaveExitValue(0);
   11.68 +  }
   11.69 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java	Sat Feb 02 16:34:10 2013 +0100
    12.3 @@ -0,0 +1,44 @@
    12.4 +/*
    12.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + *
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.
   12.11 + *
   12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 + * version 2 for more details (a copy is included in the LICENSE file that
   12.16 + * accompanied this code).
   12.17 + *
   12.18 + * You should have received a copy of the GNU General Public License version
   12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 + *
   12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.23 + * or visit www.oracle.com if you need additional information or have any
   12.24 + * questions.
   12.25 + */
   12.26 +
   12.27 + /*
   12.28 + * @test
   12.29 + * @key nmt
   12.30 + * @summary Trying to enable PrintNMTStatistics should result in a warning
   12.31 + * @library /testlibrary
   12.32 + */
   12.33 +
   12.34 +import com.oracle.java.testlibrary.*;
   12.35 +
   12.36 +public class PrintNMTStatisticsWithNMTDisabled {
   12.37 +
   12.38 +  public static void main(String args[]) throws Exception {
   12.39 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
   12.40 +      "-XX:+UnlockDiagnosticVMOptions",
   12.41 +      "-XX:+PrintNMTStatistics",
   12.42 +      "-version");
   12.43 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
   12.44 +    output.shouldContain("warning: PrintNMTStatistics is disabled, because native memory tracking is not enabled");
   12.45 +    output.shouldHaveExitValue(0);
   12.46 +  }
   12.47 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/runtime/NMT/ShutdownTwice.java	Sat Feb 02 16:34:10 2013 +0100
    13.3 @@ -0,0 +1,56 @@
    13.4 +/*
    13.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.
   13.11 + *
   13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 + * version 2 for more details (a copy is included in the LICENSE file that
   13.16 + * accompanied this code).
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License version
   13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 + *
   13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.23 + * or visit www.oracle.com if you need additional information or have any
   13.24 + * questions.
   13.25 + */
   13.26 +
   13.27 +/*
   13.28 + * @test
   13.29 + * @key nmt jcmd
   13.30 + * @summary Run shutdown twice
   13.31 + * @library /testlibrary
   13.32 + * @run main/othervm -XX:NativeMemoryTracking=detail ShutdownTwice
   13.33 + */
   13.34 +
   13.35 +import com.oracle.java.testlibrary.*;
   13.36 +
   13.37 +public class ShutdownTwice {
   13.38 +
   13.39 +  public static void main(String args[]) throws Exception {
   13.40 +    // Grab my own PID
   13.41 +    String pid = Integer.toString(ProcessTools.getProcessId());
   13.42 +    OutputAnalyzer output;
   13.43 +
   13.44 +    ProcessBuilder pb = new ProcessBuilder();
   13.45 +
   13.46 +    // Run 'jcmd <pid> VM.native_memory shutdown'
   13.47 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "shutdown"});
   13.48 +    output = new OutputAnalyzer(pb.start());
   13.49 +
   13.50 +    // Verify that jcmd reports that NMT is shutting down
   13.51 +    output.shouldContain("Shutdown is in progress, it will take a few moments to completely shutdown");
   13.52 +
   13.53 +    // Run shutdown again
   13.54 +    output = new OutputAnalyzer(pb.start());
   13.55 +
   13.56 +    // Verify that jcmd reports that NMT has been shutdown already
   13.57 +    output.shouldContain("Native memory tracking has been shutdown by user");
   13.58 +  }
   13.59 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/runtime/NMT/SummaryAfterShutdown.java	Sat Feb 02 16:34:10 2013 +0100
    14.3 @@ -0,0 +1,56 @@
    14.4 +/*
    14.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + *
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + *
   14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 + * or visit www.oracle.com if you need additional information or have any
   14.24 + * questions.
   14.25 + */
   14.26 +
   14.27 +/*
   14.28 + * @test
   14.29 + * @key nmt jcmd
   14.30 + * @summary Verify that jcmd correctly reports that NMT is not enabled after a shutdown
   14.31 + * @library /testlibrary
   14.32 + * @run main/othervm -XX:NativeMemoryTracking=detail SummaryAfterShutdown
   14.33 + */
   14.34 +
   14.35 +import com.oracle.java.testlibrary.*;
   14.36 +
   14.37 +public class SummaryAfterShutdown {
   14.38 +
   14.39 +  public static void main(String args[]) throws Exception {
   14.40 +    OutputAnalyzer output;
   14.41 +    // Grab my own PID
   14.42 +    String pid = Integer.toString(ProcessTools.getProcessId());
   14.43 +    ProcessBuilder pb = new ProcessBuilder();
   14.44 +
   14.45 +    // Run 'jcmd <pid> VM.native_memory shutdown'
   14.46 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "shutdown"});
   14.47 +    output = new OutputAnalyzer(pb.start());
   14.48 +
   14.49 +    // Verify that jcmd reports that NMT is shutting down
   14.50 +    output.shouldContain("Shutdown is in progress, it will take a few moments to completely shutdown");
   14.51 +
   14.52 +    // Run 'jcmd <pid> VM.native_memory summary'
   14.53 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
   14.54 +    output = new OutputAnalyzer(pb.start());
   14.55 +
   14.56 +    // Verify that jcmd reports that NMT has been shutdown
   14.57 +    output.shouldContain("Native memory tracking has been shutdown by user");
   14.58 +  }
   14.59 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/runtime/NMT/SummarySanityCheck.java	Sat Feb 02 16:34:10 2013 +0100
    15.3 @@ -0,0 +1,119 @@
    15.4 +/*
    15.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 + *
    15.8 + * This code is free software; you can redistribute it and/or modify it
    15.9 + * under the terms of the GNU General Public License version 2 only, as
   15.10 + * published by the Free Software Foundation.
   15.11 + *
   15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 + * version 2 for more details (a copy is included in the LICENSE file that
   15.16 + * accompanied this code).
   15.17 + *
   15.18 + * You should have received a copy of the GNU General Public License version
   15.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 + *
   15.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.23 + * or visit www.oracle.com if you need additional information or have any
   15.24 + * questions.
   15.25 + */
   15.26 +
   15.27 +/*
   15.28 + * @test
   15.29 + * @key nmt jcmd
   15.30 + * @summary Sanity check the output of NMT
   15.31 + * @library /testlibrary
   15.32 + * @run compile -J-XX:+UnlockDiagnosticVMOptions -J-XX:+WhiteBoxAPI SummarySanityCheck.java
   15.33 + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+WhiteBoxAPI SummarySanityCheck
   15.34 + */
   15.35 +
   15.36 +import com.oracle.java.testlibrary.*;
   15.37 +
   15.38 +import java.util.regex.Matcher;
   15.39 +import java.util.regex.Pattern;
   15.40 +import sun.hotspot.WhiteBox;
   15.41 +
   15.42 +public class SummarySanityCheck {
   15.43 +
   15.44 +  private static String jcmdout;
   15.45 +  public static void main(String args[]) throws Exception {
   15.46 +    // Grab my own PID
   15.47 +    String pid = Integer.toString(ProcessTools.getProcessId());
   15.48 +
   15.49 +    // Use WB API to ensure that all data has been merged before we continue
   15.50 +    if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
   15.51 +      throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
   15.52 +    }
   15.53 +
   15.54 +    ProcessBuilder pb = new ProcessBuilder();
   15.55 +
   15.56 +    // Run  'jcmd <pid> VM.native_memory summary scale=KB'
   15.57 +    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=KB"});
   15.58 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
   15.59 +
   15.60 +    jcmdout = output.getOutput();
   15.61 +    // Split by '-' to get the 'groups'
   15.62 +    String[] lines = jcmdout.split("\n");
   15.63 +
   15.64 +    if (lines.length == 0) {
   15.65 +      throwTestException("Failed to parse jcmd output");
   15.66 +    }
   15.67 +
   15.68 +    int totalCommitted = 0, totalReserved = 0;
   15.69 +    int totalCommittedSum = 0, totalReservedSum = 0;
   15.70 +
   15.71 +    // Match '- <mtType> (reserved=<reserved>KB, committed=<committed>KB)
   15.72 +    Pattern mtTypePattern = Pattern.compile("-\\s+(?<typename>[\\w\\s]+)\\(reserved=(?<reserved>\\d+)KB,\\scommitted=(?<committed>\\d+)KB\\)");
   15.73 +    // Match 'Total: reserved=<reserved>KB, committed=<committed>KB'
   15.74 +    Pattern totalMemoryPattern = Pattern.compile("Total\\:\\s\\sreserved=(?<reserved>\\d+)KB,\\s\\scommitted=(?<committed>\\d+)KB");
   15.75 +
   15.76 +    for (int i = 0; i < lines.length; i++) {
   15.77 +      if (lines[i].startsWith("Total")) {
   15.78 +        Matcher totalMemoryMatcher = totalMemoryPattern.matcher(lines[i]);
   15.79 +
   15.80 +        if (totalMemoryMatcher.matches() && totalMemoryMatcher.groupCount() == 2) {
   15.81 +          totalCommitted = Integer.parseInt(totalMemoryMatcher.group("committed"));
   15.82 +          totalReserved = Integer.parseInt(totalMemoryMatcher.group("reserved"));
   15.83 +        } else {
   15.84 +          throwTestException("Failed to match the expected groups in 'Total' memory part");
   15.85 +        }
   15.86 +      } else if (lines[i].startsWith("-")) {
   15.87 +        Matcher typeMatcher = mtTypePattern.matcher(lines[i]);
   15.88 +        if (typeMatcher.matches()) {
   15.89 +          int typeCommitted = Integer.parseInt(typeMatcher.group("committed"));
   15.90 +          int typeReserved = Integer.parseInt(typeMatcher.group("reserved"));
   15.91 +
   15.92 +          // Make sure reserved is always less or equals
   15.93 +          if (typeCommitted > typeReserved) {
   15.94 +            throwTestException("Committed (" + typeCommitted + ") was more than Reserved ("
   15.95 +                + typeReserved + ") for mtType: " + typeMatcher.group("typename"));
   15.96 +          }
   15.97 +
   15.98 +          // Add to total and compare them in the end
   15.99 +          totalCommittedSum += typeCommitted;
  15.100 +          totalReservedSum += typeReserved;
  15.101 +        } else {
  15.102 +          throwTestException("Failed to match the group on line " + i);
  15.103 +        }
  15.104 +      }
  15.105 +    }
  15.106 +
  15.107 +    // See if they add up correctly, rounding is a problem so make sure we're within +/- 8KB
  15.108 +    int committedDiff = totalCommitted - totalCommittedSum;
  15.109 +    if (committedDiff > 8 || committedDiff < -8) {
  15.110 +      throwTestException("Total committed (" + totalCommitted + ") did not match the summarized committed (" + totalCommittedSum + ")" );
  15.111 +    }
  15.112 +
  15.113 +    int reservedDiff = totalReserved - totalReservedSum;
  15.114 +    if (reservedDiff > 8 || reservedDiff < -8) {
  15.115 +      throwTestException("Total reserved (" + totalReserved + ") did not match the summarized reserved (" + totalReservedSum + ")" );
  15.116 +    }
  15.117 +  }
  15.118 +
  15.119 +  private static void throwTestException(String reason) throws Exception {
  15.120 +      throw new Exception(reason + " . Stdout is :\n" + jcmdout);
  15.121 +  }
  15.122 +}

mercurial