Mercurial > hg > truffle
annotate test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java @ 18652:dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 09 Dec 2014 22:04:06 +0100 |
parents | 09f19d3de485 |
children |
rev | line source |
---|---|
12820
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
1 /* |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
4 * |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
8 * |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
13 * accompanied this code). |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
14 * |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
18 * |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
21 * questions. |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
22 */ |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
23 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
24 import java.io.BufferedReader; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
25 import java.io.File; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
26 import java.io.FileNotFoundException; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
27 import java.io.FileReader; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
28 import java.io.IOException; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
29 import java.io.Reader; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
30 import java.nio.CharBuffer; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
31 import java.util.Arrays; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
32 import java.util.Scanner; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
33 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
34 import com.oracle.java.testlibrary.Asserts; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
35 import com.oracle.java.testlibrary.JDKToolFinder; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
36 import com.oracle.java.testlibrary.JDKToolLauncher; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
37 import com.oracle.java.testlibrary.OutputAnalyzer; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
38 import com.oracle.java.testlibrary.Platform; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
39 import com.oracle.java.testlibrary.ProcessTools; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
40 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
41 /* |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
42 * @test |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
43 * @bug 6313383 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
44 * @key regression |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
45 * @summary Regression test for hprof export issue due to large heaps (>2G) |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
46 * @library /testlibrary |
17974
09f19d3de485
8043915: Tests get ClassNotFoundException: com.oracle.java.testlibrary.StreamPumper
ykantser
parents:
12908
diff
changeset
|
47 * @build com.oracle.java.testlibrary.* JMapHProfLargeHeapProc |
12820
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
48 * @run main JMapHProfLargeHeapTest |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
49 */ |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
50 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
51 public class JMapHProfLargeHeapTest { |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
52 private static final String HEAP_DUMP_FILE_NAME = "heap.hprof"; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
53 private static final String HPROF_HEADER_1_0_1 = "JAVA PROFILE 1.0.1"; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
54 private static final String HPROF_HEADER_1_0_2 = "JAVA PROFILE 1.0.2"; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
55 private static final long M = 1024L; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
56 private static final long G = 1024L * M; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
57 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
58 public static void main(String[] args) throws Exception { |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
59 // If we are on MacOSX, test if JMap tool is signed, otherwise return |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
60 // since test will fail with privilege error. |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
61 if (Platform.isOSX()) { |
12847
cd7ea1d79dac
8026199: serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java Compilation failed
sla
parents:
12820
diff
changeset
|
62 String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap"); |
12820
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
63 ProcessBuilder codesignProcessBuilder = new ProcessBuilder( |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
64 "codesign", "-v", jmapToolPath); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
65 Process codesignProcess = codesignProcessBuilder.start(); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
66 OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
67 try { |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
68 analyser.shouldNotContain("code object is not signed at all"); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
69 System.out.println("Signed jmap found at: " + jmapToolPath); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
70 } catch (Exception e) { |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
71 // Abort since we can't know if the test will work |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
72 System.out |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
73 .println("Test aborted since we are on MacOSX and the jmap tool is not signed."); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
74 return; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
75 } |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
76 } |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
77 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
78 // Small heap 22 megabytes, should create 1.0.1 file format |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
79 testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
80 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
81 /** |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
82 * This test was deliberately commented out since the test system lacks |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
83 * support to handle the requirements for this kind of heap size in a |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
84 * good way. If or when it becomes possible to run this kind of tests in |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
85 * the test environment the test should be enabled again. |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
86 * */ |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
87 // Large heap 2,2 gigabytes, should create 1.0.2 file format |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
88 // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
89 } |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
90 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
91 private static void testHProfFileFormat(String vmArgs, long heapSize, |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
92 String expectedFormat) throws Exception, IOException, |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
93 InterruptedException, FileNotFoundException { |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
94 ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder( |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
95 vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize)); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
96 procBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
97 Process largeHeapProc = procBuilder.start(); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
98 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
99 try (Scanner largeHeapScanner = new Scanner( |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
100 largeHeapProc.getInputStream());) { |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
101 String pidstring = null; |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
102 while ((pidstring = largeHeapScanner.findInLine("PID\\[[0-9].*\\]")) == null) { |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
103 Thread.sleep(500); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
104 } |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
105 int pid = Integer.parseInt(pidstring.substring(4, |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
106 pidstring.length() - 1)); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
107 System.out.println("Extracted pid: " + pid); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
108 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
109 JDKToolLauncher jMapLauncher = JDKToolLauncher |
12847
cd7ea1d79dac
8026199: serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java Compilation failed
sla
parents:
12820
diff
changeset
|
110 .createUsingTestJDK("jmap"); |
12820
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
111 jMapLauncher.addToolArg("-dump:format=b,file=" + pid + "-" |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
112 + HEAP_DUMP_FILE_NAME); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
113 jMapLauncher.addToolArg(String.valueOf(pid)); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
114 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
115 ProcessBuilder jMapProcessBuilder = new ProcessBuilder( |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
116 jMapLauncher.getCommand()); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
117 System.out.println("jmap command: " |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
118 + Arrays.toString(jMapLauncher.getCommand())); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
119 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
120 Process jMapProcess = jMapProcessBuilder.start(); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
121 OutputAnalyzer analyzer = new OutputAnalyzer(jMapProcess); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
122 analyzer.shouldHaveExitValue(0); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
123 analyzer.shouldContain(pid + "-" + HEAP_DUMP_FILE_NAME); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
124 analyzer.shouldContain("Heap dump file created"); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
125 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
126 largeHeapProc.getOutputStream().write('\n'); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
127 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
128 File dumpFile = new File(pid + "-" + HEAP_DUMP_FILE_NAME); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
129 Asserts.assertTrue(dumpFile.exists(), "Heap dump file not found."); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
130 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
131 try (Reader reader = new BufferedReader(new FileReader(dumpFile))) { |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
132 CharBuffer buf = CharBuffer.allocate(expectedFormat.length()); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
133 reader.read(buf); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
134 buf.clear(); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
135 Asserts.assertEQ(buf.toString(), expectedFormat, |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
136 "Wrong file format. Expected '" + expectedFormat |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
137 + "', but found '" + buf.toString() + "'"); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
138 } |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
139 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
140 System.out.println("Success!"); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
141 |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
142 } finally { |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
143 largeHeapProc.destroyForcibly(); |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
144 } |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
145 } |
8ef918538e22
6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff
changeset
|
146 } |