hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java
author dsamersoff
Tue, 23 Jun 2015 12:35:21 +0300
changeset 31379 8ece48927ac0
parent 30604 b8d532cb6420
child 36401 fb588215d43d
permissions -rw-r--r--
8081576: serviceability/sa tests fail due to LingeredApp process fails to start Summary: Provide a API to corrctly terminate LingeredApp Reviewed-by: sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20388
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 24835
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
20388
2cf7b26682dc 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.
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
     4
 *
2cf7b26682dc 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
2cf7b26682dc 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
2cf7b26682dc 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.
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
     8
 *
2cf7b26682dc 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
2cf7b26682dc 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
2cf7b26682dc 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
2cf7b26682dc 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
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    13
 * accompanied this code).
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    14
 *
2cf7b26682dc 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
2cf7b26682dc 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,
2cf7b26682dc 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.
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    18
 *
2cf7b26682dc 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
2cf7b26682dc 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
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    21
 * questions.
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    22
 */
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    23
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    24
import java.io.BufferedReader;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    25
import java.io.File;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    26
import java.io.FileNotFoundException;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    27
import java.io.FileReader;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    28
import java.io.IOException;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    29
import java.io.Reader;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    30
import java.nio.CharBuffer;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    31
import java.util.Arrays;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    32
import java.util.Scanner;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    33
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    34
import jdk.test.lib.Asserts;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    35
import jdk.test.lib.JDKToolFinder;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    36
import jdk.test.lib.JDKToolLauncher;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    37
import jdk.test.lib.OutputAnalyzer;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    38
import jdk.test.lib.Platform;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    39
import jdk.test.lib.ProcessTools;
20388
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    40
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    41
/*
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    42
 * @test
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    43
 * @bug 6313383
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    44
 * @key regression
2cf7b26682dc 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)
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    46
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 24835
diff changeset
    47
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 24835
diff changeset
    48
 *          java.compiler
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 24835
diff changeset
    49
 *          java.management/sun.management
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 24835
diff changeset
    50
 *          jdk.jvmstat/sun.jvmstat.monitor
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    51
 * @build jdk.test.lib.* JMapHProfLargeHeapProc
20388
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    52
 * @run main JMapHProfLargeHeapTest
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    53
 */
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    54
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    55
public class JMapHProfLargeHeapTest {
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    56
    private static final String HEAP_DUMP_FILE_NAME = "heap.hprof";
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    57
    private static final String HPROF_HEADER_1_0_1 = "JAVA PROFILE 1.0.1";
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    58
    private static final String HPROF_HEADER_1_0_2 = "JAVA PROFILE 1.0.2";
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    59
    private static final long M = 1024L;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    60
    private static final long G = 1024L * M;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    61
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    62
    public static void main(String[] args) throws Exception {
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    63
        // If we are on MacOSX, test if JMap tool is signed, otherwise return
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    64
        // since test will fail with privilege error.
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    65
        if (Platform.isOSX()) {
20674
380fc00765c6 8026199: serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java Compilation failed
sla
parents: 20388
diff changeset
    66
            String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
20388
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    67
            ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    68
                    "codesign", "-v", jmapToolPath);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    69
            Process codesignProcess = codesignProcessBuilder.start();
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    70
            OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    71
            try {
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    72
                analyser.shouldNotContain("code object is not signed at all");
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    73
                System.out.println("Signed jmap found at: " + jmapToolPath);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    74
            } catch (Exception e) {
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    75
                // Abort since we can't know if the test will work
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    76
                System.out
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    77
                        .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    78
                return;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    79
            }
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    80
        }
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    81
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    82
        // Small heap 22 megabytes, should create 1.0.1 file format
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    83
        testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    84
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    85
        /**
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    86
         * This test was deliberately commented out since the test system lacks
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    87
         * support to handle the requirements for this kind of heap size in a
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    88
         * good way. If or when it becomes possible to run this kind of tests in
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    89
         * the test environment the test should be enabled again.
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    90
         * */
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    91
        // Large heap 2,2 gigabytes, should create 1.0.2 file format
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    92
        // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    93
    }
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    94
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    95
    private static void testHProfFileFormat(String vmArgs, long heapSize,
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    96
            String expectedFormat) throws Exception, IOException,
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    97
            InterruptedException, FileNotFoundException {
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    98
        ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
    99
                vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize));
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   100
        procBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   101
        Process largeHeapProc = procBuilder.start();
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   102
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   103
        try (Scanner largeHeapScanner = new Scanner(
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   104
                largeHeapProc.getInputStream());) {
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   105
            String pidstring = null;
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   106
            while ((pidstring = largeHeapScanner.findInLine("PID\\[[0-9].*\\]")) == null) {
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   107
                Thread.sleep(500);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   108
            }
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   109
            int pid = Integer.parseInt(pidstring.substring(4,
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   110
                    pidstring.length() - 1));
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   111
            System.out.println("Extracted pid: " + pid);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   112
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   113
            JDKToolLauncher jMapLauncher = JDKToolLauncher
20674
380fc00765c6 8026199: serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java Compilation failed
sla
parents: 20388
diff changeset
   114
                    .createUsingTestJDK("jmap");
20388
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   115
            jMapLauncher.addToolArg("-dump:format=b,file=" + pid + "-"
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   116
                    + HEAP_DUMP_FILE_NAME);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   117
            jMapLauncher.addToolArg(String.valueOf(pid));
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   118
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   119
            ProcessBuilder jMapProcessBuilder = new ProcessBuilder(
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   120
                    jMapLauncher.getCommand());
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   121
            System.out.println("jmap command: "
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   122
                    + Arrays.toString(jMapLauncher.getCommand()));
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   123
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   124
            Process jMapProcess = jMapProcessBuilder.start();
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   125
            OutputAnalyzer analyzer = new OutputAnalyzer(jMapProcess);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   126
            analyzer.shouldHaveExitValue(0);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   127
            analyzer.shouldContain(pid + "-" + HEAP_DUMP_FILE_NAME);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   128
            analyzer.shouldContain("Heap dump file created");
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   129
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   130
            largeHeapProc.getOutputStream().write('\n');
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   131
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   132
            File dumpFile = new File(pid + "-" + HEAP_DUMP_FILE_NAME);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   133
            Asserts.assertTrue(dumpFile.exists(), "Heap dump file not found.");
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   134
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   135
            try (Reader reader = new BufferedReader(new FileReader(dumpFile))) {
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   136
                CharBuffer buf = CharBuffer.allocate(expectedFormat.length());
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   137
                reader.read(buf);
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   138
                buf.clear();
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   139
                Asserts.assertEQ(buf.toString(), expectedFormat,
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   140
                        "Wrong file format. Expected '" + expectedFormat
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   141
                                + "', but found '" + buf.toString() + "'");
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   142
            }
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   143
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   144
            System.out.println("Success!");
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   145
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   146
        } finally {
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   147
            largeHeapProc.destroyForcibly();
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   148
        }
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   149
    }
2cf7b26682dc 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents:
diff changeset
   150
}