author | pliden |
Tue, 12 Jun 2018 17:40:28 +0200 | |
changeset 50525 | 767cdb97f103 |
parent 50302 | fd2fccf3b079 |
child 52492 | c22997db2a22 |
permissions | -rw-r--r-- |
49980 | 1 |
/* |
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* Copyright (c) 2018, SAP and/or its affiliates. All rights reserved. |
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
*/ |
|
24 |
||
25 |
import jdk.test.lib.process.ProcessTools; |
|
26 |
import jdk.test.lib.process.OutputAnalyzer; |
|
27 |
import jdk.test.lib.JDKToolFinder; |
|
28 |
||
29 |
/* |
|
30 |
* @test |
|
31 |
* @key metaspace jcmd |
|
32 |
* @summary Test the VM.metaspace command |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50302
diff
changeset
|
33 |
* @requires vm.gc != "Z" |
49980 | 34 |
* @library /test/lib |
35 |
* @modules java.base/jdk.internal.misc |
|
36 |
* java.management |
|
50111
1dc98fa30b14
8203032: PrintMetaspaceDcmd fails: Non-Class: missing from stdout/stderr
stuefe
parents:
49980
diff
changeset
|
37 |
* @run main/othervm -XX:MaxMetaspaceSize=201M -Xmx100M -XX:+UseCompressedOops -XX:+UseCompressedClassPointers PrintMetaspaceDcmd with-compressed-class-space |
1dc98fa30b14
8203032: PrintMetaspaceDcmd fails: Non-Class: missing from stdout/stderr
stuefe
parents:
49980
diff
changeset
|
38 |
* @run main/othervm -XX:MaxMetaspaceSize=201M -Xmx100M -XX:-UseCompressedOops -XX:-UseCompressedClassPointers PrintMetaspaceDcmd without-compressed-class-space |
49980 | 39 |
*/ |
40 |
||
41 |
public class PrintMetaspaceDcmd { |
|
42 |
||
43 |
// Run jcmd VM.metaspace against a VM with CompressedClassPointers on. |
|
44 |
// The report should detail Non-Class and Class portions separately. |
|
45 |
private static void doTheTest(boolean usesCompressedClassSpace) throws Exception { |
|
46 |
ProcessBuilder pb = new ProcessBuilder(); |
|
47 |
OutputAnalyzer output; |
|
48 |
// Grab my own PID |
|
49 |
String pid = Long.toString(ProcessTools.getProcessId()); |
|
50 |
||
51 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "basic"}); |
|
52 |
output = new OutputAnalyzer(pb.start()); |
|
53 |
output.shouldHaveExitValue(0); |
|
54 |
if (usesCompressedClassSpace) { |
|
55 |
output.shouldContain("Non-Class:"); |
|
56 |
output.shouldContain("Class:"); |
|
57 |
} |
|
58 |
output.shouldContain("Virtual space:"); |
|
59 |
output.shouldContain("Chunk freelists:"); |
|
60 |
||
61 |
||
62 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace"}); |
|
63 |
output = new OutputAnalyzer(pb.start()); |
|
64 |
output.shouldHaveExitValue(0); |
|
65 |
if (usesCompressedClassSpace) { |
|
66 |
output.shouldContain("Non-Class:"); |
|
67 |
output.shouldContain("Class:"); |
|
68 |
} |
|
69 |
output.shouldContain("Virtual space:"); |
|
70 |
output.shouldContain("Chunk freelist"); |
|
71 |
output.shouldContain("Waste"); |
|
72 |
output.shouldMatch("MaxMetaspaceSize:.*201.00.*MB"); |
|
73 |
||
74 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "show-loaders"}); |
|
75 |
output = new OutputAnalyzer(pb.start()); |
|
76 |
output.shouldHaveExitValue(0); |
|
50302
fd2fccf3b079
8203455: jcmd: VM.metaspace: print loader name for anonymous CLDs
stuefe
parents:
50111
diff
changeset
|
77 |
output.shouldMatch("CLD.*<bootstrap>"); |
49980 | 78 |
|
79 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "by-chunktype"}); |
|
80 |
output = new OutputAnalyzer(pb.start()); |
|
81 |
output.shouldHaveExitValue(0); |
|
82 |
output.shouldContain("specialized:"); |
|
83 |
output.shouldContain("small:"); |
|
84 |
output.shouldContain("medium:"); |
|
85 |
output.shouldContain("humongous:"); |
|
86 |
||
87 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "vslist"}); |
|
88 |
output = new OutputAnalyzer(pb.start()); |
|
89 |
output.shouldHaveExitValue(0); |
|
90 |
output.shouldContain("Virtual space list"); |
|
91 |
output.shouldMatch("node.*reserved.*committed.*used.*"); |
|
92 |
||
93 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "vsmap"}); |
|
94 |
output = new OutputAnalyzer(pb.start()); |
|
95 |
output.shouldHaveExitValue(0); |
|
96 |
output.shouldContain("Virtual space map:"); |
|
97 |
output.shouldContain("HHHHHHHHHHH"); |
|
98 |
||
99 |
// Test with different scales |
|
100 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "scale=G"}); |
|
101 |
output = new OutputAnalyzer(pb.start()); |
|
102 |
output.shouldHaveExitValue(0); |
|
103 |
output.shouldMatch("MaxMetaspaceSize:.*0.2.*GB"); |
|
104 |
||
105 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "scale=K"}); |
|
106 |
output = new OutputAnalyzer(pb.start()); |
|
107 |
output.shouldHaveExitValue(0); |
|
108 |
output.shouldMatch("MaxMetaspaceSize:.*205824.00 KB"); |
|
109 |
||
110 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "scale=1"}); |
|
111 |
output = new OutputAnalyzer(pb.start()); |
|
112 |
output.shouldHaveExitValue(0); |
|
113 |
output.shouldMatch("MaxMetaspaceSize:.*210763776 bytes"); |
|
114 |
} |
|
115 |
||
116 |
public static void main(String args[]) throws Exception { |
|
117 |
boolean testForCompressedClassSpace = false; |
|
118 |
if (args[0].equals("with-compressed-class-space")) { |
|
119 |
testForCompressedClassSpace = true; |
|
120 |
} else if (args[0].equals("without-compressed-class-space")) { |
|
121 |
testForCompressedClassSpace = false; |
|
122 |
} else { |
|
123 |
throw new IllegalArgumentException("Invalid argument: " + args[0]); |
|
124 |
} |
|
125 |
doTheTest(testForCompressedClassSpace); |
|
126 |
} |
|
127 |
} |