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
26 package gc.metaspace;
27
28 import jdk.test.lib.Platform;
29 import jdk.test.lib.process.ProcessTools;
30 import jdk.test.lib.process.OutputAnalyzer;
31 import java.util.ArrayList;
32 import java.util.List;
33
34 /* @test TestSizeTransitionsSerial
35 * @requires vm.gc.Serial
36 * @summary Tests that the metaspace size transition logging is done correctly.
37 * @library /test/lib
38 * @run driver gc.metaspace.TestSizeTransitions false -XX:+UseSerialGC
39 * @run driver gc.metaspace.TestSizeTransitions true -XX:+UseSerialGC
40 */
41
42 /* @test TestSizeTransitionsParallel
43 * @requires vm.gc.Parallel
44 * @summary Tests that the metaspace size transition logging is done correctly.
45 * @library /test/lib
46 * @run driver gc.metaspace.TestSizeTransitions false -XX:+UseParallelGC
47 * @run driver gc.metaspace.TestSizeTransitions true -XX:+UseParallelGC
48 */
49
50 /* @test TestSizeTransitionsG1
51 * @requires vm.gc.G1
52 * @summary Tests that the metaspace size transition logging is done correctly.
53 * @library /test/lib
54 * @run driver gc.metaspace.TestSizeTransitions false -XX:+UseG1GC
55 * @run driver gc.metaspace.TestSizeTransitions true -XX:+UseG1GC
56 */
57
58 public class TestSizeTransitions {
59 public static class Run {
60 public static void main(String... args) throws Exception {
61 System.out.println("Run started.");
62
63 // easiest way to generate a metaspace transition is to ask for a full GC
64 System.gc();
65
66 System.out.println("Run finished.");
67 }
68 }
69
70 // matches the log tags
71 // e.g., [0.043s][info][gc]
72 private static final String LOG_TAGS_REGEX = "(\\[.*\\])+ ";
73
74 // matches a size transition
75 // e.g., 177K(4864K)->177K(4864K)
76 private static final String SIZE_TRANSITION_REGEX = "\\d+K\\(\\d+K\\)->\\d+K\\(\\d+K\\)";
77
78 // matches -coops metaspace size transitions
79 private static final String NO_COMPRESSED_KLASS_POINTERS_REGEX =
80 String.format("^%s.* Metaspace: %s$",
81 LOG_TAGS_REGEX,
82 SIZE_TRANSITION_REGEX);
83
84 // matches +coops metaspace size transitions
85 private static final String COMPRESSED_KLASS_POINTERS_REGEX =
86 String.format("^%s.* Metaspace: %s NonClass: %s Class: %s$",
87 LOG_TAGS_REGEX,
88 SIZE_TRANSITION_REGEX,
89 SIZE_TRANSITION_REGEX,
90 SIZE_TRANSITION_REGEX);
91
92 public static void main(String... args) throws Exception {
93 // args: <use-coops> <gc-arg>
94 if (args.length != 2) {
95 throw new RuntimeException("wrong number of args: " + args.length);
96 }
97
98 final boolean hasCompressedKlassPointers = Platform.is64bit();
99 final boolean useCompressedKlassPointers = Boolean.parseBoolean(args[0]);
100 final String gcArg = args[1];
101
102 if (!hasCompressedKlassPointers && useCompressedKlassPointers) {
103 // No need to run this configuration.
104 System.out.println("Skipping test.");
105 return;
106 }
107
108 List<String> jvmArgs = new ArrayList<>();
109 if (hasCompressedKlassPointers) {
110 jvmArgs.add(useCompressedKlassPointers ? "-XX:+UseCompressedClassPointers" : "-XX:-UseCompressedClassPointers");
111 }
112 jvmArgs.add(gcArg);
113 jvmArgs.add("-Xmx256m");
114 jvmArgs.add("-Xlog:gc,gc+metaspace=info");
115 jvmArgs.add(TestSizeTransitions.Run.class.getName());
116
117 System.out.println("JVM args:");
118 for (String a : jvmArgs) {
119 System.out.println(" " + a);
120 }
121
122 final ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(jvmArgs);
123 final OutputAnalyzer output = new OutputAnalyzer(pb.start());
124 System.out.println(output.getStdout());
125 output.shouldHaveExitValue(0);
126
127 if (useCompressedKlassPointers) {
128 output.stdoutShouldMatch(COMPRESSED_KLASS_POINTERS_REGEX);
129 output.stdoutShouldNotMatch(NO_COMPRESSED_KLASS_POINTERS_REGEX);
130 } else {
131 output.stdoutShouldMatch(NO_COMPRESSED_KLASS_POINTERS_REGEX);
132 output.stdoutShouldNotMatch(COMPRESSED_KLASS_POINTERS_REGEX);
133 }
134 }
135 }
|
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
26 package gc.metaspace;
27
28 import jdk.test.lib.Platform;
29 import jdk.test.lib.process.ProcessTools;
30 import jdk.test.lib.process.OutputAnalyzer;
31 import java.util.ArrayList;
32 import java.util.List;
33
34 /* @test TestSizeTransitionsSerial
35 * @requires vm.gc.Serial
36 * @summary Tests that the metaspace size transition logging is done correctly.
37 * @library /test/lib
38 * @run driver gc.metaspace.TestSizeTransitions -XX:+UseSerialGC
39 */
40
41 /* @test TestSizeTransitionsParallel
42 * @requires vm.gc.Parallel
43 * @summary Tests that the metaspace size transition logging is done correctly.
44 * @library /test/lib
45 * @run driver gc.metaspace.TestSizeTransitions -XX:+UseParallelGC
46 */
47
48 /* @test TestSizeTransitionsG1
49 * @requires vm.gc.G1
50 * @summary Tests that the metaspace size transition logging is done correctly.
51 * @library /test/lib
52 * @run driver gc.metaspace.TestSizeTransitions -XX:+UseG1GC
53 */
54
55 public class TestSizeTransitions {
56 public static class Run {
57 public static void main(String... args) throws Exception {
58 System.out.println("Run started.");
59
60 // easiest way to generate a metaspace transition is to ask for a full GC
61 System.gc();
62
63 System.out.println("Run finished.");
64 }
65 }
66
67 // matches the log tags
68 // e.g., [0.043s][info][gc]
69 private static final String LOG_TAGS_REGEX = "(\\[.*\\])+ ";
70
71 // matches a size transition
72 // e.g., 177K(4864K)->177K(4864K)
73 private static final String SIZE_TRANSITION_REGEX = "\\d+K\\(\\d+K\\)->\\d+K\\(\\d+K\\)";
74
75 // matches -coops metaspace size transitions
76 private static final String NO_COMPRESSED_KLASS_POINTERS_REGEX =
77 String.format("^%s.* Metaspace: %s$",
78 LOG_TAGS_REGEX,
79 SIZE_TRANSITION_REGEX);
80
81 // matches +coops metaspace size transitions
82 private static final String COMPRESSED_KLASS_POINTERS_REGEX =
83 String.format("^%s.* Metaspace: %s NonClass: %s Class: %s$",
84 LOG_TAGS_REGEX,
85 SIZE_TRANSITION_REGEX,
86 SIZE_TRANSITION_REGEX,
87 SIZE_TRANSITION_REGEX);
88
89 public static void main(String... args) throws Exception {
90 // args: <gc-arg>
91 if (args.length != 1) {
92 throw new RuntimeException("wrong number of args: " + args.length);
93 }
94
95 final boolean hasCompressedKlassPointers = Platform.is64bit();
96 final String gcArg = args[0];
97
98 List<String> jvmArgs = new ArrayList<>();
99 jvmArgs.add(gcArg);
100 jvmArgs.add("-Xmx256m");
101 jvmArgs.add("-Xlog:gc,gc+metaspace=info");
102 jvmArgs.add(TestSizeTransitions.Run.class.getName());
103
104 System.out.println("JVM args:");
105 for (String a : jvmArgs) {
106 System.out.println(" " + a);
107 }
108
109 final ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(jvmArgs);
110 final OutputAnalyzer output = new OutputAnalyzer(pb.start());
111 System.out.println(output.getStdout());
112 output.shouldHaveExitValue(0);
113
114 if (hasCompressedKlassPointers) {
115 output.stdoutShouldMatch(COMPRESSED_KLASS_POINTERS_REGEX);
116 output.stdoutShouldNotMatch(NO_COMPRESSED_KLASS_POINTERS_REGEX);
117 } else {
118 output.stdoutShouldMatch(NO_COMPRESSED_KLASS_POINTERS_REGEX);
119 output.stdoutShouldNotMatch(COMPRESSED_KLASS_POINTERS_REGEX);
120 }
121 }
122 }
|