author | lmesnik |
Fri, 26 Apr 2019 11:33:32 -0700 | |
changeset 54638 | 9b8926bf85c1 |
parent 53693 | af078dd4a224 |
child 59053 | ba6c248cae19 |
permissions | -rw-r--r-- |
40914
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
1 |
/* |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
50455
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
40914
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
4 |
* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
8 |
* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
13 |
* accompanied this code). |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
14 |
* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
18 |
* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
21 |
* questions. |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
22 |
*/ |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
23 |
|
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
50455
diff
changeset
|
24 |
package gc; |
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
50455
diff
changeset
|
25 |
|
40914
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
26 |
/* |
54638
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
27 |
* @test TestAgeOutputSerial |
40914
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
28 |
* @bug 8164936 |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
29 |
* @key gc |
54638
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
30 |
* @requires vm.gc.Serial |
40914
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
31 |
* @modules java.base/jdk.internal.misc |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
32 |
* @library /test/lib |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
33 |
* @build sun.hotspot.WhiteBox |
48791
6e079ff6c83c
8186635: ClassFileInstaller should be run as a driver
iignatyev
parents:
47216
diff
changeset
|
34 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
50455
diff
changeset
|
35 |
* @run main/othervm -XX:+UseSerialGC gc.TestAgeOutput UseSerialGC |
54638
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
36 |
*/ |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
37 |
|
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
38 |
/* |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
39 |
* @test TestAgeOutputG1 |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
40 |
* @bug 8164936 |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
41 |
* @summary Check that collectors using age table based aging print an age table even for the first garbage collection |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
42 |
* @key gc |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
43 |
* @requires vm.gc.G1 |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
44 |
* @modules java.base/jdk.internal.misc |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
45 |
* @library /test/lib |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
46 |
* @build sun.hotspot.WhiteBox |
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
47 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
50455
diff
changeset
|
48 |
* @run main/othervm -XX:+UseG1GC gc.TestAgeOutput UseG1GC |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
49 |
*/ |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
50 |
|
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
51 |
/* |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
52 |
* @test TestAgeOutputCMS |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
53 |
* @bug 8164936 |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
54 |
* @key gc |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
55 |
* @comment Graal does not support CMS |
54638
9b8926bf85c1
8220813: update hotspot tier1_gc tests depending on GC to use @requires vm.gc.X
lmesnik
parents:
53693
diff
changeset
|
56 |
* @requires vm.gc.ConcMarkSweep & !vm.graal.enabled |
50455
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
57 |
* @modules java.base/jdk.internal.misc |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
58 |
* @library /test/lib |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
59 |
* @build sun.hotspot.WhiteBox |
2b73cce96dce
8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents:
48791
diff
changeset
|
60 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
50455
diff
changeset
|
61 |
* @run main/othervm -XX:+UseConcMarkSweepGC gc.TestAgeOutput UseConcMarkSweepGC |
40914
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
62 |
*/ |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
63 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
64 |
import sun.hotspot.WhiteBox; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
65 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
66 |
import java.util.regex.Matcher; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
67 |
import java.util.regex.Pattern; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
68 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
69 |
import jdk.test.lib.process.OutputAnalyzer; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
70 |
import jdk.test.lib.process.ProcessTools; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
71 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
72 |
public class TestAgeOutput { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
73 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
74 |
public static void checkPattern(String pattern, String what) throws Exception { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
75 |
Pattern r = Pattern.compile(pattern); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
76 |
Matcher m = r.matcher(what); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
77 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
78 |
if (!m.find()) { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
79 |
throw new RuntimeException("Could not find pattern " + pattern + " in output"); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
80 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
81 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
82 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
83 |
public static void runTest(String gcArg) throws Exception { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
84 |
final String[] arguments = { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
85 |
"-Xbootclasspath/a:.", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
86 |
"-XX:+UnlockExperimentalVMOptions", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
87 |
"-XX:+UnlockDiagnosticVMOptions", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
88 |
"-XX:+WhiteBoxAPI", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
89 |
"-XX:+" + gcArg, |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
90 |
"-Xmx10M", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
91 |
"-Xlog:gc+age=trace", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
92 |
GCTest.class.getName() |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
93 |
}; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
94 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
95 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
96 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
97 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
98 |
output.shouldHaveExitValue(0); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
99 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
100 |
System.out.println(output.getStdout()); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
101 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
102 |
String stdout = output.getStdout(); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
103 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
104 |
checkPattern(".*GC\\(0\\) .*Desired survivor size.*", stdout); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
105 |
checkPattern(".*GC\\(0\\) .*Age table with threshold.*", stdout); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
106 |
checkPattern(".*GC\\(0\\) .*- age 1:.*", stdout); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
107 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
108 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
109 |
public static void main(String[] args) throws Exception { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
110 |
runTest(args[0]); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
111 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
112 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
113 |
static class GCTest { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
114 |
private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
115 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
116 |
public static Object holder; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
117 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
118 |
public static void main(String [] args) { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
119 |
holder = new byte[100]; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
120 |
WB.youngGC(); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
121 |
System.out.println(holder); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
122 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
123 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
124 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
125 |