annotate test/gc/defnew/HeapChangeLogging.java @ 14343:05ede1d98e1e

8032771: The flag VerifySilently misses a test case Summary: Add test case for the VerifySilently flag. Reviewed-by: brutisso
author tschatzl
date Fri, 31 Jan 2014 09:55:59 +0100
parents dd1b266713ea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14193
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
1 /*
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
4 *
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
7 * published by the Free Software Foundation.
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
8 *
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
13 * accompanied this code).
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
14 *
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
18 *
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
21 * questions.
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
22 */
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
23
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
24 /*
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
25 * @test HeapChangeLogging.java
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
26 * @bug 8027440
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
27 * @library /testlibrary
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
28 * @build HeapChangeLogging
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
29 * @summary Allocate to get a promotion failure and verify that that heap change logging is present.
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
30 * @run main HeapChangeLogging
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
31 *
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
32 * Test the output of G1SummarizeRSetStats in conjunction with G1SummarizeRSetStatsPeriod.
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
33 */
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
34
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
35 import java.util.regex.Matcher;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
36 import java.util.regex.Pattern;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
37
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
38 import com.oracle.java.testlibrary.*;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
39
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
40 public class HeapChangeLogging {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
41 public static void main(String[] args) throws Exception {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
42 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-XX:+PrintGC", "HeapFiller");
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
43 OutputAnalyzer output = new OutputAnalyzer(pb.start());
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
44 String stdout = output.getStdout();
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
45 System.out.println(stdout);
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
46 Matcher stdoutMatcher = Pattern.compile("\\[GC .Allocation Failure.*K->.*K\\(.*K\\), .* secs\\]", Pattern.MULTILINE).matcher(stdout);
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
47 if (!stdoutMatcher.find()) {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
48 throw new RuntimeException("No proper GC log line found");
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
49 }
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
50 output.shouldHaveExitValue(0);
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
51 }
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
52 }
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
53
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
54 class HeapFiller {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
55 public static Entry root;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
56 private static final int PAYLOAD_SIZE = 1000;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
57
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
58 public static void main(String[] args) {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
59 root = new Entry(PAYLOAD_SIZE, null);
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
60 Entry current = root;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
61 try {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
62 while (true) {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
63 Entry newEntry = new Entry(PAYLOAD_SIZE, current);
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
64 current = newEntry;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
65 }
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
66 } catch (OutOfMemoryError e) {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
67 root = null;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
68 }
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
69
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
70 }
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
71 }
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
72
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
73 class Entry {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
74 public Entry previous;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
75 public byte[] payload;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
76
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
77 Entry(int payloadSize, Entry previous) {
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
78 payload = new byte[payloadSize];
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
79 this.previous = previous;
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
80 }
dd1b266713ea 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
81 }