Mercurial > hg > truffle
annotate test/gc/logging/TestGCId.java @ 20392:66d359ee9681
8057143: Incomplete renaming of variables containing "hrs" to "hrm" related to HeapRegionSeq
Summary: Fixup the remaining variable names.
Reviewed-by: tonyp, jwilhelm
author | tschatzl |
---|---|
date | Wed, 03 Sep 2014 17:01:57 +0200 |
parents | 418bb2c2b55a |
children |
rev | line source |
---|---|
20190
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
1 /* |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
4 * |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
8 * |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
13 * accompanied this code). |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
14 * |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
18 * |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
21 * questions. |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
22 */ |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
23 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
24 /* |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
25 * @test TestGCId |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
26 * @bug 8043607 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
27 * @summary Ensure that the GCId is logged |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
28 * @key gc |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
29 * @library /testlibrary |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
30 */ |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
31 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
32 import com.oracle.java.testlibrary.ProcessTools; |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
33 import com.oracle.java.testlibrary.OutputAnalyzer; |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
34 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
35 public class TestGCId { |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
36 public static void main(String[] args) throws Exception { |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
37 testGCId("UseParallelGC", "PrintGC"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
38 testGCId("UseParallelGC", "PrintGCDetails"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
39 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
40 testGCId("UseG1GC", "PrintGC"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
41 testGCId("UseG1GC", "PrintGCDetails"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
42 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
43 testGCId("UseConcMarkSweepGC", "PrintGC"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
44 testGCId("UseConcMarkSweepGC", "PrintGCDetails"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
45 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
46 testGCId("UseSerialGC", "PrintGC"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
47 testGCId("UseSerialGC", "PrintGCDetails"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
48 } |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
49 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
50 private static void verifyContainsGCIDs(OutputAnalyzer output) { |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
51 output.shouldMatch("^#0: \\["); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
52 output.shouldMatch("^#1: \\["); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
53 output.shouldHaveExitValue(0); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
54 } |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
55 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
56 private static void verifyContainsNoGCIDs(OutputAnalyzer output) { |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
57 output.shouldNotMatch("^#[0-9]+: \\["); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
58 output.shouldHaveExitValue(0); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
59 } |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
60 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
61 private static void testGCId(String gcFlag, String logFlag) throws Exception { |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
62 // GCID logging enabled |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
63 ProcessBuilder pb_enabled = |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
64 ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:+PrintGCID", GCTest.class.getName()); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
65 verifyContainsGCIDs(new OutputAnalyzer(pb_enabled.start())); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
66 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
67 // GCID logging disabled |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
68 ProcessBuilder pb_disabled = |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
69 ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:-PrintGCID", GCTest.class.getName()); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
70 verifyContainsNoGCIDs(new OutputAnalyzer(pb_disabled.start())); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
71 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
72 // GCID logging default |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
73 ProcessBuilder pb_default = |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
74 ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", GCTest.class.getName()); |
20195
418bb2c2b55a
8049327: [TESTBUG] gc/logging/TestGCId.java assumes default PrintGCID value is true
brutisso
parents:
20190
diff
changeset
|
75 verifyContainsNoGCIDs(new OutputAnalyzer(pb_default.start())); |
20190
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
76 } |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
77 |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
78 static class GCTest { |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
79 private static byte[] garbage; |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
80 public static void main(String [] args) { |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
81 System.out.println("Creating garbage"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
82 // create 128MB of garbage. This should result in at least one GC |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
83 for (int i = 0; i < 1024; i++) { |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
84 garbage = new byte[128 * 1024]; |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
85 } |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
86 // do a system gc to get one more gc |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
87 System.gc(); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
88 System.out.println("Done"); |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
89 } |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
90 } |
0982ec23da03
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff
changeset
|
91 } |