Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/launcher/Settings.java
41144 views
1
/*
2
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
import java.io.File;
24
import java.io.IOException;
25
26
/*
27
* @test
28
* @bug 6994753 7123582
29
* @summary tests -XshowSettings options
30
* @modules jdk.compiler
31
* jdk.zipfs
32
* @compile -XDignore.symbol.file Settings.java
33
* @run main Settings
34
* @author ksrini
35
*/
36
public class Settings extends TestHelper {
37
private static File testJar = null;
38
39
static void init() throws IOException {
40
if (testJar != null) {
41
return;
42
}
43
testJar = new File("test.jar");
44
StringBuilder tsrc = new StringBuilder();
45
tsrc.append("public static void main(String... args) {\n");
46
tsrc.append(" for (String x : args) {\n");
47
tsrc.append(" System.out.println(x);\n");
48
tsrc.append(" }\n");
49
tsrc.append("}\n");
50
createJar(testJar, tsrc.toString());
51
}
52
53
static void checkContains(TestResult tr, String str) {
54
if (!tr.contains(str)) {
55
System.out.println(tr);
56
throw new RuntimeException(str + " not found");
57
}
58
}
59
60
static void checkNotContains(TestResult tr, String str) {
61
if (!tr.notContains(str)) {
62
System.out.println(tr);
63
throw new RuntimeException(str + " found");
64
}
65
}
66
67
private static final String VM_SETTINGS = "VM settings:";
68
private static final String PROP_SETTINGS = "Property settings:";
69
private static final String LOCALE_SETTINGS = "Locale settings:";
70
private static final String SYSTEM_SETTINGS = "Operating System Metrics:";
71
private static final String STACKSIZE_SETTINGS = "Stack Size:";
72
73
static void containsAllOptions(TestResult tr) {
74
checkContains(tr, VM_SETTINGS);
75
checkContains(tr, PROP_SETTINGS);
76
checkContains(tr, LOCALE_SETTINGS);
77
if (System.getProperty("os.name").contains("Linux")) {
78
checkContains(tr, SYSTEM_SETTINGS);
79
}
80
}
81
82
static void runTestOptionDefault() throws IOException {
83
int stackSize = 256; // in kb
84
if (getArch().equals("ppc64") || getArch().equals("ppc64le")) {
85
stackSize = 800;
86
} else if (getArch().equals("aarch64")) {
87
/*
88
* The max value of minimum stack size allowed for aarch64 can be estimated as
89
* such: suppose the vm page size is 64KB and the test runs with a debug build,
90
* the initial _java_thread_min_stack_allowed defined in os_linux_aarch64.cpp is
91
* 72K, stack guard zones could take 192KB, and the shadow zone needs 128KB,
92
* after aligning up all parts to the page size, the final size would be 448KB.
93
* See details in JDK-8163363
94
*/
95
stackSize = 448;
96
}
97
TestResult tr;
98
tr = doExec(javaCmd, "-Xms64m", "-Xmx512m",
99
"-Xss" + stackSize + "k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
100
// Check the stack size logs printed by -XshowSettings to verify -Xss meaningfully.
101
checkContains(tr, STACKSIZE_SETTINGS);
102
containsAllOptions(tr);
103
if (!tr.isOK()) {
104
System.out.println(tr);
105
throw new RuntimeException("test fails");
106
}
107
tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m",
108
"-Xss" + (stackSize * 1024), "-XshowSettings", "-jar", testJar.getAbsolutePath());
109
checkContains(tr, STACKSIZE_SETTINGS);
110
containsAllOptions(tr);
111
if (!tr.isOK()) {
112
System.out.println(tr);
113
throw new RuntimeException("test fails");
114
}
115
}
116
117
static void runTestOptionAll() throws IOException {
118
init();
119
TestResult tr = doExec(javaCmd, "-XshowSettings:all");
120
containsAllOptions(tr);
121
}
122
123
static void runTestOptionVM() throws IOException {
124
TestResult tr = doExec(javaCmd, "-XshowSettings:vm");
125
checkContains(tr, VM_SETTINGS);
126
checkNotContains(tr, PROP_SETTINGS);
127
checkNotContains(tr, LOCALE_SETTINGS);
128
}
129
130
static void runTestOptionProperty() throws IOException {
131
TestResult tr = doExec(javaCmd, "-XshowSettings:properties");
132
checkNotContains(tr, VM_SETTINGS);
133
checkContains(tr, PROP_SETTINGS);
134
checkNotContains(tr, LOCALE_SETTINGS);
135
}
136
137
static void runTestOptionLocale() throws IOException {
138
TestResult tr = doExec(javaCmd, "-XshowSettings:locale");
139
checkNotContains(tr, VM_SETTINGS);
140
checkNotContains(tr, PROP_SETTINGS);
141
checkContains(tr, LOCALE_SETTINGS);
142
}
143
144
static void runTestOptionSystem() throws IOException {
145
TestResult tr = doExec(javaCmd, "-XshowSettings:system");
146
if (System.getProperty("os.name").contains("Linux")) {
147
checkNotContains(tr, VM_SETTINGS);
148
checkNotContains(tr, PROP_SETTINGS);
149
checkNotContains(tr, LOCALE_SETTINGS);
150
checkContains(tr, SYSTEM_SETTINGS);
151
} else {
152
// -XshowSettings prints all available settings when
153
// settings argument is not recognized.
154
containsAllOptions(tr);
155
}
156
}
157
158
static void runTestBadOptions() throws IOException {
159
TestResult tr = doExec(javaCmd, "-XshowSettingsBadOption");
160
checkNotContains(tr, VM_SETTINGS);
161
checkNotContains(tr, PROP_SETTINGS);
162
checkNotContains(tr, LOCALE_SETTINGS);
163
checkContains(tr, "Unrecognized option: -XshowSettingsBadOption");
164
}
165
166
static void runTest7123582() throws IOException {
167
TestResult tr = doExec(javaCmd, "-XshowSettings", "-version");
168
if (!tr.isOK()) {
169
System.out.println(tr);
170
throw new RuntimeException("test fails");
171
}
172
containsAllOptions(tr);
173
}
174
175
public static void main(String... args) throws IOException {
176
runTestOptionAll();
177
runTestOptionDefault();
178
runTestOptionVM();
179
runTestOptionProperty();
180
runTestOptionLocale();
181
runTestOptionSystem();
182
runTestBadOptions();
183
runTest7123582();
184
if (testExitValue != 0) {
185
throw new Error(testExitValue + " tests failed");
186
}
187
}
188
}
189
190