Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/arguments/TestG1ConcMarkStepDurationMillis.java
40942 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 TestG1ConcMarkStepDurationMillis
28
* @requires vm.gc.G1
29
* @summary Tests argument processing for double type flag, G1ConcMarkStepDurationMillis
30
* @library /test/lib
31
* @library /
32
* @modules java.base/jdk.internal.misc
33
* java.management
34
* @run driver gc.arguments.TestG1ConcMarkStepDurationMillis
35
*/
36
37
import jdk.test.lib.process.ProcessTools;
38
import jdk.test.lib.process.OutputAnalyzer;
39
import java.util.*;
40
import java.util.regex.*;
41
42
public class TestG1ConcMarkStepDurationMillis {
43
44
static final int PASS = 0;
45
static final int FAIL_IMPROPER_VALUE = 1;
46
static final int FAIL_OUT_RANGE = 2;
47
48
static final String DOUBLE_1 = "1.0";
49
static final String DOUBLE_MAX = "1.79e+308";
50
51
static final String DOUBLE_NEG_EXP = "1.0e-30";
52
static final String NEG_DOUBLE_1 = "-1.0";
53
54
static final String DOUBLE_INF = "1.79e+309";
55
static final String NEG_DOUBLE_INF = "-1.79e+309";
56
static final String DOUBLE_NAN = "abe+309";
57
static final String WRONG_DOUBLE_1 = "1.79e+308e";
58
static final String WRONG_DOUBLE_2 = "1.79ee+308";
59
60
public static void main(String args[]) throws Exception {
61
// Pass cases
62
runG1ConcMarkStepDurationMillisTest(DOUBLE_1, PASS);
63
runG1ConcMarkStepDurationMillisTest(DOUBLE_MAX, PASS);
64
65
// Fail cases: out of range
66
runG1ConcMarkStepDurationMillisTest(DOUBLE_NEG_EXP, FAIL_OUT_RANGE);
67
runG1ConcMarkStepDurationMillisTest(NEG_DOUBLE_1, FAIL_OUT_RANGE);
68
69
// Fail cases: not double
70
runG1ConcMarkStepDurationMillisTest(DOUBLE_INF, FAIL_IMPROPER_VALUE);
71
runG1ConcMarkStepDurationMillisTest(NEG_DOUBLE_INF, FAIL_IMPROPER_VALUE);
72
runG1ConcMarkStepDurationMillisTest(DOUBLE_NAN, FAIL_IMPROPER_VALUE);
73
runG1ConcMarkStepDurationMillisTest(WRONG_DOUBLE_1, FAIL_IMPROPER_VALUE);
74
runG1ConcMarkStepDurationMillisTest(WRONG_DOUBLE_2, FAIL_IMPROPER_VALUE);
75
}
76
77
private static void runG1ConcMarkStepDurationMillisTest(String expectedValue, int expectedResult) throws Exception {
78
List<String> vmOpts = new ArrayList<>();
79
80
Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:G1ConcMarkStepDurationMillis="+expectedValue, "-XX:+PrintFlagsFinal", "-version");
81
82
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(vmOpts);
83
OutputAnalyzer output = new OutputAnalyzer(pb.start());
84
85
output.shouldHaveExitValue(expectedResult == PASS ? 0 : 1);
86
String stdout = output.getStdout();
87
if (expectedResult == PASS) {
88
checkG1ConcMarkStepDurationMillisConsistency(stdout, expectedValue);
89
} else if (expectedResult == FAIL_IMPROPER_VALUE) {
90
output.shouldContain("Improperly specified VM option");
91
} else if (expectedResult == FAIL_OUT_RANGE) {
92
output.shouldContain("outside the allowed range");
93
}
94
}
95
96
private static void checkG1ConcMarkStepDurationMillisConsistency(String output, String expectedValue) {
97
double actualValue = getDoubleValue("G1ConcMarkStepDurationMillis", output);
98
99
if (Double.parseDouble(expectedValue) != actualValue) {
100
throw new RuntimeException(
101
"Actual G1ConcMarkStepDurationMillis(" + Double.toString(actualValue)
102
+ ") is not equal to expected value(" + expectedValue + ")");
103
}
104
}
105
106
public static double getDoubleValue(String flag, String where) {
107
Matcher m = Pattern.compile(flag + "\\s+:?=\\s+\\d+").matcher(where);
108
if (!m.find()) {
109
throw new RuntimeException("Could not find value for flag " + flag + " in output string");
110
}
111
String match = m.group();
112
return Double.parseDouble(match.substring(match.lastIndexOf(" ") + 1, match.length()));
113
}
114
}
115
116