author | kkharbas |
Wed, 29 Nov 2017 17:03:10 -0800 | |
changeset 48153 | cfa2c43e58c2 |
parent 47216 | 71c04702a3d5 |
child 50406 | 314af5e1e787 |
permissions | -rw-r--r-- |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38299
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
4 |
* |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
8 |
* |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
13 |
* accompanied this code). |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
14 |
* |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
18 |
* |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
21 |
* questions. |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
22 |
*/ |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
23 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
24 |
/* |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
25 |
* @test CompressedClassSpaceSizeInJmapHeap |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
26 |
* @bug 8004924 |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
27 |
* @summary Checks that jmap -heap contains the flag CompressedClassSpaceSize |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38299
diff
changeset
|
28 |
* @library /test/lib |
36851 | 29 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
29200
diff
changeset
|
30 |
* java.management |
23509
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
31 |
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:CompressedClassSpaceSize=50m CompressedClassSpaceSizeInJmapHeap |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
32 |
*/ |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
33 |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38299
diff
changeset
|
34 |
import jdk.test.lib.JDKToolLauncher; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38299
diff
changeset
|
35 |
import jdk.test.lib.Platform; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38299
diff
changeset
|
36 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38299
diff
changeset
|
37 |
import jdk.test.lib.process.ProcessTools; |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
38 |
import java.nio.file.*; |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
39 |
import java.io.File; |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
40 |
import java.nio.charset.Charset; |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
41 |
import java.util.List; |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
42 |
|
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
43 |
public class CompressedClassSpaceSizeInJmapHeap { |
29200 | 44 |
// Note that on some platforms it may require root privileges to run this test. |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
45 |
public static void main(String[] args) throws Exception { |
23509
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
46 |
if (!Platform.is64bit()) { |
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
47 |
// Compressed Class Space is only available on 64-bit JVMs |
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
48 |
return; |
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
49 |
} |
28733
0fc2c4609840
8068778: [TESTBUG] CompressedClassSpaceSizeInJmapHeap.java fails if SA not available
goetz
parents:
23509
diff
changeset
|
50 |
if (!Platform.shouldSAAttach()) { |
0fc2c4609840
8068778: [TESTBUG] CompressedClassSpaceSizeInJmapHeap.java fails if SA not available
goetz
parents:
23509
diff
changeset
|
51 |
System.out.println("SA attach not expected to work - test skipped."); |
0fc2c4609840
8068778: [TESTBUG] CompressedClassSpaceSizeInJmapHeap.java fails if SA not available
goetz
parents:
23509
diff
changeset
|
52 |
return; |
0fc2c4609840
8068778: [TESTBUG] CompressedClassSpaceSizeInJmapHeap.java fails if SA not available
goetz
parents:
23509
diff
changeset
|
53 |
} |
23509
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
54 |
|
38089
9e58203ef0e2
8153992: Some hotspot tests fail on compact2 due to an unnecessary test library dependency
akulyakh
parents:
36851
diff
changeset
|
55 |
String pid = Long.toString(ProcessTools.getProcessId()); |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
56 |
|
38299
83971c7804b1
8156769: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with java.lang.Exception
dsamersoff
parents:
38089
diff
changeset
|
57 |
JDKToolLauncher jmap = JDKToolLauncher.create("jhsdb") |
83971c7804b1
8156769: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with java.lang.Exception
dsamersoff
parents:
38089
diff
changeset
|
58 |
.addToolArg("jmap") |
83971c7804b1
8156769: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with java.lang.Exception
dsamersoff
parents:
38089
diff
changeset
|
59 |
.addToolArg("--heap") |
83971c7804b1
8156769: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with java.lang.Exception
dsamersoff
parents:
38089
diff
changeset
|
60 |
.addToolArg("--pid") |
16607
2581c39b3b93
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
15811
diff
changeset
|
61 |
.addToolArg(pid); |
2581c39b3b93
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
15811
diff
changeset
|
62 |
ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
63 |
|
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
64 |
File out = new File("CompressedClassSpaceSizeInJmapHeap.stdout.txt"); |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
65 |
pb.redirectOutput(out); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
66 |
|
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
67 |
File err = new File("CompressedClassSpaceSizeInJmapHeap.stderr.txt"); |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
68 |
pb.redirectError(err); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
69 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
70 |
run(pb); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
71 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
72 |
OutputAnalyzer output = new OutputAnalyzer(read(out)); |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
73 |
output.shouldContain("CompressedClassSpaceSize = 52428800 (50.0MB)"); |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
74 |
out.delete(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
75 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
76 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
77 |
private static void run(ProcessBuilder pb) throws Exception { |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
78 |
Process p = pb.start(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
79 |
p.waitFor(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
80 |
int exitValue = p.exitValue(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
81 |
if (exitValue != 0) { |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
82 |
throw new Exception("jmap -heap exited with error code: " + exitValue); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
83 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
84 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
85 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
86 |
private static String read(File f) throws Exception { |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
87 |
Path p = f.toPath(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
88 |
List<String> lines = Files.readAllLines(p, Charset.defaultCharset()); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
89 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
90 |
StringBuilder sb = new StringBuilder(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
91 |
for (String line : lines) { |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
92 |
sb.append(line).append('\n'); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
93 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
94 |
return sb.toString(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
95 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
96 |
} |