comparison test/runtime/NMT/PrintNMTStatistics.java @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 52b4284cb496 e244cb6bdedf
children
comparison
equal deleted inserted replaced
20184:84105dcdb05b 20804:7848fc12602b
1 /* 1 /*
2 * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
22 */ 22 */
23 23
24 /* 24 /*
25 * @test 25 * @test
26 * @key nmt regression 26 * @key nmt regression
27 * @bug 8005936 27 * @bug 8005936 8058606
28 * @summary Make sure PrintNMTStatistics works on normal JVM exit 28 * @summary Verify PrintNMTStatistics on normal JVM exit for detail and summary tracking level
29 * @library /testlibrary /testlibrary/whitebox 29 * @library /testlibrary
30 * @build PrintNMTStatistics
31 * @run main ClassFileInstaller sun.hotspot.WhiteBox
32 * @run main PrintNMTStatistics
33 */ 30 */
34 31
35 import com.oracle.java.testlibrary.*; 32 import com.oracle.java.testlibrary.*;
36 33
37 import java.util.regex.Matcher;
38 import java.util.regex.Pattern;
39 import sun.hotspot.WhiteBox;
40
41 public class PrintNMTStatistics { 34 public class PrintNMTStatistics {
42 35
43 public static void main(String args[]) throws Exception { 36 public static void main(String args[]) throws Exception {
44
45 // We start a new java process running with an argument and use WB API to ensure
46 // we have data for NMT on VM exit
47 if (args.length > 0) {
48 // Use WB API to ensure that all data has been merged before we continue
49 if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
50 throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
51 }
52 return;
53 }
54 37
55 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( 38 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
56 "-XX:+UnlockDiagnosticVMOptions", 39 "-XX:+UnlockDiagnosticVMOptions",
57 "-Xbootclasspath/a:.", 40 "-XX:+PrintNMTStatistics",
58 "-XX:+WhiteBoxAPI", 41 "-XX:NativeMemoryTracking=detail",
59 "-XX:NativeMemoryTracking=summary", 42 "-version");
60 "-XX:+PrintNMTStatistics",
61 "PrintNMTStatistics",
62 "test");
63 43
64 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 44 OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
65 output.shouldContain("Java Heap (reserved="); 45 output_detail.shouldContain("Virtual memory map:");
66 output.shouldNotContain("error"); 46 output_detail.shouldContain("Details:");
67 output.shouldHaveExitValue(0); 47 output_detail.shouldNotContain("error");
68 } 48 output_detail.shouldHaveExitValue(0);
49
50 ProcessBuilder pb1 = ProcessTools.createJavaProcessBuilder(
51 "-XX:+UnlockDiagnosticVMOptions",
52 "-XX:+PrintNMTStatistics",
53 "-XX:NativeMemoryTracking=summary",
54 "-version");
55
56 OutputAnalyzer output_summary = new OutputAnalyzer(pb1.start());
57 output_summary.shouldContain("Java Heap (reserved=");
58 output_summary.shouldNotContain("Virtual memory map:");
59 output_summary.shouldNotContain("Details:");
60 output_summary.shouldNotContain("error");
61 output_summary.shouldHaveExitValue(0);
62 }
69 } 63 }