author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57596 | dad0062bb7f3 |
permissions | -rw-r--r-- |
55751 | 1 |
/* |
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* Copyright (c) 2019, Twitter, Inc. |
|
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 |
||
26 |
package gc.metaspace; |
|
27 |
||
57596
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
28 |
import jdk.test.lib.Platform; |
55751 | 29 |
import jdk.test.lib.process.ProcessTools; |
30 |
import jdk.test.lib.process.OutputAnalyzer; |
|
57596
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
31 |
import java.util.ArrayList; |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
32 |
import java.util.List; |
55751 | 33 |
|
34 |
/* @test TestSizeTransitionsSerial |
|
35 |
* @key gc |
|
36 |
* @requires vm.gc.Serial |
|
37 |
* @summary Tests that the metaspace size transition logging is done correctly. |
|
38 |
* @library /test/lib |
|
39 |
* @run driver gc.metaspace.TestSizeTransitions false -XX:+UseSerialGC |
|
40 |
* @run driver gc.metaspace.TestSizeTransitions true -XX:+UseSerialGC |
|
41 |
*/ |
|
42 |
||
43 |
/* @test TestSizeTransitionsParallel |
|
44 |
* @key gc |
|
45 |
* @requires vm.gc.Parallel |
|
46 |
* @summary Tests that the metaspace size transition logging is done correctly. |
|
47 |
* @library /test/lib |
|
48 |
* @run driver gc.metaspace.TestSizeTransitions false -XX:+UseParallelGC |
|
49 |
* @run driver gc.metaspace.TestSizeTransitions true -XX:+UseParallelGC |
|
50 |
*/ |
|
51 |
||
52 |
/* @test TestSizeTransitionsG1 |
|
53 |
* @key gc |
|
54 |
* @requires vm.gc.G1 |
|
55 |
* @summary Tests that the metaspace size transition logging is done correctly. |
|
56 |
* @library /test/lib |
|
57 |
* @run driver gc.metaspace.TestSizeTransitions false -XX:+UseG1GC |
|
58 |
* @run driver gc.metaspace.TestSizeTransitions true -XX:+UseG1GC |
|
59 |
*/ |
|
60 |
||
61 |
/* @test TestSizeTransitionsCMS |
|
62 |
* @key gc |
|
63 |
* @requires vm.gc.ConcMarkSweep |
|
64 |
* @summary Tests that the metaspace size transition logging is done correctly. |
|
65 |
* @library /test/lib |
|
66 |
* @run driver gc.metaspace.TestSizeTransitions false -XX:+UseConcMarkSweepGC |
|
67 |
* @run driver gc.metaspace.TestSizeTransitions true -XX:+UseConcMarkSweepGC |
|
68 |
*/ |
|
69 |
||
70 |
public class TestSizeTransitions { |
|
71 |
public static class Run { |
|
72 |
public static void main(String... args) throws Exception { |
|
73 |
System.out.println("Run started."); |
|
74 |
||
75 |
// easiest way to generate a metaspace transition is to ask for a full GC |
|
76 |
System.gc(); |
|
77 |
||
78 |
System.out.println("Run finished."); |
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
// matches the log tags |
|
83 |
// e.g., [0.043s][info][gc] |
|
84 |
private static final String LOG_TAGS_REGEX = "(\\[.*\\])+ "; |
|
85 |
||
86 |
// matches a size transition |
|
87 |
// e.g., 177K(4864K)->177K(4864K) |
|
88 |
private static final String SIZE_TRANSITION_REGEX = "\\d+K\\(\\d+K\\)->\\d+K\\(\\d+K\\)"; |
|
89 |
||
90 |
// matches -coops metaspace size transitions |
|
91 |
private static final String NO_COOPS_REGEX = |
|
92 |
String.format("^%s.* Metaspace: %s$", |
|
93 |
LOG_TAGS_REGEX, |
|
94 |
SIZE_TRANSITION_REGEX); |
|
95 |
||
96 |
// matches +coops metaspace size transitions |
|
97 |
private static final String COOPS_REGEX = |
|
98 |
String.format("^%s.* Metaspace: %s NonClass: %s Class: %s$", |
|
99 |
LOG_TAGS_REGEX, |
|
100 |
SIZE_TRANSITION_REGEX, |
|
101 |
SIZE_TRANSITION_REGEX, |
|
102 |
SIZE_TRANSITION_REGEX); |
|
103 |
||
104 |
public static void main(String... args) throws Exception { |
|
105 |
// args: <use-coops> <gc-arg> |
|
106 |
if (args.length != 2) { |
|
107 |
throw new RuntimeException("wrong number of args: " + args.length); |
|
108 |
} |
|
109 |
||
57596
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
110 |
final boolean hasCoops = Platform.is64bit(); |
55751 | 111 |
final boolean useCoops = Boolean.parseBoolean(args[0]); |
112 |
final String gcArg = args[1]; |
|
57596
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
113 |
|
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
114 |
if (!hasCoops && useCoops) { |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
115 |
// No need to run this configuration. |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
116 |
System.out.println("Skipping test."); |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
117 |
return; |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
118 |
} |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
119 |
|
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
120 |
List<String> jvmArgs = new ArrayList<>(); |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
121 |
if (hasCoops) { |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
122 |
jvmArgs.add(useCoops ? "-XX:+UseCompressedOops" : "-XX:-UseCompressedOops"); |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
123 |
} |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
124 |
jvmArgs.add(gcArg); |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
125 |
jvmArgs.add("-Xmx256m"); |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
126 |
jvmArgs.add("-Xlog:gc,gc+metaspace=info"); |
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
127 |
jvmArgs.add(TestSizeTransitions.Run.class.getName()); |
55751 | 128 |
|
129 |
System.out.println("JVM args:"); |
|
130 |
for (String a : jvmArgs) { |
|
131 |
System.out.println(" " + a); |
|
132 |
} |
|
133 |
||
57596
dad0062bb7f3
8228672: [TESTBUG] gc/metaspace/TestSizeTransitions.java fails on 32-bit platforms
shade
parents:
55751
diff
changeset
|
134 |
final ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(jvmArgs.toArray(new String[0])); |
55751 | 135 |
final OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
136 |
System.out.println(output.getStdout()); |
|
137 |
output.shouldHaveExitValue(0); |
|
138 |
||
139 |
if (useCoops) { |
|
140 |
output.stdoutShouldMatch(COOPS_REGEX); |
|
141 |
output.stdoutShouldNotMatch(NO_COOPS_REGEX); |
|
142 |
} else { |
|
143 |
output.stdoutShouldMatch(NO_COOPS_REGEX); |
|
144 |
output.stdoutShouldNotMatch(COOPS_REGEX); |
|
145 |
} |
|
146 |
} |
|
147 |
} |