author | ksrini |
Sat, 28 Jan 2012 10:46:46 -0800 | |
changeset 11687 | f13cadbb0bb5 |
parent 11363 | 09b0c9731145 |
child 11998 | 7ef4a256eb26 |
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 |
||
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
58 |
static void checkNoContains(TestResult tr, String str) { |
7297 | 59 |
if (tr.contains(str)) { |
60 |
System.out.println(tr.status); |
|
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 { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
76 |
TestResult tr = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
77 |
tr = doExec(javaCmd, "-Xms64m", "-Xmx512m", |
7810 | 78 |
"-Xss128k", "-XshowSettings", "-jar", testJar.getAbsolutePath()); |
79 |
containsAllOptions(tr); |
|
80 |
if (!tr.isOK()) { |
|
81 |
System.out.println(tr.status); |
|
82 |
throw new RuntimeException("test fails"); |
|
83 |
} |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
84 |
tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m", |
7810 | 85 |
"-Xss122880", "-XshowSettings", "-jar", testJar.getAbsolutePath()); |
7297 | 86 |
containsAllOptions(tr); |
87 |
if (!tr.isOK()) { |
|
88 |
System.out.println(tr.status); |
|
89 |
throw new RuntimeException("test fails"); |
|
90 |
} |
|
91 |
} |
|
92 |
||
93 |
static void runTestOptionAll() throws IOException { |
|
94 |
init(); |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
95 |
TestResult tr = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
96 |
tr = doExec(javaCmd, "-XshowSettings:all"); |
7297 | 97 |
containsAllOptions(tr); |
98 |
} |
|
99 |
||
100 |
static void runTestOptionVM() throws IOException { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
101 |
TestResult tr = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
102 |
tr = doExec(javaCmd, "-XshowSettings:vm"); |
7297 | 103 |
checkContains(tr, VM_SETTINGS); |
104 |
checkNoContains(tr, PROP_SETTINGS); |
|
105 |
checkNoContains(tr, LOCALE_SETTINGS); |
|
106 |
} |
|
107 |
||
108 |
static void runTestOptionProperty() throws IOException { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
109 |
TestResult tr = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
110 |
tr = doExec(javaCmd, "-XshowSettings:properties"); |
7297 | 111 |
checkNoContains(tr, VM_SETTINGS); |
112 |
checkContains(tr, PROP_SETTINGS); |
|
113 |
checkNoContains(tr, LOCALE_SETTINGS); |
|
114 |
} |
|
115 |
||
116 |
static void runTestOptionLocale() throws IOException { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
117 |
TestResult tr = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
118 |
tr = doExec(javaCmd, "-XshowSettings:locale"); |
7297 | 119 |
checkNoContains(tr, VM_SETTINGS); |
120 |
checkNoContains(tr, PROP_SETTINGS); |
|
121 |
checkContains(tr, LOCALE_SETTINGS); |
|
122 |
} |
|
123 |
||
124 |
static void runTestBadOptions() throws IOException { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
125 |
TestResult tr = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
126 |
tr = doExec(javaCmd, "-XshowSettingsBadOption"); |
7297 | 127 |
checkNoContains(tr, VM_SETTINGS); |
128 |
checkNoContains(tr, PROP_SETTINGS); |
|
129 |
checkNoContains(tr, LOCALE_SETTINGS); |
|
130 |
checkContains(tr, "Unrecognized option: -XshowSettingsBadOption"); |
|
131 |
} |
|
11363
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
132 |
|
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
133 |
static void runTest7123582() throws IOException { |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
134 |
TestResult tr = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11363
diff
changeset
|
135 |
tr = doExec(javaCmd, "-XshowSettings", "-version"); |
11363
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
136 |
if (!tr.isOK()) { |
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
137 |
System.out.println(tr.status); |
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
138 |
throw new RuntimeException("test fails"); |
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 |
containsAllOptions(tr); |
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
141 |
} |
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
142 |
|
7297 | 143 |
public static void main(String... args) { |
144 |
try { |
|
145 |
runTestOptionAll(); |
|
146 |
runTestOptionDefault(); |
|
147 |
runTestOptionVM(); |
|
148 |
runTestOptionProperty(); |
|
149 |
runTestOptionLocale(); |
|
150 |
runTestBadOptions(); |
|
11363
09b0c9731145
7123582: (launcher) display the -version and -XshowSettings
ksrini
parents:
7810
diff
changeset
|
151 |
runTest7123582(); |
7297 | 152 |
} catch (IOException ioe) { |
153 |
throw new RuntimeException(ioe); |
|
154 |
} |
|
155 |
} |
|
156 |
} |