author | sangheki |
Thu, 10 Aug 2017 18:09:19 -0700 | |
changeset 46795 | 623a5e42deb6 |
parent 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
33803 | 1 |
/* |
36390
a2d991d1d628
8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents:
35753
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
33803 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
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 TestPLABOutput |
|
26 |
* @bug 8140585 |
|
27 |
* @summary Check that G1 does not report empty PLAB statistics in the first evacuation. |
|
39414
4adf52148100
8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents:
38152
diff
changeset
|
28 |
* @requires vm.gc.G1 |
33803 | 29 |
* @key gc |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36390
diff
changeset
|
30 |
* @modules java.base/jdk.internal.misc |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
31 |
* @library /test/lib |
33803 | 32 |
* @build sun.hotspot.WhiteBox |
33 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
|
34 |
* @run driver TestPLABOutput |
|
35 |
*/ |
|
36 |
||
37 |
import sun.hotspot.WhiteBox; |
|
38 |
||
39 |
import java.util.regex.Matcher; |
|
40 |
import java.util.regex.Pattern; |
|
41 |
||
42 |
import jdk.test.lib.Platform; |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
43 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
44 |
import jdk.test.lib.process.ProcessTools; |
33803 | 45 |
|
46 |
import static jdk.test.lib.Asserts.*; |
|
47 |
||
48 |
public class TestPLABOutput { |
|
49 |
||
50 |
public static void runTest() throws Exception { |
|
51 |
final String[] arguments = { |
|
52 |
"-Xbootclasspath/a:.", |
|
53 |
"-XX:+UnlockExperimentalVMOptions", |
|
54 |
"-XX:+UnlockDiagnosticVMOptions", |
|
55 |
"-XX:+WhiteBoxAPI", |
|
56 |
"-XX:+UseG1GC", |
|
57 |
"-Xmx10M", |
|
35061 | 58 |
"-Xlog:gc+plab=debug", |
33803 | 59 |
GCTest.class.getName() |
60 |
}; |
|
61 |
||
62 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); |
|
63 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
|
64 |
||
65 |
output.shouldHaveExitValue(0); |
|
66 |
||
67 |
System.out.println(output.getStdout()); |
|
68 |
||
36390
a2d991d1d628
8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents:
35753
diff
changeset
|
69 |
String pattern = ".*GC\\(0\\) .*allocated: (\\d+).*"; |
33803 | 70 |
Pattern r = Pattern.compile(pattern); |
71 |
Matcher m = r.matcher(output.getStdout()); |
|
72 |
||
73 |
if (!m.find()) { |
|
74 |
throw new RuntimeException("Could not find any PLAB statistics output"); |
|
75 |
} |
|
76 |
int allocated = Integer.parseInt(m.group(1)); |
|
77 |
assertGT(allocated, 0, "Did not allocate any memory during test"); |
|
78 |
} |
|
79 |
||
80 |
public static void main(String[] args) throws Exception { |
|
81 |
runTest(); |
|
82 |
} |
|
83 |
||
84 |
static class GCTest { |
|
85 |
private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
|
86 |
||
87 |
public static Object holder; |
|
88 |
||
89 |
public static void main(String [] args) { |
|
90 |
holder = new byte[100]; |
|
91 |
WB.youngGC(); |
|
92 |
System.out.println(holder); |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |