author | ddmitriev |
Sat, 12 Dec 2015 21:23:20 +0300 | |
changeset 35074 | 4ac430acedd7 |
parent 34661 | 9a1d11d88ea0 |
child 36175 | 0f5b32ce95fc |
permissions | -rw-r--r-- |
31372
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
1 |
/* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
4 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
8 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
13 |
* accompanied this code). |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
14 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
18 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
21 |
* questions. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
22 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
23 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
24 |
package optionsvalidation; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
25 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
26 |
import java.io.BufferedReader; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
27 |
import java.io.IOException; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
28 |
import java.io.InputStreamReader; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
29 |
import java.io.Reader; |
34242
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
30 |
import java.math.BigDecimal; |
31372
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
31 |
import java.util.ArrayList; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
32 |
import java.util.Arrays; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
33 |
import java.util.List; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
34 |
import java.util.LinkedHashMap; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
35 |
import java.util.Map; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
36 |
import java.util.StringTokenizer; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
37 |
import java.util.function.Predicate; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
38 |
import jdk.test.lib.OutputAnalyzer; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
39 |
import jdk.test.lib.Platform; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
40 |
import jdk.test.lib.ProcessTools; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
41 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
42 |
public class JVMOptionsUtils { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
43 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
44 |
/* Java option which print options with ranges */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
45 |
private static final String PRINT_FLAGS_RANGES = "-XX:+PrintFlagsRanges"; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
46 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
47 |
/* StringBuilder to accumulate failed message */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
48 |
private static final StringBuilder finalFailedMessage = new StringBuilder(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
49 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
50 |
/* Used to start the JVM with the same type as current */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
51 |
static String VMType; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
52 |
|
34242
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
53 |
private static Map<String, JVMOption> optionsAsMap; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
54 |
|
31372
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
55 |
static { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
56 |
if (Platform.isServer()) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
57 |
VMType = "-server"; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
58 |
} else if (Platform.isClient()) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
59 |
VMType = "-client"; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
60 |
} else if (Platform.isMinimal()) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
61 |
VMType = "-minimal"; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
62 |
} else if (Platform.isGraal()) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
63 |
VMType = "-graal"; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
64 |
} else { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
65 |
VMType = null; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
66 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
67 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
68 |
|
34242
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
69 |
public static boolean fitsRange(String optionName, BigDecimal number) throws Exception { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
70 |
JVMOption option; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
71 |
String minRangeString = null; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
72 |
String maxRangeString = null; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
73 |
boolean fits = true; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
74 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
75 |
if (optionsAsMap == null) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
76 |
optionsAsMap = getOptionsWithRangeAsMap(); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
77 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
78 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
79 |
option = optionsAsMap.get(optionName); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
80 |
if (option != null) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
81 |
minRangeString = option.getMin(); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
82 |
if (minRangeString != null) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
83 |
fits = (number.compareTo(new BigDecimal(minRangeString)) >= 0); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
84 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
85 |
maxRangeString = option.getMax(); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
86 |
if (maxRangeString != null) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
87 |
fits &= (number.compareTo(new BigDecimal(maxRangeString)) <= 0); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
88 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
89 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
90 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
91 |
return fits; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
92 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
93 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
94 |
public static boolean fitsRange(String optionName, String number) throws Exception { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
95 |
String lowerCase = number.toLowerCase(); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
96 |
String multiplier = "1"; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
97 |
if (lowerCase.endsWith("k")) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
98 |
multiplier = "1024"; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
99 |
lowerCase = lowerCase.substring(0, lowerCase.length()-1); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
100 |
} else if (lowerCase.endsWith("m")) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
101 |
multiplier = "1048576"; //1024*1024 |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
102 |
lowerCase = lowerCase.substring(0, lowerCase.length()-1); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
103 |
} else if (lowerCase.endsWith("g")) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
104 |
multiplier = "1073741824"; //1024*1024*1024 |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
105 |
lowerCase = lowerCase.substring(0, lowerCase.length()-1); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
106 |
} else if (lowerCase.endsWith("t")) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
107 |
multiplier = "1099511627776"; //1024*1024*1024*1024 |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
108 |
lowerCase = lowerCase.substring(0, lowerCase.length()-1); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
109 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
110 |
BigDecimal valueBig = new BigDecimal(lowerCase); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
111 |
BigDecimal multiplierBig = new BigDecimal(multiplier); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
112 |
return fitsRange(optionName, valueBig.multiply(multiplierBig)); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
113 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
114 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
115 |
public static String getMinOptionRange(String optionName) throws Exception { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
116 |
JVMOption option; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
117 |
String minRange = null; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
118 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
119 |
if (optionsAsMap == null) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
120 |
optionsAsMap = getOptionsWithRangeAsMap(); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
121 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
122 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
123 |
option = optionsAsMap.get(optionName); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
124 |
if (option != null) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
125 |
minRange = option.getMin(); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
126 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
127 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
128 |
return minRange; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
129 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
130 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
131 |
public static String getMaxOptionRange(String optionName) throws Exception { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
132 |
JVMOption option; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
133 |
String maxRange = null; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
134 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
135 |
if (optionsAsMap == null) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
136 |
optionsAsMap = getOptionsWithRangeAsMap(); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
137 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
138 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
139 |
option = optionsAsMap.get(optionName); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
140 |
if (option != null) { |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
141 |
maxRange = option.getMax(); |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
142 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
143 |
|
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
144 |
return maxRange; |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
145 |
} |
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
33610
diff
changeset
|
146 |
|
31372
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
147 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
148 |
* Add dependency for option depending on it's name. E.g. enable G1 GC for |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
149 |
* G1 options or add prepend options to not hit constraints. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
150 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
151 |
* @param option option |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
152 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
153 |
private static void addNameDependency(JVMOption option) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
154 |
String name = option.getName(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
155 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
156 |
if (name.startsWith("G1")) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
157 |
option.addPrepend("-XX:+UseG1GC"); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
158 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
159 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
160 |
if (name.startsWith("CMS")) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
161 |
option.addPrepend("-XX:+UseConcMarkSweepGC"); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
162 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
163 |
|
34661
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
164 |
if (name.startsWith("NUMA")) { |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
165 |
option.addPrepend("-XX:+UseNUMA"); |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
166 |
} |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
167 |
|
31372
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
168 |
switch (name) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
169 |
case "MinHeapFreeRatio": |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
170 |
option.addPrepend("-XX:MaxHeapFreeRatio=100"); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
171 |
break; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
172 |
case "MaxHeapFreeRatio": |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
173 |
option.addPrepend("-XX:MinHeapFreeRatio=0"); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
174 |
break; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
175 |
case "MinMetaspaceFreeRatio": |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
176 |
option.addPrepend("-XX:MaxMetaspaceFreeRatio=100"); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
177 |
break; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
178 |
case "MaxMetaspaceFreeRatio": |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
179 |
option.addPrepend("-XX:MinMetaspaceFreeRatio=0"); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
180 |
break; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
181 |
case "CMSOldPLABMin": |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
182 |
option.addPrepend("-XX:CMSOldPLABMax=" + option.getMax()); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
183 |
break; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
184 |
case "CMSOldPLABMax": |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
185 |
option.addPrepend("-XX:CMSOldPLABMin=" + option.getMin()); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
186 |
break; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
187 |
case "CMSPrecleanNumerator": |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
188 |
option.addPrepend("-XX:CMSPrecleanDenominator=" + option.getMax()); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
189 |
break; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
190 |
case "CMSPrecleanDenominator": |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
191 |
option.addPrepend("-XX:CMSPrecleanNumerator=" + ((new Integer(option.getMin())) - 1)); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
192 |
break; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
193 |
case "InitialTenuringThreshold": |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
194 |
option.addPrepend("-XX:MaxTenuringThreshold=" + option.getMax()); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
195 |
break; |
34661
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
196 |
case "NUMAInterleaveGranularity": |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
197 |
option.addPrepend("-XX:+UseNUMAInterleaving"); |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
198 |
break; |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
199 |
case "CPUForCMSThread": |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
200 |
option.addPrepend("-XX:+BindCMSThreadToCPU"); |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
201 |
break; |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
202 |
case "VerifyGCStartAt": |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
203 |
option.addPrepend("-XX:+VerifyBeforeGC"); |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
204 |
option.addPrepend("-XX:+VerifyAfterGC"); |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
205 |
break; |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
206 |
case "NewSizeThreadIncrease": |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
207 |
option.addPrepend("-XX:+UseSerialGC"); |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
208 |
break; |
35074
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
209 |
case "SharedReadWriteSize": |
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
210 |
case "SharedReadOnlySize": |
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
211 |
case "SharedMiscDataSize": |
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
212 |
case "SharedMiscCodeSize": |
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
213 |
case "SharedBaseAddress": |
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
214 |
case "SharedSymbolTableBucketSize": |
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
215 |
option.addPrepend("-XX:+UnlockDiagnosticVMOptions"); |
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
216 |
option.addPrepend("-XX:SharedArchiveFile=TestOptionsWithRanges.jsa"); |
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
217 |
option.addPrepend("-Xshare:dump"); |
4ac430acedd7
8142874: [TESTBUG] OptionsValidation testing framework needs to handle VM error codes in some cases
ddmitriev
parents:
34661
diff
changeset
|
218 |
break; |
31372
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
219 |
default: |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
220 |
/* Do nothing */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
221 |
break; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
222 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
223 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
224 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
225 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
226 |
* Parse JVM Options. Get input from "inputReader". Parse using |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
227 |
* "-XX:+PrintFlagsRanges" output format. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
228 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
229 |
* @param inputReader input data for parsing |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
230 |
* @param withRanges true if needed options with defined ranges inside JVM |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
231 |
* @param acceptOrigin predicate for option origins. Origins can be |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
232 |
* "product", "diagnostic" etc. Accept option only if acceptOrigin evaluates |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
233 |
* to true. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
234 |
* @return map from option name to the JVMOption object |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
235 |
* @throws IOException if an error occurred while reading the data |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
236 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
237 |
private static Map<String, JVMOption> getJVMOptions(Reader inputReader, |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
238 |
boolean withRanges, Predicate<String> acceptOrigin) throws IOException { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
239 |
BufferedReader reader = new BufferedReader(inputReader); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
240 |
String type; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
241 |
String line; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
242 |
String token; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
243 |
String name; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
244 |
StringTokenizer st; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
245 |
JVMOption option; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
246 |
Map<String, JVMOption> allOptions = new LinkedHashMap<>(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
247 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
248 |
// Skip first line |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
249 |
line = reader.readLine(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
250 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
251 |
while ((line = reader.readLine()) != null) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
252 |
/* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
253 |
* Parse option from following line: |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
254 |
* <type> <name> [ <min, optional> ... <max, optional> ] {<origin>} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
255 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
256 |
st = new StringTokenizer(line); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
257 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
258 |
type = st.nextToken(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
259 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
260 |
name = st.nextToken(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
261 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
262 |
option = JVMOption.createVMOption(type, name); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
263 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
264 |
/* Skip '[' */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
265 |
token = st.nextToken(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
266 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
267 |
/* Read min range or "..." if range is absent */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
268 |
token = st.nextToken(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
269 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
270 |
if (token.equals("...") == false) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
271 |
if (!withRanges) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
272 |
/* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
273 |
* Option have range, but asked for options without |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
274 |
* ranges => skip it |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
275 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
276 |
continue; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
277 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
278 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
279 |
/* Mark this option as option which range is defined in VM */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
280 |
option.optionWithRange(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
281 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
282 |
option.setMin(token); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
283 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
284 |
/* Read "..." and skip it */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
285 |
token = st.nextToken(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
286 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
287 |
/* Get max value */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
288 |
token = st.nextToken(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
289 |
option.setMax(token); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
290 |
} else if (withRanges) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
291 |
/* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
292 |
* Option not have range, but asked for options with |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
293 |
* ranges => skip it |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
294 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
295 |
continue; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
296 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
297 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
298 |
/* Skip ']' */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
299 |
token = st.nextToken(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
300 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
301 |
/* Read origin of the option */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
302 |
token = st.nextToken(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
303 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
304 |
while (st.hasMoreTokens()) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
305 |
token += st.nextToken(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
306 |
}; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
307 |
token = token.substring(1, token.indexOf("}")); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
308 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
309 |
if (acceptOrigin.test(token)) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
310 |
addNameDependency(option); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
311 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
312 |
allOptions.put(name, option); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
313 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
314 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
315 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
316 |
return allOptions; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
317 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
318 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
319 |
static void failedMessage(String optionName, String value, boolean valid, String message) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
320 |
String temp; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
321 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
322 |
if (valid) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
323 |
temp = "valid"; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
324 |
} else { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
325 |
temp = "invalid"; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
326 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
327 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
328 |
failedMessage(String.format("Error processing option %s with %s value '%s'! %s", |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
329 |
optionName, temp, value, message)); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
330 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
331 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
332 |
static void failedMessage(String message) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
333 |
System.err.println("TEST FAILED: " + message); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
334 |
finalFailedMessage.append(String.format("(%s)%n", message)); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
335 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
336 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
337 |
static void printOutputContent(OutputAnalyzer output) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
338 |
System.err.println(String.format("stdout content[%s]", output.getStdout())); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
339 |
System.err.println(String.format("stderr content[%s]%n", output.getStderr())); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
340 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
341 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
342 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
343 |
* Return string with accumulated failure messages |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
344 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
345 |
* @return string with accumulated failure messages |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
346 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
347 |
public static String getMessageWithFailures() { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
348 |
return finalFailedMessage.toString(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
349 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
350 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
351 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
352 |
* Run command line tests for options passed in the list |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
353 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
354 |
* @param options list of options to test |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
355 |
* @return number of failed tests |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
356 |
* @throws Exception if java process can not be started |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
357 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
358 |
public static int runCommandLineTests(List<? extends JVMOption> options) throws Exception { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
359 |
int failed = 0; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
360 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
361 |
for (JVMOption option : options) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
362 |
failed += option.testCommandLine(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
363 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
364 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
365 |
return failed; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
366 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
367 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
368 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
369 |
* Test passed options using DynamicVMOption isValidValue and isInvalidValue |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
370 |
* methods. Only tests writeable options. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
371 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
372 |
* @param options list of options to test |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
373 |
* @return number of failed tests |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
374 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
375 |
public static int runDynamicTests(List<? extends JVMOption> options) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
376 |
int failed = 0; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
377 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
378 |
for (JVMOption option : options) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
379 |
failed += option.testDynamic(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
380 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
381 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
382 |
return failed; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
383 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
384 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
385 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
386 |
* Test passed options using Jcmd. Only tests writeable options. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
387 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
388 |
* @param options list of options to test |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
389 |
* @return number of failed tests |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
390 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
391 |
public static int runJcmdTests(List<? extends JVMOption> options) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
392 |
int failed = 0; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
393 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
394 |
for (JVMOption option : options) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
395 |
failed += option.testJcmd(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
396 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
397 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
398 |
return failed; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
399 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
400 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
401 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
402 |
* Test passed option using attach method. Only tests writeable options. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
403 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
404 |
* @param options list of options to test |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
405 |
* @return number of failed tests |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
406 |
* @throws Exception if an error occurred while attaching to the target JVM |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
407 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
408 |
public static int runAttachTests(List<? extends JVMOption> options) throws Exception { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
409 |
int failed = 0; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
410 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
411 |
for (JVMOption option : options) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
412 |
failed += option.testAttach(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
413 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
414 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
415 |
return failed; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
416 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
417 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
418 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
419 |
* Get JVM options as map. Can return options with defined ranges or options |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
420 |
* without range depending on "withRanges" argument. "acceptOrigin" |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
421 |
* predicate can be used to filter option origin. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
422 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
423 |
* @param withRanges true if needed options with defined ranges inside JVM |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
424 |
* @param acceptOrigin predicate for option origins. Origins can be |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
425 |
* "product", "diagnostic" etc. Accept option only if acceptOrigin evaluates |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
426 |
* to true. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
427 |
* @param additionalArgs additional arguments to the Java process which ran |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
428 |
* with "-XX:+PrintFlagsRanges" |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
429 |
* @return map from option name to the JVMOption object |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
430 |
* @throws Exception if a new process can not be created or an error |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
431 |
* occurred while reading the data |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
432 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
433 |
public static Map<String, JVMOption> getOptionsAsMap(boolean withRanges, Predicate<String> acceptOrigin, |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
434 |
String... additionalArgs) throws Exception { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
435 |
Map<String, JVMOption> result; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
436 |
Process p; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
437 |
List<String> runJava = new ArrayList<>(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
438 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
439 |
if (additionalArgs.length > 0) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
440 |
runJava.addAll(Arrays.asList(additionalArgs)); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
441 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
442 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
443 |
if (VMType != null) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
444 |
runJava.add(VMType); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
445 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
446 |
runJava.add(PRINT_FLAGS_RANGES); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
447 |
runJava.add("-version"); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
448 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
449 |
p = ProcessTools.createJavaProcessBuilder(runJava.toArray(new String[0])).start(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
450 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
451 |
result = getJVMOptions(new InputStreamReader(p.getInputStream()), withRanges, acceptOrigin); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
452 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
453 |
p.waitFor(); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
454 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
455 |
return result; |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
456 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
457 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
458 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
459 |
* Get JVM options as list. Can return options with defined ranges or |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
460 |
* options without range depending on "withRanges" argument. "acceptOrigin" |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
461 |
* predicate can be used to filter option origin. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
462 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
463 |
* @param withRanges true if needed options with defined ranges inside JVM |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
464 |
* @param acceptOrigin predicate for option origins. Origins can be |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
465 |
* "product", "diagnostic" etc. Accept option only if acceptOrigin evaluates |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
466 |
* to true. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
467 |
* @param additionalArgs additional arguments to the Java process which ran |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
468 |
* with "-XX:+PrintFlagsRanges" |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
469 |
* @return List of options |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
470 |
* @throws Exception if a new process can not be created or an error |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
471 |
* occurred while reading the data |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
472 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
473 |
public static List<JVMOption> getOptions(boolean withRanges, Predicate<String> acceptOrigin, |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
474 |
String... additionalArgs) throws Exception { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
475 |
return new ArrayList<>(getOptionsAsMap(withRanges, acceptOrigin, additionalArgs).values()); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
476 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
477 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
478 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
479 |
* Get JVM options with ranges as list. "acceptOrigin" predicate can be used |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
480 |
* to filter option origin. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
481 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
482 |
* @param acceptOrigin predicate for option origins. Origins can be |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
483 |
* "product", "diagnostic" etc. Accept option only if acceptOrigin evaluates |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
484 |
* to true. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
485 |
* @param additionalArgs additional arguments to the Java process which ran |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
486 |
* with "-XX:+PrintFlagsRanges" |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
487 |
* @return List of options |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
488 |
* @throws Exception if a new process can not be created or an error |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
489 |
* occurred while reading the data |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
490 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
491 |
public static List<JVMOption> getOptionsWithRange(Predicate<String> acceptOrigin, String... additionalArgs) throws Exception { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
492 |
return getOptions(true, acceptOrigin, additionalArgs); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
493 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
494 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
495 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
496 |
* Get JVM options with ranges as list. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
497 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
498 |
* @param additionalArgs additional arguments to the Java process which ran |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
499 |
* with "-XX:+PrintFlagsRanges" |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
500 |
* @return list of options |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
501 |
* @throws Exception if a new process can not be created or an error |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
502 |
* occurred while reading the data |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
503 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
504 |
public static List<JVMOption> getOptionsWithRange(String... additionalArgs) throws Exception { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
505 |
return getOptionsWithRange(origin -> true, additionalArgs); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
506 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
507 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
508 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
509 |
* Get JVM options with range as map. "acceptOrigin" predicate can be used |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
510 |
* to filter option origin. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
511 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
512 |
* @param acceptOrigin predicate for option origins. Origins can be |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
513 |
* "product", "diagnostic" etc. Accept option only if acceptOrigin evaluates |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
514 |
* to true. |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
515 |
* @param additionalArgs additional arguments to the Java process which ran |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
516 |
* with "-XX:+PrintFlagsRanges" |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
517 |
* @return Map from option name to the JVMOption object |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
518 |
* @throws Exception if a new process can not be created or an error |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
519 |
* occurred while reading the data |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
520 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
521 |
public static Map<String, JVMOption> getOptionsWithRangeAsMap(Predicate<String> acceptOrigin, String... additionalArgs) throws Exception { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
522 |
return getOptionsAsMap(true, acceptOrigin, additionalArgs); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
523 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
524 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
525 |
/** |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
526 |
* Get JVM options with range as map |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
527 |
* |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
528 |
* @param additionalArgs additional arguments to the Java process which ran |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
529 |
* with "-XX:+PrintFlagsRanges" |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
530 |
* @return map from option name to the JVMOption object |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
531 |
* @throws Exception if a new process can not be created or an error |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
532 |
* occurred while reading the data |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
533 |
*/ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
534 |
public static Map<String, JVMOption> getOptionsWithRangeAsMap(String... additionalArgs) throws Exception { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
535 |
return getOptionsWithRangeAsMap(origin -> true, additionalArgs); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
536 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
537 |
|
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
538 |
/* Simple method to test that java start-up. Used for testing options. */ |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
539 |
public static void main(String[] args) { |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
540 |
System.out.print("Java start-up!"); |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
541 |
} |
9821df46cf47
8072931: JEP-JDK-8059557: Test task: test framework development
ddmitriev
parents:
diff
changeset
|
542 |
} |