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 * sun.hotspot.WhiteBox$WhiteBoxPermission |
|
33 * @run main PrintNMTStatistics |
|
34 */ |
30 */ |
35 |
31 |
36 import com.oracle.java.testlibrary.*; |
32 import com.oracle.java.testlibrary.*; |
37 |
33 |
38 import java.util.regex.Matcher; |
|
39 import java.util.regex.Pattern; |
|
40 import sun.hotspot.WhiteBox; |
|
41 |
|
42 public class PrintNMTStatistics { |
34 public class PrintNMTStatistics { |
43 |
35 |
44 public static void main(String args[]) throws Exception { |
36 public static void main(String args[]) throws Exception { |
45 |
|
46 // We start a new java process running with an argument and use WB API to ensure |
|
47 // we have data for NMT on VM exit |
|
48 if (args.length > 0) { |
|
49 return; |
|
50 } |
|
51 |
37 |
52 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
38 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
53 "-XX:+UnlockDiagnosticVMOptions", |
39 "-XX:+UnlockDiagnosticVMOptions", |
54 "-Xbootclasspath/a:.", |
40 "-XX:+PrintNMTStatistics", |
55 "-XX:+WhiteBoxAPI", |
41 "-XX:NativeMemoryTracking=detail", |
56 "-XX:NativeMemoryTracking=summary", |
42 "-version"); |
57 "-XX:+PrintNMTStatistics", |
|
58 "PrintNMTStatistics", |
|
59 "test"); |
|
60 |
43 |
61 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
44 OutputAnalyzer output_detail = new OutputAnalyzer(pb.start()); |
62 output.shouldContain("Java Heap (reserved="); |
45 output_detail.shouldContain("Virtual memory map:"); |
63 output.shouldNotContain("error"); |
46 output_detail.shouldContain("Details:"); |
64 output.shouldHaveExitValue(0); |
47 output_detail.shouldNotContain("error"); |
65 } |
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 } |
66 } |
63 } |