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