Thu, 10 Oct 2013 14:58:04 +0200
8001931: The new build system whitespace cleanup
Reviewed-by: tbell, simonis, erikj
1 #!/bin/sh
3 #
4 # Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 #
7 # This code is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License version 2 only, as
9 # published by the Free Software Foundation.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
26 #
27 # @test
28 # @summary Test classpath wildcards for javac and java -classpath option.
29 # @bug 6268383
30 # @run shell/timeout=600 wcMineField.sh
32 # To run this test manually, simply do ./wcMineField.sh
33 #----------------------------------------------------------------
35 . ${TESTSRC-.}/Util.sh
37 set -u
39 #----------------------------------------------------------------
40 # Note that, on Windows only, the launcher also includes another
41 # kind of command-line wildcard expansion, via setargv.obj
42 # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/progs_11.asp
43 # Therefore, on Windows, -classpath "foo/*" is treated differently
44 # from -classpath ".${PS}foo/*"
45 #----------------------------------------------------------------
47 #----------------------------------------------------------------
48 # Prepare the "Minefield"
49 #----------------------------------------------------------------
50 Cleanup() {
51 Sys rm -rf GooSrc GooJar GooZip GooClass
52 Sys rm -rf SpeSrc SpeJar SpeZip SpeClass
53 Sys rm -rf BadSrc BadJar BadZip BadClass
54 Sys rm -rf JarNClass StarJar MixJar StarDir
55 Sys rm -rf OneDir *.class Main*.java MANIFEST.MF
56 }
58 Cleanup
59 Sys mkdir GooSrc GooJar GooZip GooClass GooJar/SubDir
60 Sys mkdir BadSrc BadJar BadZip BadClass
61 Sys mkdir SpeSrc SpeJar SpeZip SpeClass
62 Sys mkdir JarNClass StarJar MixJar
63 echo 'public class Lib {public static void f(){}}' > Lib.java
64 echo 'public class Lib2 {public static void g(){}}' > Lib2.java
65 echo 'public class Lib3 {public static void h(){}}' > Lib3.java
66 Sys "$javac" ${TESTTOOLVMOPTS} Lib.java Lib2.java Lib3.java
67 Sys cp Lib.class JarNClass/.
68 Sys "$jar" cf GooJar/Lib.jar Lib.class
69 Sys "$jar" cf GooJar/SubDir/Lib2.jar Lib2.class
70 Sys "$jar" cf JarNClass/Lib.jar Lib.class
72 Sys "$jar" cf GooZip/Lib.zip Lib.class
73 Sys mv Lib.class GooClass/.
74 Sys mv Lib2.class GooClass/.
75 Sys mv Lib3.class GooClass/.
76 Sys mv Lib.java GooSrc/.
77 Sys mv Lib2.java GooSrc/.
78 Sys mv Lib3.java GooSrc
79 CheckFiles GooZip/Lib.zip GooJar/Lib.jar GooSrc/Lib.java
80 CheckFiles GooSrc/Lib2.java GooSrc/Lib3.java GooJar/SubDir/Lib2.jar
82 echo 'public class Spe1 {public static void f(){}}' > Spe1.java
83 echo 'public class Spe2 {public static void f(){}}' > Spe2.java
84 echo 'public class Spe3 {public static void f(){}}' > Spe3.java
85 echo 'public class Spe4 {public static void f(){}}' > Spe4.java
86 Sys "$javac" ${TESTTOOLVMOPTS} Spe1.java
87 Sys "$javac" ${TESTTOOLVMOPTS} Spe2.java
88 Sys "$javac" ${TESTTOOLVMOPTS} Spe3.java
89 Sys "$javac" ${TESTTOOLVMOPTS} Spe4.java
91 UnixOnly Sys "$jar" cf "SpeJar/Spe:Colon.jar" Spe1.class
92 UnixOnly Sys "$jar" cf "SpeJar/Spe*wc.jar" Spe4.class
93 UnixOnly CheckFiles "SpeJar/Spe*wc.jar"
95 UnixOnly Sys "$jar" cf "StarJar/*jar.jar" Spe2.class
96 UnixOnly Sys "$jar" cf "StarJar/jar*.jar" Spe3.class
97 UnixOnly Sys "$jar" cf "StarJar/*jar*.jar" Spe4.class
98 UnixOnly CheckFiles "StarJar/*jar.jar" "StarJar/jar*.jar" "StarJar/*jar*.jar"
100 Sys "$jar" cf "SpeJar/Spe,Comma.jar" Spe2.class
101 Sys "$jar" cf "SpeJar/Spe;Semi.jar" Spe3.class
103 Sys "$jar" cf "MixJar/mix.jAr" Spe1.class
104 Sys "$jar" cf "MixJar/mix2.JAR" Spe2.class
105 Sys "$jar" cf "MixJar/mix3.zip" Spe3.class
106 Sys "$jar" cf "MixJar/.hiddenjar.jar" Spe4.class
108 Sys mv Spe*.class SpeClass/.
109 Sys mv Spe*.java SpeSrc/.
110 CheckFiles "SpeJar/Spe,Comma.jar" "SpeJar/Spe;Semi.jar" "SpeSrc/Spe2.java" "SpeSrc/Spe3.java" "SpeSrc/Spe4.java"
111 CheckFiles "MixJar/mix.jAr" "MixJar/mix2.JAR" "MixJar/mix3.zip" "MixJar/.hiddenjar.jar"
113 echo 'public class Main {public static void main(String[] a) {Lib.f();}}' > Main.java
114 echo 'public class Main1 {public static void main(String[] a) {Lib2.g();}}' > Main1.java
115 echo 'public class Main1b {public static void main(String[] a) {Spe1.f();}}' > Main1b.java
116 echo 'public class Main2 {public static void main(String[] a) {Spe2.f();}}' > Main2.java
117 echo 'public class Main3 {public static void main(String[] a) {Spe3.f();}}' > Main3.java
118 echo 'public class Main4 {public static void main(String[] a) {Spe4.f();}}' > Main4.java
119 echo 'public class Main5 {public static void main(String[] a) {Spe2.f(); Lib.f();}}' > Main5.java
120 echo 'public class Main6 {public static void main(String[] a) {Lib3.h();}}' > Main6.java
123 #----------------------------------------------------------------
124 # Verify expected behaviour with directory named "*"
125 #----------------------------------------------------------------
126 starDir() {
127 printf "Running tests with directory named \"*\"\n"
128 Sys rm -rf ./StarDir
129 Sys mkdir -p StarDir/"*"
130 Sys cp -p "GooClass/Lib3.class" "GooClass/Lib.class" ./
131 Sys cp "GooClass/Lib2.class" "StarDir/*/Lib2.class"
132 Sys "$jar" cf "StarDir/Lib3.jar" "Lib3.class"
133 Sys "$jar" cf "StarDir/*/Lib.jar" "Lib.class"
134 Sys rm -f "./Lib.class" "./Lib3.class"
135 CheckFiles "StarDir/*/Lib.jar" "StarDir/*/Lib2.class" "StarDir/Lib3.jar"
136 Sys cp Main6.java ./StarDir/.
137 Sys cp Main.java ./StarDir/"*"/.
138 Sys cp Main1.java ./StarDir/"*"/.
139 CPWC_DIR=`pwd`
140 Sys cd StarDir
141 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "*" Main6.java
142 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "./*" Main6.java
143 Sys rm -f Main6.*
144 Sys cd "*"
145 Success "$javac" ${TESTTOOLVMOPTS} -classpath "*" Main.java
146 Success "$java" ${TESTVMOPTS} -classpath .${PS}"*" Main
147 Success "$javac" ${TESTTOOLVMOPTS} Main1.java
148 Success "$java" ${TESTVMOPTS} -classpath "." Main1
149 Sys cd $CPWC_DIR
151 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "StarDir/*" Main6.java
153 Success "$javac" ${TESTTOOLVMOPTS} -classpath StarDir/\* Main1.java
154 Success "$java" ${TESTVMOPTS} -classpath StarDir/\*:. Main1
156 Success "$javac" ${TESTTOOLVMOPTS} -classpath "StarDir/*" Main1.java
157 Success "$java" ${TESTVMOPTS} -classpath ".${PS}StarDir/*" Main1
159 Failure "$javac" ${TESTTOOLVMOPTS} -classpath StarDir/"\*/*" Main.java
160 Success "$javac" ${TESTTOOLVMOPTS} -classpath StarDir/"*/*" Main.java
162 Success "$java" ${TESTVMOPTS} -classpath .${PS}StarDir/"*/*" Main
163 Failure "$java" ${TESTVMOPTS} -classpath .${PS}StarDir/"\*/*" Main
165 Success "$javac" ${TESTTOOLVMOPTS} -classpath "StarDir/Lib3.jar" Main6.java
166 Success "$java" ${TESTVMOPTS} -classpath ".${PS}StarDir/Lib3.jar" Main6
168 Success "$javac" ${TESTTOOLVMOPTS} -classpath StarDir/"*"/Lib.jar Main.java
169 Success "$java" ${TESTVMOPTS} -classpath .${PS}StarDir/"*"/Lib.jar Main
170 }
171 UnixOnly starDir
173 #----------------------------------------------------------------
174 # Verify the basic jar file works
175 #----------------------------------------------------------------
176 #baseline test to verify it works.
177 Success "$javac" ${TESTTOOLVMOPTS} -cp "GooJar/Lib.jar" Main.java
178 Success "$javac" ${TESTTOOLVMOPTS} -classpath "GooJar/Lib.jar" Main.java
179 Success "$java" ${TESTVMOPTS} -classpath "GooJar/Lib.jar${PS}." Main
180 Success "$java" ${TESTVMOPTS} -cp "GooJar/Lib.jar${PS}." Main
182 #basic test of one jar to be loaded
183 UnixOnly Success "$javac" ${TESTTOOLVMOPTS} -classpath "GooJar/*" Main.java
184 Success "$javac" ${TESTTOOLVMOPTS} -classpath "GooJar/*${PS}." Main.java
185 Success "$java" ${TESTVMOPTS} -classpath "GooJar/*${PS}." Main
186 #in a subdir. First * should not load jars in subdirectories unless specified
187 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "GooJar/*" Main1.java
188 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "GooJar/*${PS}." Main1.java
189 Success "$javac" ${TESTTOOLVMOPTS} -cp "GooJar/SubDir/*" Main1.java
190 Success "$javac" ${TESTTOOLVMOPTS} -classpath "GooJar/SubDir/*" Main1.java
191 #Same with launcher. Should not load jar in subdirectories unless specified
192 Failure "$java" ${TESTVMOPTS} -classpath "GooJar/*${PS}." Main1
193 Success "$java" ${TESTVMOPTS} -classpath "GooJar/SubDir/*${PS}." Main1
194 Success "$java" ${TESTVMOPTS} -cp "GooJar/SubDir/*${PS}." Main1
196 Success env CLASSPATH="GooJar/SubDir/*" "$javac" ${TESTTOOLVMOPTS} Main1.java
197 Success env CLASSPATH="GooJar/SubDir/*${PS}." "$java" ${TESTVMOPTS} Main1
198 #----------------------------------------------------------------
199 # Verify the jar files in 2 directories
200 #----------------------------------------------------------------
201 Success "$javac" ${TESTTOOLVMOPTS} -classpath "GooJar/Lib.jar${PS}SpeJar/Spe,Comma.jar" Main5.java
202 Success "$java" ${TESTVMOPTS} -classpath "GooJar/Lib.jar${PS}SpeJar/Spe,Comma.jar${PS}." Main5
204 Success "$javac" ${TESTTOOLVMOPTS} -classpath "GooJar/*${PS}SpeJar/*" Main5.java
205 Success "$java" ${TESTVMOPTS} -classpath "GooJar/*${PS}SpeJar/*${PS}." Main5
207 #----------------------------------------------------------------
208 # Verify jar file and class file in same directory.
209 #----------------------------------------------------------------
210 Success "$javac" ${TESTTOOLVMOPTS} -classpath "JarNClass/*${PS}" Main.java
211 Success "$java" ${TESTVMOPTS} -classpath "JarNClass/*${PS}." Main
213 #----------------------------------------------------------------
214 # Verify these odd jar files work explicitly on classpath, kind of
215 # a baseline. Last one is also a test with * in a jar name.
216 #----------------------------------------------------------------
217 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "SpeJar/Spe:Colon.jar" Main1.java
219 Success "$javac" ${TESTTOOLVMOPTS} -classpath "SpeJar/Spe,Comma.jar" Main2.java
220 Success "$java" ${TESTVMOPTS} -classpath "SpeJar/Spe,Comma.jar${PS}." Main2
222 UnixOnly Success "$javac" ${TESTTOOLVMOPTS} -classpath "SpeJar/Spe;Semi.jar" Main3.java
223 UnixOnly Success "$java" ${TESTVMOPTS} -classpath "SpeJar/Spe;Semi.jar${PS}." Main3
225 UnixOnly Success "$javac" ${TESTTOOLVMOPTS} -classpath "SpeJar/Spe*wc.jar" Main4.java
226 UnixOnly Success "$java" ${TESTVMOPTS} -classpath "SpeJar/Spe*wc.jar${PS}." Main4
227 #----------------------------------------------------------------
228 # Verify these odd jar files work with classpath wildcard.
229 #----------------------------------------------------------------
231 speJar() {
232 printf "Running tests with jar file names containing special characters\n"
233 # Failure "$javac" ${TESTTOOLVMOPTS} -classpath "SpeJar/*" Main1.java
234 # Success "$java" ${TESTVMOPTS} -classpath "SpeJar/*" Main1
236 Success "$javac" ${TESTTOOLVMOPTS} -classpath "SpeJar/*" Main2.java
237 Success "$java" ${TESTVMOPTS} -classpath "SpeJar/*${PS}." Main2
239 Success "$javac" ${TESTTOOLVMOPTS} -classpath "SpeJar/*" Main3.java
240 Success "$java" ${TESTVMOPTS} -classpath "SpeJar/*${PS}." Main3
242 Success "$javac" ${TESTTOOLVMOPTS} -classpath "SpeJar/*" Main4.java
243 Success "$java" ${TESTVMOPTS} -classpath "SpeJar/*${PS}." Main4
244 }
245 UnixOnly speJar
247 #----------------------------------------------------------------
248 # Verify these jar files with asterisk in jar file name
249 #----------------------------------------------------------------
250 starJar() {
251 printf "Running tests with jar file names containing \"*\"\n"
252 Success "$javac" ${TESTTOOLVMOPTS} -classpath "StarJar/*jar.jar" Main2.java
253 Success "$java" ${TESTVMOPTS} -classpath "StarJar/*jar.jar${PS}." Main2
255 Success "$javac" ${TESTTOOLVMOPTS} -classpath "StarJar/jar*.jar" Main3.java
256 Success "$java" ${TESTVMOPTS} -classpath "StarJar/jar*.jar${PS}." Main3
258 Success "$javac" ${TESTTOOLVMOPTS} -classpath "StarJar/*jar*.jar" Main4.java
259 Success "$java" ${TESTVMOPTS} -classpath "StarJar/*jar*.jar${PS}." Main4
261 Success "$javac" ${TESTTOOLVMOPTS} -classpath "StarJar/*" Main2.java
262 Success "$java" ${TESTVMOPTS} -classpath "StarJar/*${PS}." Main2
264 Success "$javac" ${TESTTOOLVMOPTS} -classpath "StarJar/*" Main3.java
265 Success "$java" ${TESTVMOPTS} -classpath "StarJar/*${PS}." Main3
267 Success "$javac" ${TESTTOOLVMOPTS} -classpath "StarJar/*" Main4.java
268 Success "$java" ${TESTVMOPTS} -classpath "StarJar/*${PS}." Main4
269 }
270 UnixOnly starJar
272 #----------------------------------------------------------------
273 # Verify these jar files with varying extensions
274 #----------------------------------------------------------------
275 # Mixed case extensions should not be loaded.
276 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "MixJar/*" Main1b.java
277 Success "$javac" ${TESTTOOLVMOPTS} -classpath "MixJar/mix.jAr" Main1b.java
278 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "MixJar/*" Main1b
280 #upper case, .JAR, extension should be loaded
281 UnixOnly Success "$javac" ${TESTTOOLVMOPTS} -classpath "MixJar/*" Main2.java
282 Success "$javac" ${TESTTOOLVMOPTS} -classpath ".${PS}MixJar/*" Main2.java
284 Success "$java" ${TESTVMOPTS} -classpath "MixJar/*${PS}." Main2
285 # zip extensions should not be loaded
286 Failure "$javac" ${TESTTOOLVMOPTS} -classpath "MixJar/*" Main3.java
287 Success "$javac" ${TESTTOOLVMOPTS} -classpath "MixJar/mix3.zip" Main3.java
288 Failure "$java" ${TESTVMOPTS} -classpath "MixJar/*${PS}." Main3
289 # unix "hidden" file
290 UnixOnly Success "$javac" ${TESTTOOLVMOPTS} -classpath "MixJar/*" Main4.java
291 UnixOnly Success "$java" ${TESTVMOPTS} -classpath "MixJar/*${PS}." Main4
293 Cleanup
295 Bottom Line
296 #----------------------------------------------------------------