< prev index next >

test/runtime/NMT/SummarySanityCheck.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @key nmt jcmd
  27  * @summary Sanity check the output of NMT
  28  * @library /testlibrary /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  *          java.management
  31  * @build SummarySanityCheck
  32  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  33  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  34  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+WhiteBoxAPI SummarySanityCheck
  35  */
  36 
  37 import jdk.test.lib.*;


  38 
  39 import java.util.regex.Matcher;
  40 import java.util.regex.Pattern;
  41 import sun.hotspot.WhiteBox;
  42 
  43 public class SummarySanityCheck {
  44 
  45   private static String jcmdout;
  46   public static void main(String args[]) throws Exception {
  47     // Grab my own PID
  48     String pid = Long.toString(ProcessTools.getProcessId());
  49 
  50     ProcessBuilder pb = new ProcessBuilder();
  51 
  52     // Run  'jcmd <pid> VM.native_memory summary scale=KB'
  53     pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=KB"});
  54     OutputAnalyzer output = new OutputAnalyzer(pb.start());
  55 
  56     jcmdout = output.getOutput();
  57     // Split by '-' to get the 'groups'




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @key nmt jcmd
  27  * @summary Sanity check the output of NMT
  28  * @library /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  *          java.management
  31  * @build sun.hotspot.WhiteBox
  32  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  33  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  34  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+WhiteBoxAPI SummarySanityCheck
  35  */
  36 
  37 import jdk.test.lib.process.ProcessTools;
  38 import jdk.test.lib.process.OutputAnalyzer;
  39 import jdk.test.lib.JDKToolFinder;
  40 
  41 import java.util.regex.Matcher;
  42 import java.util.regex.Pattern;
  43 import sun.hotspot.WhiteBox;
  44 
  45 public class SummarySanityCheck {
  46 
  47   private static String jcmdout;
  48   public static void main(String args[]) throws Exception {
  49     // Grab my own PID
  50     String pid = Long.toString(ProcessTools.getProcessId());
  51 
  52     ProcessBuilder pb = new ProcessBuilder();
  53 
  54     // Run  'jcmd <pid> VM.native_memory summary scale=KB'
  55     pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=KB"});
  56     OutputAnalyzer output = new OutputAnalyzer(pb.start());
  57 
  58     jcmdout = output.getOutput();
  59     // Split by '-' to get the 'groups'


< prev index next >