Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java
40943 views
1
/*
2
* Copyright (c) 2015, 2020, 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.arguments;
25
26
/*
27
* @test TestVerifyBeforeAndAfterGCFlags
28
* @bug 8000831
29
* @summary Runs an simple application (GarbageProducer) with various
30
combinations of -XX:{+|-}Verify{After|Before}GC flags and checks that
31
output contain or doesn't contain expected patterns
32
* @requires vm.gc != "Z" & vm.gc != "Shenandoah"
33
* @modules java.base/jdk.internal.misc
34
* @modules java.management
35
* @library /test/lib
36
* @library /
37
* @run driver gc.arguments.TestVerifyBeforeAndAfterGCFlags
38
*/
39
40
import java.util.ArrayList;
41
import java.util.Collections;
42
43
import jdk.test.lib.Utils;
44
import jdk.test.lib.process.OutputAnalyzer;
45
import jdk.test.lib.process.ProcessTools;
46
47
public class TestVerifyBeforeAndAfterGCFlags {
48
49
// VerifyBeforeGC:[Verifying threads heap tenured eden syms strs zone dict metaspace chunks hand code cache ]
50
public static final String VERIFY_BEFORE_GC_PATTERN = "Verifying Before GC";
51
// VerifyBeforeGC: VerifyBeforeGC: VerifyBeforeGC:
52
public static final String VERIFY_BEFORE_GC_CORRUPTED_PATTERN = "VerifyBeforeGC:(?!\\[Verifying[^]]+\\])";
53
54
// VerifyAfterGC:[Verifying threads heap tenured eden syms strs zone dict metaspace chunks hand code cache ]
55
public static final String VERIFY_AFTER_GC_PATTERN = "Verifying After GC";
56
// VerifyAfterGC: VerifyAfterGC: VerifyAfterGC:
57
public static final String VERIFY_AFTER_GC_CORRUPTED_PATTERN = "VerifyAfterGC:(?!\\[Verifying[^]]+\\])";
58
59
public static void main(String args[]) throws Exception {
60
String[] filteredOpts = Utils.getFilteredTestJavaOpts(
61
new String[] { "-Xlog:gc+verify=debug",
62
"-XX:+UseGCLogFileRotation",
63
"-XX:-DisplayVMOutput",
64
"VerifyBeforeGC",
65
"VerifyAfterGC" });
66
testVerifyFlags(false, false, filteredOpts);
67
testVerifyFlags(true, true, filteredOpts);
68
testVerifyFlags(true, false, filteredOpts);
69
testVerifyFlags(false, true, filteredOpts);
70
}
71
72
public static void testVerifyFlags(boolean verifyBeforeGC,
73
boolean verifyAfterGC,
74
String[] opts) throws Exception {
75
ArrayList<String> vmOpts = new ArrayList<>();
76
if (opts != null && (opts.length > 0)) {
77
Collections.addAll(vmOpts, opts);
78
}
79
Collections.addAll(vmOpts, new String[] {
80
"-Xlog:gc+verify=debug",
81
"-Xmx5m",
82
"-Xms5m",
83
"-Xmn3m",
84
"-XX:+UnlockDiagnosticVMOptions",
85
(verifyBeforeGC ? "-XX:+VerifyBeforeGC"
86
: "-XX:-VerifyBeforeGC"),
87
(verifyAfterGC ? "-XX:+VerifyAfterGC"
88
: "-XX:-VerifyAfterGC"),
89
GarbageProducer.class.getName() });
90
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(vmOpts);
91
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
92
93
analyzer.shouldHaveExitValue(0);
94
analyzer.shouldNotMatch(VERIFY_BEFORE_GC_CORRUPTED_PATTERN);
95
analyzer.shouldNotMatch(VERIFY_AFTER_GC_CORRUPTED_PATTERN);
96
97
if (verifyBeforeGC) {
98
analyzer.shouldMatch(VERIFY_BEFORE_GC_PATTERN);
99
} else {
100
analyzer.shouldNotMatch(VERIFY_BEFORE_GC_PATTERN);
101
}
102
103
if (verifyAfterGC) {
104
analyzer.shouldMatch(VERIFY_AFTER_GC_PATTERN);
105
} else {
106
analyzer.shouldNotMatch(VERIFY_AFTER_GC_PATTERN);
107
}
108
}
109
110
public static class GarbageProducer {
111
static long[][] garbage = new long[10][];
112
113
public static void main(String args[]) {
114
int j = 0;
115
for(int i = 0; i<1000; i++) {
116
garbage[j] = new long[10000];
117
j = (j+1)%garbage.length;
118
}
119
}
120
}
121
}
122
123