Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/TestNumWorkerOutput.java
40930 views
1
/*
2
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
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
package gc;
25
26
/*
27
* @test TestNumWorkerOutputG1
28
* @bug 8165292
29
* @summary Check that when PrintGCDetails is enabled, gc,task output is printed only once per collection.
30
* @requires vm.gc.G1
31
* @modules java.base/jdk.internal.misc
32
* @library /test/lib
33
* @build sun.hotspot.WhiteBox
34
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
35
* @run driver gc.TestNumWorkerOutput UseG1GC
36
*/
37
38
import sun.hotspot.WhiteBox;
39
40
import java.util.regex.Matcher;
41
import java.util.regex.Pattern;
42
43
import jdk.test.lib.process.OutputAnalyzer;
44
import jdk.test.lib.process.ProcessTools;
45
46
public class TestNumWorkerOutput {
47
48
public static void checkPatternOnce(String pattern, String what) throws Exception {
49
Pattern r = Pattern.compile(pattern);
50
Matcher m = r.matcher(what);
51
52
if (!m.find()) {
53
throw new RuntimeException("Could not find pattern " + pattern + " in output");
54
}
55
if (m.find()) {
56
throw new RuntimeException("Could find pattern " + pattern + " in output more than once");
57
}
58
}
59
60
public static void runTest(String gcArg) throws Exception {
61
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
62
"-Xbootclasspath/a:.",
63
"-XX:+UnlockExperimentalVMOptions",
64
"-XX:+UnlockDiagnosticVMOptions",
65
"-XX:+WhiteBoxAPI",
66
"-XX:+" + gcArg,
67
"-Xmx10M",
68
"-XX:+PrintGCDetails",
69
GCTest.class.getName());
70
OutputAnalyzer output = new OutputAnalyzer(pb.start());
71
72
output.shouldHaveExitValue(0);
73
74
System.out.println(output.getStdout());
75
76
String stdout = output.getStdout();
77
78
checkPatternOnce(".*[info.*].*[gc,task.*].*GC\\(0\\) .*Using \\d+ workers of \\d+ for evacuation.*", stdout);
79
}
80
81
public static void main(String[] args) throws Exception {
82
runTest(args[0]);
83
}
84
85
static class GCTest {
86
private static final WhiteBox WB = WhiteBox.getWhiteBox();
87
88
public static Object holder;
89
90
public static void main(String [] args) {
91
holder = new byte[100];
92
WB.youngGC();
93
System.out.println(holder);
94
}
95
}
96
}
97
98
99