test/gc/g1/TestGCLogMessages.java

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6413
595c0f60d50d
parent 0
f90c822e73f8
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 */
aoqi@0 23
aoqi@0 24 /*
aoqi@0 25 * @test TestPrintGCDetails
aoqi@0 26 * @bug 8035406 8027295 8035398
aoqi@0 27 * @summary Ensure that the PrintGCDetails output for a minor GC with G1
aoqi@0 28 * includes the expected necessary messages.
aoqi@0 29 * @key gc
aoqi@0 30 * @library /testlibrary
aoqi@0 31 */
aoqi@0 32
aoqi@0 33 import com.oracle.java.testlibrary.ProcessTools;
aoqi@0 34 import com.oracle.java.testlibrary.OutputAnalyzer;
aoqi@0 35
aoqi@0 36 public class TestGCLogMessages {
aoqi@0 37 public static void main(String[] args) throws Exception {
aoqi@0 38 testNormalLogs();
aoqi@0 39 testWithToSpaceExhaustionLogs();
aoqi@0 40 }
aoqi@0 41
aoqi@0 42 private static void testNormalLogs() throws Exception {
aoqi@0 43
aoqi@0 44 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
aoqi@0 45 "-Xmx10M",
aoqi@0 46 GCTest.class.getName());
aoqi@0 47
aoqi@0 48 OutputAnalyzer output = new OutputAnalyzer(pb.start());
aoqi@0 49
aoqi@0 50 output.shouldNotContain("[Redirty Cards");
aoqi@0 51 output.shouldNotContain("[Code Root Purge");
aoqi@0 52 output.shouldNotContain("[String Dedup Fixup");
aoqi@0 53 output.shouldNotContain("[Young Free CSet");
aoqi@0 54 output.shouldNotContain("[Non-Young Free CSet");
aoqi@0 55 output.shouldHaveExitValue(0);
aoqi@0 56
aoqi@0 57 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
aoqi@0 58 "-XX:+UseStringDeduplication",
aoqi@0 59 "-Xmx10M",
aoqi@0 60 "-XX:+PrintGCDetails",
aoqi@0 61 GCTest.class.getName());
aoqi@0 62
aoqi@0 63 output = new OutputAnalyzer(pb.start());
aoqi@0 64
aoqi@0 65 output.shouldContain("[Redirty Cards");
aoqi@0 66 output.shouldContain("[Code Root Purge");
aoqi@0 67 output.shouldContain("[String Dedup Fixup");
aoqi@0 68 output.shouldNotContain("[Young Free CSet");
aoqi@0 69 output.shouldNotContain("[Non-Young Free CSet");
aoqi@0 70 output.shouldHaveExitValue(0);
aoqi@0 71
aoqi@0 72 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
aoqi@0 73 "-XX:+UseStringDeduplication",
aoqi@0 74 "-Xmx10M",
aoqi@0 75 "-XX:+PrintGCDetails",
aoqi@0 76 "-XX:+UnlockExperimentalVMOptions",
aoqi@0 77 "-XX:G1LogLevel=finest",
aoqi@0 78 GCTest.class.getName());
aoqi@0 79
aoqi@0 80 output = new OutputAnalyzer(pb.start());
aoqi@0 81
aoqi@0 82 output.shouldContain("[Redirty Cards");
aoqi@0 83 output.shouldContain("[Code Root Purge");
aoqi@0 84 output.shouldContain("[String Dedup Fixup");
aoqi@0 85 output.shouldContain("[Young Free CSet");
aoqi@0 86 output.shouldContain("[Non-Young Free CSet");
aoqi@0 87
aoqi@0 88 // also check evacuation failure messages once
aoqi@0 89 output.shouldNotContain("[Evacuation Failure");
aoqi@0 90 output.shouldNotContain("[Recalculate Used");
aoqi@0 91 output.shouldNotContain("[Remove Self Forwards");
aoqi@0 92 output.shouldNotContain("[Restore RemSet");
aoqi@0 93 output.shouldHaveExitValue(0);
aoqi@0 94 }
aoqi@0 95
aoqi@0 96 private static void testWithToSpaceExhaustionLogs() throws Exception {
aoqi@0 97 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
aoqi@0 98 "-Xmx10M",
aoqi@0 99 "-Xmn5M",
aoqi@0 100 "-XX:+PrintGCDetails",
aoqi@0 101 GCTestWithToSpaceExhaustion.class.getName());
aoqi@0 102
aoqi@0 103 OutputAnalyzer output = new OutputAnalyzer(pb.start());
aoqi@0 104 output.shouldContain("[Evacuation Failure");
aoqi@0 105 output.shouldNotContain("[Recalculate Used");
aoqi@0 106 output.shouldNotContain("[Remove Self Forwards");
aoqi@0 107 output.shouldNotContain("[Restore RemSet");
aoqi@0 108 output.shouldHaveExitValue(0);
aoqi@0 109
aoqi@0 110 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
aoqi@0 111 "-Xmx10M",
aoqi@0 112 "-Xmn5M",
aoqi@0 113 "-XX:+PrintGCDetails",
aoqi@0 114 "-XX:+UnlockExperimentalVMOptions",
aoqi@0 115 "-XX:G1LogLevel=finest",
aoqi@0 116 GCTestWithToSpaceExhaustion.class.getName());
aoqi@0 117
aoqi@0 118 output = new OutputAnalyzer(pb.start());
aoqi@0 119 output.shouldContain("[Evacuation Failure");
aoqi@0 120 output.shouldContain("[Recalculate Used");
aoqi@0 121 output.shouldContain("[Remove Self Forwards");
aoqi@0 122 output.shouldContain("[Restore RemSet");
aoqi@0 123 output.shouldHaveExitValue(0);
aoqi@0 124 }
aoqi@0 125
aoqi@0 126 static class GCTest {
aoqi@0 127 private static byte[] garbage;
aoqi@0 128 public static void main(String [] args) {
aoqi@0 129 System.out.println("Creating garbage");
aoqi@0 130 // create 128MB of garbage. This should result in at least one GC
aoqi@0 131 for (int i = 0; i < 1024; i++) {
aoqi@0 132 garbage = new byte[128 * 1024];
aoqi@0 133 }
aoqi@0 134 System.out.println("Done");
aoqi@0 135 }
aoqi@0 136 }
aoqi@0 137
aoqi@0 138 static class GCTestWithToSpaceExhaustion {
aoqi@0 139 private static byte[] garbage;
aoqi@0 140 private static byte[] largeObject;
aoqi@0 141 public static void main(String [] args) {
aoqi@0 142 largeObject = new byte[5*1024*1024];
aoqi@0 143 System.out.println("Creating garbage");
aoqi@0 144 // create 128MB of garbage. This should result in at least one GC,
aoqi@0 145 // some of them with to-space exhaustion.
aoqi@0 146 for (int i = 0; i < 1024; i++) {
aoqi@0 147 garbage = new byte[128 * 1024];
aoqi@0 148 }
aoqi@0 149 System.out.println("Done");
aoqi@0 150 }
aoqi@0 151 }
aoqi@0 152 }

mercurial