Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/arguments/TestHeapFreeRatio.java
40948 views
1
/*
2
* Copyright (c) 2013, 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 TestHeapFreeRatio
28
* @bug 8025661
29
* @summary Test parsing of -Xminf and -Xmaxf
30
* @library /test/lib
31
* @library /
32
* @modules java.base/jdk.internal.misc
33
* java.management
34
* @run driver gc.arguments.TestHeapFreeRatio
35
*/
36
37
import jdk.test.lib.process.OutputAnalyzer;
38
import jdk.test.lib.process.ProcessTools;
39
40
public class TestHeapFreeRatio {
41
42
enum Validation {
43
VALID,
44
MIN_INVALID,
45
MAX_INVALID,
46
OUT_OF_RANGE,
47
COMBINATION_INVALID
48
}
49
50
private static void testMinMaxFreeRatio(String min, String max, Validation type) throws Exception {
51
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
52
"-Xminf" + min,
53
"-Xmaxf" + max,
54
"-version");
55
OutputAnalyzer output = new OutputAnalyzer(pb.start());
56
57
switch (type) {
58
case VALID:
59
output.shouldNotContain("Error");
60
output.shouldHaveExitValue(0);
61
break;
62
case MIN_INVALID:
63
output.shouldContain("Bad min heap free percentage size: -Xminf" + min);
64
output.shouldContain("Error");
65
output.shouldHaveExitValue(1);
66
break;
67
case MAX_INVALID:
68
output.shouldContain("Bad max heap free percentage size: -Xmaxf" + max);
69
output.shouldContain("Error");
70
output.shouldHaveExitValue(1);
71
break;
72
case OUT_OF_RANGE:
73
output.shouldContain("outside the allowed range");
74
output.shouldContain("Error");
75
output.shouldHaveExitValue(1);
76
break;
77
case COMBINATION_INVALID:
78
output.shouldContain("must be less than or equal to MaxHeapFreeRatio");
79
output.shouldContain("Error");
80
output.shouldHaveExitValue(1);
81
break;
82
default:
83
throw new IllegalStateException("Must specify expected validation type");
84
}
85
86
System.out.println(output.getOutput());
87
}
88
89
public static void main(String args[]) throws Exception {
90
testMinMaxFreeRatio( "0.1", "0.5", Validation.VALID);
91
testMinMaxFreeRatio( ".1", ".5", Validation.VALID);
92
testMinMaxFreeRatio( "0.5", "0.5", Validation.VALID);
93
94
testMinMaxFreeRatio("=0.1", "0.5", Validation.MIN_INVALID);
95
testMinMaxFreeRatio("0.1f", "0.5", Validation.MIN_INVALID);
96
testMinMaxFreeRatio(
97
"INVALID", "0.5", Validation.MIN_INVALID);
98
99
testMinMaxFreeRatio( "0.1", "0.5f", Validation.MAX_INVALID);
100
testMinMaxFreeRatio( "0.1", "=0.5", Validation.MAX_INVALID);
101
testMinMaxFreeRatio(
102
"0.1", "INVALID", Validation.MAX_INVALID);
103
104
testMinMaxFreeRatio("-0.1", "0.5", Validation.OUT_OF_RANGE);
105
testMinMaxFreeRatio( "1.1", "0.5", Validation.OUT_OF_RANGE);
106
testMinMaxFreeRatio(
107
"2147483647", "0.5", Validation.OUT_OF_RANGE);
108
testMinMaxFreeRatio( "0.1", "-0.5", Validation.OUT_OF_RANGE);
109
testMinMaxFreeRatio( "0.1", "1.5", Validation.OUT_OF_RANGE);
110
testMinMaxFreeRatio(
111
"0.1", "2147483647", Validation.OUT_OF_RANGE);
112
113
testMinMaxFreeRatio( "0.5", "0.1", Validation.COMBINATION_INVALID);
114
testMinMaxFreeRatio( ".5", ".10", Validation.COMBINATION_INVALID);
115
testMinMaxFreeRatio("0.12","0.100", Validation.COMBINATION_INVALID);
116
}
117
}
118
119