10
|
1 |
#!/bin/sh
|
|
2 |
|
|
3 |
#
|
5520
|
4 |
# Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
|
10
|
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 |
#
|
5520
|
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.
|
10
|
24 |
#
|
|
25 |
|
|
26 |
|
|
27 |
# @test
|
|
28 |
# @bug 4241229 4785453
|
|
29 |
# @summary Test -classpath option and classpath defaults.
|
|
30 |
# @author maddox
|
|
31 |
#
|
|
32 |
# @run shell/timeout=180 ClassPathTest.sh
|
|
33 |
|
|
34 |
# TODO: Should test sourcepath and classpath separately.
|
|
35 |
|
|
36 |
if [ "${TESTSRC}" = "" ]
|
|
37 |
then
|
|
38 |
echo "TESTSRC not set. Test cannot execute. Failed."
|
|
39 |
exit 1
|
|
40 |
fi
|
|
41 |
echo "TESTSRC=${TESTSRC}"
|
|
42 |
if [ "${TESTJAVA}" = "" ]
|
|
43 |
then
|
|
44 |
echo "TESTJAVA not set. Test cannot execute. Failed."
|
|
45 |
exit 1
|
|
46 |
fi
|
|
47 |
echo "TESTJAVA=${TESTJAVA}"
|
|
48 |
if [ "${TESTCLASSES}" = "" ]
|
|
49 |
then
|
|
50 |
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
|
51 |
exit 1
|
|
52 |
fi
|
|
53 |
echo "TESTCLASSES=${TESTCLASSES}"
|
|
54 |
echo "CLASSPATH=${CLASSPATH}"
|
|
55 |
|
|
56 |
# set platform-dependent variables
|
|
57 |
OS=`uname -s`
|
|
58 |
case "$OS" in
|
3772
|
59 |
SunOS | Linux | CYGWIN* )
|
10
|
60 |
FS="/"
|
|
61 |
;;
|
|
62 |
Windows* )
|
|
63 |
FS="\\"
|
|
64 |
;;
|
|
65 |
* )
|
|
66 |
echo "Unrecognized system!"
|
|
67 |
exit 1;
|
|
68 |
;;
|
|
69 |
esac
|
|
70 |
|
|
71 |
javac="${TESTJAVA}${FS}bin${FS}javac"
|
|
72 |
|
|
73 |
cleanup() {
|
|
74 |
rm -f *.class pkg${FS}*.class foo${FS}pkg${FS}*.class bar${FS}pkg${FS}*.class
|
|
75 |
cp -rf $TESTSRC${FS}* .
|
|
76 |
}
|
|
77 |
|
|
78 |
fail() {
|
|
79 |
echo "FAIL: $1"
|
|
80 |
failed="yes"
|
|
81 |
}
|
|
82 |
|
|
83 |
# report expectedResult $?
|
|
84 |
report() {
|
|
85 |
if test "$1" = "success" -a "$2" = 0; then
|
|
86 |
echo "PASS: succeeded as expected"
|
|
87 |
elif test "$1" = "failure" -a "$2" != 0; then
|
|
88 |
echo "PASS: failed as expected"
|
|
89 |
elif test "$1" = "success" -a "$2" != 0; then
|
|
90 |
fail "test failed unexpectedly"
|
|
91 |
elif test "$1" = "failure" -a "$2" = 0; then
|
|
92 |
fail "test succeeded unexpectedly"
|
|
93 |
else
|
|
94 |
fail "internal error"
|
|
95 |
fi
|
|
96 |
}
|
|
97 |
|
|
98 |
# testJavac expectedResult javacArgs...
|
|
99 |
testJavac() {
|
|
100 |
expectedResult="$1"; shift
|
|
101 |
cleanup
|
|
102 |
echo $javac ${TESTTOOLVMOPTS} "$@"
|
|
103 |
$javac ${TESTTOOLVMOPTS} "$@"
|
|
104 |
report $expectedResult $?
|
|
105 |
}
|
|
106 |
|
|
107 |
unset CLASSPATH
|
|
108 |
|
|
109 |
# classpath should default to current directory
|
|
110 |
|
|
111 |
testJavac success ClassPathTest3.java
|
|
112 |
testJavac failure ClassPathTest1.java
|
|
113 |
|
|
114 |
# if CLASSPATH is set, it should be honored
|
|
115 |
|
|
116 |
CLASSPATH=bar; export CLASSPATH
|
|
117 |
|
|
118 |
testJavac success ClassPathTest2.java
|
|
119 |
testJavac failure ClassPathTest1.java
|
|
120 |
testJavac failure ClassPathTest3.java
|
|
121 |
|
|
122 |
# -classpath option should override default
|
|
123 |
|
|
124 |
testJavac success -classpath foo ClassPathTest1.java
|
|
125 |
testJavac failure -classpath foo ClassPathTest2.java
|
|
126 |
testJavac failure -classpath foo ClassPathTest3.java
|
|
127 |
|
|
128 |
if test -n "$failed"; then
|
|
129 |
echo "Some tests failed"
|
|
130 |
exit 1
|
|
131 |
else
|
|
132 |
echo PASS: all tests gave expected results
|
|
133 |
exit 0
|
|
134 |
fi
|