author | twisti |
Mon, 27 Apr 2015 09:02:41 -0700 | |
changeset 30288 | 476c276de939 |
parent 29678 | dd2f3932c21e |
child 30604 | b8d532cb6420 |
permissions | -rw-r--r-- |
28832
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
1 |
/* |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
4 |
* |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
8 |
* |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
13 |
* accompanied this code). |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
14 |
* |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
18 |
* |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
21 |
* questions. |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
22 |
*/ |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
23 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
24 |
/* |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
25 |
* @test TestG1PercentageOptions |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
26 |
* @key gc |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
27 |
* @bug 8068942 |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
28 |
* @summary Test argument processing of various percentage options |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
29 |
* @library /testlibrary |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28832
diff
changeset
|
30 |
* @modules java.base/sun.misc |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28832
diff
changeset
|
31 |
* java.management |
28832
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
32 |
* @run driver TestG1PercentageOptions |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
33 |
*/ |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
34 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
35 |
import com.oracle.java.testlibrary.*; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
36 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
37 |
public class TestG1PercentageOptions { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
38 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
39 |
private static final class OptionDescription { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
40 |
public final String name; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
41 |
public final String[] valid; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
42 |
public final String[] invalid; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
43 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
44 |
OptionDescription(String name_, String[] valid_, String[] invalid_) { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
45 |
name = name_; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
46 |
valid = valid_; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
47 |
invalid = invalid_; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
48 |
} |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
49 |
} |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
50 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
51 |
private static final String[] defaultValid = new String[] { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
52 |
"0", "1", "50", "95", "100" }; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
53 |
private static final String[] defaultInvalid = new String[] { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
54 |
"-10", "110", "bad" }; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
55 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
56 |
// All of the G1 product arguments that are percentages. |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
57 |
private static final OptionDescription[] percentOptions = new OptionDescription[] { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
58 |
new OptionDescription("G1ConfidencePercent", defaultValid, defaultInvalid) |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
59 |
// Other percentage options are not yet validated by argument processing. |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
60 |
}; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
61 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
62 |
private static void check(String flag, boolean is_valid) throws Exception { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
63 |
String[] flags = new String[] { "-XX:+UseG1GC", flag, "-version" }; |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
64 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
65 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
66 |
if (is_valid) { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
67 |
output.shouldHaveExitValue(0); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
68 |
} else { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
69 |
output.shouldHaveExitValue(1); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
70 |
} |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
71 |
} |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
72 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
73 |
private static |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
74 |
void check(String name, String value, boolean is_valid) throws Exception { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
75 |
check("-XX:" + name + "=" + value, is_valid); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
76 |
} |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
77 |
|
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
78 |
public static void main(String args[]) throws Exception { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
79 |
for (OptionDescription option : percentOptions) { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
80 |
for (String value : option.valid) { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
81 |
check(option.name, value, true); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
82 |
} |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
83 |
for (String value : option.invalid) { |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
84 |
check(option.name, value, false); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
85 |
} |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
86 |
check("-XX:" + option.name, false); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
87 |
check("-XX:+" + option.name, false); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
88 |
check("-XX:-" + option.name, false); |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
89 |
} |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
90 |
} |
4c2704386850
8068942: Improve validation of -XX:G1ConfidencePercent value
kbarrett
parents:
diff
changeset
|
91 |
} |