author | martin |
Mon, 18 Apr 2016 09:38:38 -0700 | |
changeset 37540 | e92d95400f31 |
parent 35248 | b0665ea22f83 |
child 45944 | 882cea808912 |
child 46844 | 36796fc011d8 |
permissions | -rw-r--r-- |
7297 | 1 |
/* |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
2 |
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
7297 | 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 |
|
11363
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
28 |
* @bug 6994753 7123582 |
7297 | 29 |
* @summary tests -XshowSettings options |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
30 |
* @compile -XDignore.symbol.file Settings.java |
7297 | 31 |
* @run main Settings |
32 |
* @author ksrini |
|
33 |
*/ |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
34 |
public class Settings extends TestHelper { |
7297 | 35 |
private static File testJar = null; |
36 |
||
37 |
static void init() throws IOException { |
|
38 |
if (testJar != null) { |
|
39 |
return; |
|
40 |
} |
|
41 |
testJar = new File("test.jar"); |
|
42 |
StringBuilder tsrc = new StringBuilder(); |
|
43 |
tsrc.append("public static void main(String... args) {\n"); |
|
44 |
tsrc.append(" for (String x : args) {\n"); |
|
45 |
tsrc.append(" System.out.println(x);\n"); |
|
46 |
tsrc.append(" }\n"); |
|
47 |
tsrc.append("}\n"); |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
48 |
createJar(testJar, tsrc.toString()); |
7297 | 49 |
} |
50 |
||
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
51 |
static void checkContains(TestResult tr, String str) { |
7297 | 52 |
if (!tr.contains(str)) { |
53 |
System.out.println(tr); |
|
54 |
throw new RuntimeException(str + " not found"); |
|
55 |
} |
|
56 |
} |
|
57 |
||
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
58 |
static void checkNotContains(TestResult tr, String str) { |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
59 |
if (!tr.notContains(str)) { |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
60 |
System.out.println(tr); |
7297 | 61 |
throw new RuntimeException(str + " found"); |
62 |
} |
|
63 |
} |
|
64 |
||
65 |
private static final String VM_SETTINGS = "VM settings:"; |
|
66 |
private static final String PROP_SETTINGS = "Property settings:"; |
|
67 |
private static final String LOCALE_SETTINGS = "Locale settings:"; |
|
68 |
||
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
69 |
static void containsAllOptions(TestResult tr) { |
7297 | 70 |
checkContains(tr, VM_SETTINGS); |
71 |
checkContains(tr, PROP_SETTINGS); |
|
72 |
checkContains(tr, LOCALE_SETTINGS); |
|
73 |
} |
|
74 |
||
75 |
static void runTestOptionDefault() throws IOException { |
|
22602
0d9a07b0d7e9
8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents:
11998
diff
changeset
|
76 |
String stackSize = "256"; // in kb |
35248
b0665ea22f83
8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling
asmundak
parents:
22602
diff
changeset
|
77 |
if (getArch().equals("ppc64") || getArch().equals("ppc64le")) { |
22602
0d9a07b0d7e9
8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents:
11998
diff
changeset
|
78 |
stackSize = "800"; |
0d9a07b0d7e9
8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents:
11998
diff
changeset
|
79 |
} |
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
80 |
TestResult tr; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
81 |
tr = doExec(javaCmd, "-Xms64m", "-Xmx512m", |
22602
0d9a07b0d7e9
8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents:
11998
diff
changeset
|
82 |
"-Xss" + stackSize + "k", "-XshowSettings", "-jar", testJar.getAbsolutePath()); |
7810 | 83 |
containsAllOptions(tr); |
84 |
if (!tr.isOK()) { |
|
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
85 |
System.out.println(tr); |
7810 | 86 |
throw new RuntimeException("test fails"); |
87 |
} |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
88 |
tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m", |
22602
0d9a07b0d7e9
8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents:
11998
diff
changeset
|
89 |
"-Xss" + stackSize + "000", "-XshowSettings", "-jar", testJar.getAbsolutePath()); |
7297 | 90 |
containsAllOptions(tr); |
91 |
if (!tr.isOK()) { |
|
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
92 |
System.out.println(tr); |
7297 | 93 |
throw new RuntimeException("test fails"); |
94 |
} |
|
95 |
} |
|
96 |
||
97 |
static void runTestOptionAll() throws IOException { |
|
98 |
init(); |
|
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
99 |
TestResult tr = doExec(javaCmd, "-XshowSettings:all"); |
7297 | 100 |
containsAllOptions(tr); |
101 |
} |
|
102 |
||
103 |
static void runTestOptionVM() throws IOException { |
|
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
104 |
TestResult tr = doExec(javaCmd, "-XshowSettings:vm"); |
7297 | 105 |
checkContains(tr, VM_SETTINGS); |
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
106 |
checkNotContains(tr, PROP_SETTINGS); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
107 |
checkNotContains(tr, LOCALE_SETTINGS); |
7297 | 108 |
} |
109 |
||
110 |
static void runTestOptionProperty() throws IOException { |
|
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
111 |
TestResult tr = doExec(javaCmd, "-XshowSettings:properties"); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
112 |
checkNotContains(tr, VM_SETTINGS); |
7297 | 113 |
checkContains(tr, PROP_SETTINGS); |
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
114 |
checkNotContains(tr, LOCALE_SETTINGS); |
7297 | 115 |
} |
116 |
||
117 |
static void runTestOptionLocale() throws IOException { |
|
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
118 |
TestResult tr = doExec(javaCmd, "-XshowSettings:locale"); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
119 |
checkNotContains(tr, VM_SETTINGS); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
120 |
checkNotContains(tr, PROP_SETTINGS); |
7297 | 121 |
checkContains(tr, LOCALE_SETTINGS); |
122 |
} |
|
123 |
||
124 |
static void runTestBadOptions() throws IOException { |
|
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
125 |
TestResult tr = doExec(javaCmd, "-XshowSettingsBadOption"); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
126 |
checkNotContains(tr, VM_SETTINGS); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
127 |
checkNotContains(tr, PROP_SETTINGS); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
128 |
checkNotContains(tr, LOCALE_SETTINGS); |
7297 | 129 |
checkContains(tr, "Unrecognized option: -XshowSettingsBadOption"); |
130 |
} |
|
11363
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
131 |
|
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
132 |
static void runTest7123582() throws IOException { |
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
133 |
TestResult tr = doExec(javaCmd, "-XshowSettings", "-version"); |
11363
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
134 |
if (!tr.isOK()) { |
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
135 |
System.out.println(tr); |
11363
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
136 |
throw new RuntimeException("test fails"); |
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
137 |
} |
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
138 |
containsAllOptions(tr); |
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
139 |
} |
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
140 |
|
37540
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
141 |
public static void main(String... args) throws IOException { |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
142 |
runTestOptionAll(); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
143 |
runTestOptionDefault(); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
144 |
runTestOptionVM(); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
145 |
runTestOptionProperty(); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
146 |
runTestOptionLocale(); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
147 |
runTestBadOptions(); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
148 |
runTest7123582(); |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
149 |
if (testExitValue != 0) { |
e92d95400f31
8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents:
35248
diff
changeset
|
150 |
throw new Error(testExitValue + " tests failed"); |
7297 | 151 |
} |
152 |
} |
|
153 |
} |