6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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 /*
25 * @test TestGCLogMessages
26 * @bug 8035406 8027295 8035398 8019342 8027959 8027962
27 * @summary Ensure that the PrintGCDetails output for a minor GC with G1
28 * includes the expected necessary messages.
29 * @key gc
30 * @library /testlibrary
31 */
32
33 import com.oracle.java.testlibrary.ProcessTools;
34 import com.oracle.java.testlibrary.OutputAnalyzer;
35
36 public class TestGCLogMessages {
37
38 private enum Level {
39 OFF, FINER, FINEST;
40 public boolean lessOrEqualTo(Level other) {
41 return this.compareTo(other) < 0;
42 }
43 }
44
45 private class LogMessageWithLevel {
46 String message;
64 new LogMessageWithLevel("SystemDictionary Roots", Level.FINEST),
65 new LogMessageWithLevel("CLDG Roots", Level.FINEST),
66 new LogMessageWithLevel("JVMTI Roots", Level.FINEST),
67 new LogMessageWithLevel("CodeCache Roots", Level.FINEST),
68 new LogMessageWithLevel("SATB Filtering", Level.FINEST),
69 new LogMessageWithLevel("CM RefProcessor Roots", Level.FINEST),
70 new LogMessageWithLevel("Wait For Strong CLD", Level.FINEST),
71 new LogMessageWithLevel("Weak CLD Roots", Level.FINEST),
72 // Redirty Cards
73 new LogMessageWithLevel("Redirty Cards", Level.FINER),
74 new LogMessageWithLevel("Parallel Redirty", Level.FINEST),
75 new LogMessageWithLevel("Redirtied Cards", Level.FINEST),
76 // Misc Top-level
77 new LogMessageWithLevel("Code Root Purge", Level.FINER),
78 new LogMessageWithLevel("String Dedup Fixup", Level.FINER),
79 // Free CSet
80 new LogMessageWithLevel("Young Free CSet", Level.FINEST),
81 new LogMessageWithLevel("Non-Young Free CSet", Level.FINEST),
82 // Humongous Eager Reclaim
83 new LogMessageWithLevel("Humongous Reclaim", Level.FINER),
84 };
85
86 void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[], Level level) throws Exception {
87 for (LogMessageWithLevel l : messages) {
88 if (level.lessOrEqualTo(l.level)) {
89 output.shouldNotContain(l.message);
90 } else {
91 output.shouldContain(l.message);
92 }
93 }
94 }
95
96 public static void main(String[] args) throws Exception {
97 new TestGCLogMessages().testNormalLogs();
98 new TestGCLogMessages().testWithToSpaceExhaustionLogs();
99 }
100
101 private void testNormalLogs() throws Exception {
102
103 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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 /*
25 * @test TestGCLogMessages
26 * @bug 8035406 8027295 8035398 8019342 8027959 8048179 8027962
27 * @summary Ensure that the PrintGCDetails output for a minor GC with G1
28 * includes the expected necessary messages.
29 * @key gc
30 * @library /testlibrary
31 */
32
33 import com.oracle.java.testlibrary.ProcessTools;
34 import com.oracle.java.testlibrary.OutputAnalyzer;
35
36 public class TestGCLogMessages {
37
38 private enum Level {
39 OFF, FINER, FINEST;
40 public boolean lessOrEqualTo(Level other) {
41 return this.compareTo(other) < 0;
42 }
43 }
44
45 private class LogMessageWithLevel {
46 String message;
64 new LogMessageWithLevel("SystemDictionary Roots", Level.FINEST),
65 new LogMessageWithLevel("CLDG Roots", Level.FINEST),
66 new LogMessageWithLevel("JVMTI Roots", Level.FINEST),
67 new LogMessageWithLevel("CodeCache Roots", Level.FINEST),
68 new LogMessageWithLevel("SATB Filtering", Level.FINEST),
69 new LogMessageWithLevel("CM RefProcessor Roots", Level.FINEST),
70 new LogMessageWithLevel("Wait For Strong CLD", Level.FINEST),
71 new LogMessageWithLevel("Weak CLD Roots", Level.FINEST),
72 // Redirty Cards
73 new LogMessageWithLevel("Redirty Cards", Level.FINER),
74 new LogMessageWithLevel("Parallel Redirty", Level.FINEST),
75 new LogMessageWithLevel("Redirtied Cards", Level.FINEST),
76 // Misc Top-level
77 new LogMessageWithLevel("Code Root Purge", Level.FINER),
78 new LogMessageWithLevel("String Dedup Fixup", Level.FINER),
79 // Free CSet
80 new LogMessageWithLevel("Young Free CSet", Level.FINEST),
81 new LogMessageWithLevel("Non-Young Free CSet", Level.FINEST),
82 // Humongous Eager Reclaim
83 new LogMessageWithLevel("Humongous Reclaim", Level.FINER),
84 new LogMessageWithLevel("Humongous Register", Level.FINER),
85 };
86
87 void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[], Level level) throws Exception {
88 for (LogMessageWithLevel l : messages) {
89 if (level.lessOrEqualTo(l.level)) {
90 output.shouldNotContain(l.message);
91 } else {
92 output.shouldContain(l.message);
93 }
94 }
95 }
96
97 public static void main(String[] args) throws Exception {
98 new TestGCLogMessages().testNormalLogs();
99 new TestGCLogMessages().testWithToSpaceExhaustionLogs();
100 }
101
102 private void testNormalLogs() throws Exception {
103
104 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
|