test/hotspot/jtreg/runtime/cds/DumpSharedDictionary.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 57705 7cf02b2c1455
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46747
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
     1
/*
57567
b000362a89a0 8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents: 51990
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
46747
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
     4
 *
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
     8
 *
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    13
 * accompanied this code).
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    14
 *
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    18
 *
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    21
 * questions.
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    22
 */
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    23
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    24
/*
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    25
 * @test
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    26
 * @bug 8130072
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    27
 * @summary Check that Shared Dictionary is printed out with jcmd
48469
7312ae4465d6 8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents: 47216
diff changeset
    28
 * @requires vm.cds
46747
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    29
 * @library /test/lib
51990
6003e034cdd8 8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents: 49931
diff changeset
    30
 * @run driver DumpSharedDictionary
46747
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    31
 */
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    32
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    33
import jdk.test.lib.cds.CDSTestUtils;
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    34
import jdk.test.lib.process.ProcessTools;
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    35
import jdk.test.lib.process.OutputAnalyzer;
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    36
import jdk.test.lib.JDKToolFinder;
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    37
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    38
public class DumpSharedDictionary {
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    39
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    40
    public static void main(String[] args) throws Exception {
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    41
        if (args.length == 0) {
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    42
            // Start this process
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    43
            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    44
                "-XX:SharedArchiveFile=./DumpSharedDictionary.jsa",
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    45
                "-Xshare:dump");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    46
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    47
            OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "dump");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    48
            out.shouldHaveExitValue(0);
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    49
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    50
            String testjdkPath = System.getProperty("test.jdk");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    51
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    52
            pb = ProcessTools.createJavaProcessBuilder(
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    53
                    "-XX:SharedArchiveFile=./DumpSharedDictionary.jsa",
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    54
                    "-Dtest.jdk=" + testjdkPath,
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    55
                    "-Xshare:on", "DumpSharedDictionary", "test");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    56
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    57
            out = CDSTestUtils.executeAndLog(pb, "exec");
46781
81d54b338660 8186044: [TESTBUG] DumpSharedDictionary test sometimes fails in JPRT
coleenp
parents: 46747
diff changeset
    58
            if (!CDSTestUtils.isUnableToMap(out)) {
81d54b338660 8186044: [TESTBUG] DumpSharedDictionary test sometimes fails in JPRT
coleenp
parents: 46747
diff changeset
    59
                out.shouldHaveExitValue(0);
81d54b338660 8186044: [TESTBUG] DumpSharedDictionary test sometimes fails in JPRT
coleenp
parents: 46747
diff changeset
    60
            }
46747
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    61
        } else {
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    62
            // Grab my own PID
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    63
            String pid = Long.toString(ProcessTools.getProcessId());
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    64
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    65
            ProcessBuilder pb = new ProcessBuilder();
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    66
            pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary"});
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    67
            OutputAnalyzer output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    68
            try {
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    69
                output.shouldContain("Shared Dictionary statistics:");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    70
                output.shouldContain("Number of buckets");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    71
                output.shouldContain("Number of entries");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    72
                output.shouldContain("Maximum bucket size");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    73
            } catch (RuntimeException e) {
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    74
                output.shouldContain("Unknown diagnostic command");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    75
            }
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    76
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    77
            pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.systemdictionary", "-verbose"});
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    78
            output = CDSTestUtils.executeAndLog(pb, "jcmd-systemdictionary-verbose");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    79
            try {
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    80
                output.shouldContain("Shared Dictionary");
49348
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 49008
diff changeset
    81
                output.shouldContain("Dictionary for loader data: 0x");
46747
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    82
                output.shouldContain("^java.lang.String");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    83
            } catch (RuntimeException e) {
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    84
                output.shouldContain("Unknown diagnostic command");
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    85
            }
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    86
        }
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    87
    }
7b6570052b58 8130072: Add a flag to print out statistics for both system dictionary and shared dictionary
coleenp
parents:
diff changeset
    88
}