author | sangheki |
Mon, 05 Oct 2015 14:56:19 -0700 | |
changeset 33144 | c56850e328fc |
parent 32613 | 73bec9f941d7 |
child 36851 | 03e2f4d0a421 |
permissions | -rw-r--r-- |
20723
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
20723
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
20723
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
4 |
* |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
8 |
* |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
13 |
* accompanied this code). |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
14 |
* |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
18 |
* |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
21 |
* questions. |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
22 |
*/ |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
23 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
24 |
/* |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
25 |
* @test TestHeapFreeRatio |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
26 |
* @key gc |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
27 |
* @bug 8025661 |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
28 |
* @summary Test parsing of -Xminf and -Xmaxf |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
29 |
* @library /testlibrary |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
20723
diff
changeset
|
30 |
* @modules java.base/sun.misc |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
20723
diff
changeset
|
31 |
* java.management |
20723
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
32 |
* @run main/othervm TestHeapFreeRatio |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
33 |
*/ |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
34 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
35 |
import jdk.test.lib.*; |
20723
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
36 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
37 |
public class TestHeapFreeRatio { |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
38 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
39 |
enum Validation { |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
40 |
VALID, |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
41 |
MIN_INVALID, |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
42 |
MAX_INVALID, |
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
43 |
OUT_OF_RANGE, |
20723
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
44 |
COMBINATION_INVALID |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
45 |
} |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
46 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
47 |
private static void testMinMaxFreeRatio(String min, String max, Validation type) throws Exception { |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
48 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
49 |
"-Xminf" + min, |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
50 |
"-Xmaxf" + max, |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
51 |
"-version"); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
52 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
53 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
54 |
switch (type) { |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
55 |
case VALID: |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
56 |
output.shouldNotContain("Error"); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
57 |
output.shouldHaveExitValue(0); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
58 |
break; |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
59 |
case MIN_INVALID: |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
60 |
output.shouldContain("Bad min heap free percentage size: -Xminf" + min); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
61 |
output.shouldContain("Error"); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
62 |
output.shouldHaveExitValue(1); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
63 |
break; |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
64 |
case MAX_INVALID: |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
65 |
output.shouldContain("Bad max heap free percentage size: -Xmaxf" + max); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
66 |
output.shouldContain("Error"); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
67 |
output.shouldHaveExitValue(1); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
68 |
break; |
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
69 |
case OUT_OF_RANGE: |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
70 |
output.shouldContain("outside the allowed range"); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
71 |
output.shouldContain("Error"); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
72 |
output.shouldHaveExitValue(1); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
73 |
break; |
20723
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
74 |
case COMBINATION_INVALID: |
33144
c56850e328fc
8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32613
diff
changeset
|
75 |
output.shouldContain("must be less than or equal to MaxHeapFreeRatio"); |
20723
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
76 |
output.shouldContain("Error"); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
77 |
output.shouldHaveExitValue(1); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
78 |
break; |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
79 |
default: |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
80 |
throw new IllegalStateException("Must specify expected validation type"); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
81 |
} |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
82 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
83 |
System.out.println(output.getOutput()); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
84 |
} |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
85 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
86 |
public static void main(String args[]) throws Exception { |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
87 |
testMinMaxFreeRatio( "0.1", "0.5", Validation.VALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
88 |
testMinMaxFreeRatio( ".1", ".5", Validation.VALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
89 |
testMinMaxFreeRatio( "0.5", "0.5", Validation.VALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
90 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
91 |
testMinMaxFreeRatio("=0.1", "0.5", Validation.MIN_INVALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
92 |
testMinMaxFreeRatio("0.1f", "0.5", Validation.MIN_INVALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
93 |
testMinMaxFreeRatio( |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
94 |
"INVALID", "0.5", Validation.MIN_INVALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
95 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
96 |
testMinMaxFreeRatio( "0.1", "0.5f", Validation.MAX_INVALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
97 |
testMinMaxFreeRatio( "0.1", "=0.5", Validation.MAX_INVALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
98 |
testMinMaxFreeRatio( |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
99 |
"0.1", "INVALID", Validation.MAX_INVALID); |
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
100 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
101 |
testMinMaxFreeRatio("-0.1", "0.5", Validation.OUT_OF_RANGE); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
102 |
testMinMaxFreeRatio( "1.1", "0.5", Validation.OUT_OF_RANGE); |
20723
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
103 |
testMinMaxFreeRatio( |
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
104 |
"2147483647", "0.5", Validation.OUT_OF_RANGE); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
105 |
testMinMaxFreeRatio( "0.1", "-0.5", Validation.OUT_OF_RANGE); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
106 |
testMinMaxFreeRatio( "0.1", "1.5", Validation.OUT_OF_RANGE); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
107 |
testMinMaxFreeRatio( |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30604
diff
changeset
|
108 |
"0.1", "2147483647", Validation.OUT_OF_RANGE); |
20723
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
109 |
|
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
110 |
testMinMaxFreeRatio( "0.5", "0.1", Validation.COMBINATION_INVALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
111 |
testMinMaxFreeRatio( ".5", ".10", Validation.COMBINATION_INVALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
112 |
testMinMaxFreeRatio("0.12","0.100", Validation.COMBINATION_INVALID); |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
113 |
} |
929cc8568f8e
8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0
sjohanss
parents:
diff
changeset
|
114 |
} |