19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import sun.hotspot.code.Compiler;
25
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.io.IOException;
29 import java.util.stream.Collectors;
30 import java.io.OutputStream;
31 import jdk.test.lib.apps.LingeredApp;
32 import jdk.test.lib.JDKToolLauncher;
33 import jdk.test.lib.Platform;
34 import jdk.test.lib.process.OutputAnalyzer;
35
36 /*
37 * @test
38 * @summary Test the 'universe' command of jhsdb clhsdb.
39 * @bug 8190307
40 * @library /test/lib
41 * @build jdk.test.lib.apps.*
42 * @build sun.hotspot.WhiteBox
43 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
44 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestUniverse
45 */
46
47 public class TestUniverse {
48
49 private static void testClhsdbForUniverse(long lingeredAppPid,
50 String gc) throws Exception {
51
52 Process p;
53 JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
54 launcher.addToolArg("clhsdb");
55 launcher.addToolArg("--pid");
56 launcher.addToolArg(Long.toString(lingeredAppPid));
57
58 ProcessBuilder pb = new ProcessBuilder();
59 pb.command(launcher.getCommand());
60 System.out.println(
61 pb.command().stream().collect(Collectors.joining(" ")));
62
63 try {
64 p = pb.start();
89 System.out.println(output.getOutput());
90
91 output.shouldContain("Heap Parameters");
92 if (gc.contains("G1GC")) {
93 output.shouldContain("garbage-first heap");
94 output.shouldContain("region size");
95 output.shouldContain("G1 Young Generation:");
96 output.shouldContain("regions =");
97 }
98 if (gc.contains("UseConcMarkSweepGC")) {
99 output.shouldContain("Gen 1: concurrent mark-sweep generation");
100 }
101 if (gc.contains("UseSerialGC")) {
102 output.shouldContain("Gen 1: old");
103 }
104 if (gc.contains("UseParallelGC")) {
105 output.shouldContain("ParallelScavengeHeap");
106 output.shouldContain("PSYoungGen");
107 output.shouldContain("eden");
108 }
109
110 }
111
112 public static void test(String gc) throws Exception {
113 LingeredApp app = null;
114 try {
115 List<String> vmArgs = new ArrayList<String>();
116 vmArgs.add(gc);
117 app = LingeredApp.startApp(vmArgs);
118 System.out.println ("Started LingeredApp with the GC option " + gc +
119 " and pid " + app.getPid());
120 testClhsdbForUniverse(app.getPid(), gc);
121 } finally {
122 LingeredApp.stopApp(app);
123 }
124 }
125
126
127 public static void main (String... args) throws Exception {
128
129 if (!Platform.shouldSAAttach()) {
130 System.out.println(
131 "SA attach not expected to work - test skipped.");
132 return;
133 }
134
135 try {
136 test("-XX:+UseG1GC");
137 test("-XX:+UseParallelGC");
138 test("-XX:+UseSerialGC");
139 if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
140 test("-XX:+UseConcMarkSweepGC");
141 }
142 } catch (Exception e) {
143 throw new Error("Test failed with " + e);
144 }
145 }
146 }
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import sun.hotspot.code.Compiler;
25
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.io.IOException;
29 import java.util.stream.Collectors;
30 import java.io.OutputStream;
31 import jdk.test.lib.apps.LingeredApp;
32 import jdk.test.lib.JDKToolLauncher;
33 import jdk.test.lib.Platform;
34 import jdk.test.lib.process.OutputAnalyzer;
35
36 /*
37 * @test
38 * @summary Test the 'universe' command of jhsdb clhsdb.
39 * @requires vm.gc != "Z"
40 * @bug 8190307
41 * @library /test/lib
42 * @build jdk.test.lib.apps.*
43 * @build sun.hotspot.WhiteBox
44 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
45 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestUniverse withoutZ
46 */
47
48 /*
49 * @test
50 * @summary Test the 'universe' command of jhsdb clhsdb.
51 * @requires vm.gc == "Z"
52 * @bug 8190307
53 * @library /test/lib
54 * @build jdk.test.lib.apps.*
55 * @build sun.hotspot.WhiteBox
56 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
57 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestUniverse withZ
58 */
59
60 public class TestUniverse {
61
62 private static void testClhsdbForUniverse(long lingeredAppPid,
63 String gc) throws Exception {
64
65 Process p;
66 JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
67 launcher.addToolArg("clhsdb");
68 launcher.addToolArg("--pid");
69 launcher.addToolArg(Long.toString(lingeredAppPid));
70
71 ProcessBuilder pb = new ProcessBuilder();
72 pb.command(launcher.getCommand());
73 System.out.println(
74 pb.command().stream().collect(Collectors.joining(" ")));
75
76 try {
77 p = pb.start();
102 System.out.println(output.getOutput());
103
104 output.shouldContain("Heap Parameters");
105 if (gc.contains("G1GC")) {
106 output.shouldContain("garbage-first heap");
107 output.shouldContain("region size");
108 output.shouldContain("G1 Young Generation:");
109 output.shouldContain("regions =");
110 }
111 if (gc.contains("UseConcMarkSweepGC")) {
112 output.shouldContain("Gen 1: concurrent mark-sweep generation");
113 }
114 if (gc.contains("UseSerialGC")) {
115 output.shouldContain("Gen 1: old");
116 }
117 if (gc.contains("UseParallelGC")) {
118 output.shouldContain("ParallelScavengeHeap");
119 output.shouldContain("PSYoungGen");
120 output.shouldContain("eden");
121 }
122 if (gc.contains("UseZGC")) {
123 output.shouldContain("ZHeap");
124 }
125
126 }
127
128 public static void test(String gc) throws Exception {
129 LingeredApp app = null;
130 try {
131 List<String> vmArgs = new ArrayList<String>();
132 if (gc.contains("UseZGC")) {
133 vmArgs.add("-XX:+UnlockExperimentalVMOptions");
134 }
135 vmArgs.add(gc);
136 app = LingeredApp.startApp(vmArgs);
137 System.out.println ("Started LingeredApp with the GC option " + gc +
138 " and pid " + app.getPid());
139 testClhsdbForUniverse(app.getPid(), gc);
140 } finally {
141 LingeredApp.stopApp(app);
142 }
143 }
144
145
146 public static void main (String... args) throws Exception {
147
148 if (!Platform.shouldSAAttach()) {
149 System.out.println(
150 "SA attach not expected to work - test skipped.");
151 return;
152 }
153
154 try {
155 test("-XX:+UseG1GC");
156 test("-XX:+UseParallelGC");
157 test("-XX:+UseSerialGC");
158 if (!Compiler.isGraalEnabled()) { // Graal does not support all GCs
159 test("-XX:+UseConcMarkSweepGC");
160 if (args[0].equals("withZ")) {
161 test("-XX:+UseZGC");
162 }
163 }
164 } catch (Exception e) {
165 throw new Error("Test failed with " + e);
166 }
167 }
168 }
|