test/runtime/NMT/PrintNMTStatistics.java

Wed, 21 May 2014 10:56:41 -0700

author
katleman
date
Wed, 21 May 2014 10:56:41 -0700
changeset 6672
fb9d124d9192
parent 6272
e56d11f8cc21
child 6876
710a3c8b516e
child 7075
ac12996df59b
permissions
-rw-r--r--

Added tag jdk8u20-b15 for changeset 8c785f9bde6f

ctornqvi@4518 1 /*
gtriantafill@6272 2 * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
ctornqvi@4518 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ctornqvi@4518 4 *
ctornqvi@4518 5 * This code is free software; you can redistribute it and/or modify it
ctornqvi@4518 6 * under the terms of the GNU General Public License version 2 only, as
ctornqvi@4518 7 * published by the Free Software Foundation.
ctornqvi@4518 8 *
ctornqvi@4518 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ctornqvi@4518 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ctornqvi@4518 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ctornqvi@4518 12 * version 2 for more details (a copy is included in the LICENSE file that
ctornqvi@4518 13 * accompanied this code).
ctornqvi@4518 14 *
ctornqvi@4518 15 * You should have received a copy of the GNU General Public License version
ctornqvi@4518 16 * 2 along with this work; if not, write to the Free Software Foundation,
ctornqvi@4518 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ctornqvi@4518 18 *
ctornqvi@4518 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ctornqvi@4518 20 * or visit www.oracle.com if you need additional information or have any
ctornqvi@4518 21 * questions.
ctornqvi@4518 22 */
ctornqvi@4518 23
ctornqvi@4518 24 /*
ctornqvi@4518 25 * @test
ctornqvi@4518 26 * @key nmt regression
ctornqvi@4518 27 * @bug 8005936
ctornqvi@4518 28 * @summary Make sure PrintNMTStatistics works on normal JVM exit
mgerdin@4637 29 * @library /testlibrary /testlibrary/whitebox
ctornqvi@4814 30 * @build PrintNMTStatistics
ctornqvi@4814 31 * @run main ClassFileInstaller sun.hotspot.WhiteBox
ctornqvi@4814 32 * @run main PrintNMTStatistics
ctornqvi@4518 33 */
ctornqvi@4518 34
ctornqvi@4518 35 import com.oracle.java.testlibrary.*;
ctornqvi@4518 36
ctornqvi@4518 37 import java.util.regex.Matcher;
ctornqvi@4518 38 import java.util.regex.Pattern;
ctornqvi@4518 39 import sun.hotspot.WhiteBox;
ctornqvi@4518 40
ctornqvi@4518 41 public class PrintNMTStatistics {
ctornqvi@4518 42
ctornqvi@4518 43 public static void main(String args[]) throws Exception {
ctornqvi@4518 44
ctornqvi@4518 45 // We start a new java process running with an argument and use WB API to ensure
ctornqvi@4518 46 // we have data for NMT on VM exit
ctornqvi@4518 47 if (args.length > 0) {
ctornqvi@4518 48 // Use WB API to ensure that all data has been merged before we continue
ctornqvi@4518 49 if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
ctornqvi@4518 50 throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
ctornqvi@4518 51 }
ctornqvi@4518 52 return;
ctornqvi@4518 53 }
ctornqvi@4518 54
ctornqvi@4518 55 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
ctornqvi@4518 56 "-XX:+UnlockDiagnosticVMOptions",
ctornqvi@4814 57 "-Xbootclasspath/a:.",
ctornqvi@4814 58 "-XX:+WhiteBoxAPI",
ctornqvi@4518 59 "-XX:NativeMemoryTracking=summary",
ctornqvi@4814 60 "-XX:+PrintNMTStatistics",
ctornqvi@4518 61 "PrintNMTStatistics",
ctornqvi@4518 62 "test");
ctornqvi@4518 63
ctornqvi@4518 64 OutputAnalyzer output = new OutputAnalyzer(pb.start());
ctornqvi@4814 65 output.shouldContain("Java Heap (reserved=");
ctornqvi@4518 66 output.shouldNotContain("error");
ctornqvi@4518 67 output.shouldHaveExitValue(0);
ctornqvi@4518 68 }
ctornqvi@4518 69 }

mercurial