author | katleman |
Thu, 05 Jan 2012 08:42:37 -0800 | |
changeset 11376 | 075fe3928b7f |
parent 9018 | 29184ade5361 |
child 12047 | 320a714614e9 |
permissions | -rw-r--r-- |
2 | 1 |
#!/bin/ksh -p |
2 |
||
3 |
# |
|
9018
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
4 |
# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
# |
|
5506 | 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. |
|
2 | 24 |
# |
25 |
||
26 |
# |
|
27 |
# @test PrivateTransportTest.sh |
|
28 |
# @bug 6225664 6220618 |
|
29 |
# @summary Test for when private transport library outside jdk |
|
30 |
# @author Kelly O'Hair |
|
31 |
# |
|
32 |
# @run compile -g HelloWorld.java |
|
33 |
# @run shell PrivateTransportTest.sh |
|
34 |
# |
|
35 |
||
36 |
# Beginning of subroutines: |
|
37 |
status=1 |
|
38 |
||
39 |
#Call this from anywhere to fail the test with an error message |
|
40 |
# usage: fail "reason why the test failed" |
|
41 |
fail() |
|
42 |
{ echo "The test failed :-(" |
|
43 |
echo "$*" 1>&2 |
|
44 |
echo "exit status was $status" |
|
45 |
exit $status |
|
46 |
} #end of fail() |
|
47 |
||
48 |
#Call this from anywhere to pass the test with a message |
|
49 |
# usage: pass "reason why the test passed if applicable" |
|
50 |
pass() |
|
51 |
{ echo "The test passed!!!" |
|
52 |
echo "$*" 1>&2 |
|
53 |
exit 0 |
|
54 |
} #end of pass() |
|
55 |
||
56 |
# end of subroutines |
|
57 |
||
58 |
# The beginning of the script proper |
|
59 |
||
60 |
TARGETCLASS="HelloWorld" |
|
61 |
if [ -z "${TESTJAVA}" ] ; then |
|
62 |
# TESTJAVA is not set, so the test is running stand-alone. |
|
63 |
# TESTJAVA holds the path to the root directory of the build of the JDK |
|
64 |
# to be tested. That is, any java files run explicitly in this shell |
|
65 |
# should use TESTJAVA in the path to the java interpreter. |
|
66 |
# So, we'll set this to the JDK spec'd on the command line. If none |
|
67 |
# is given on the command line, tell the user that and use a default. |
|
68 |
# THIS IS THE JDK BEING TESTED. |
|
69 |
if [ -n "$1" ] ; then |
|
70 |
TESTJAVA=$1 |
|
71 |
else |
|
72 |
TESTJAVA=$JAVA_HOME |
|
73 |
fi |
|
74 |
TESTSRC=. |
|
75 |
TESTCLASSES=. |
|
76 |
#Deal with .class files: |
|
77 |
${TESTJAVA}/bin/javac -d ${TESTCLASSES} \ |
|
78 |
-classpath "${TESTCLASSES}" -g \ |
|
79 |
${TARGETCLASS}.java |
|
80 |
fi |
|
81 |
# |
|
82 |
echo "JDK under test is: $TESTJAVA" |
|
83 |
||
84 |
# Get flags being sent to debuggee |
|
85 |
DEBUGGEEFLAGS= |
|
86 |
if [ -r $TESTCLASSES/@debuggeeVMOptions ] ; then |
|
87 |
DEBUGGEEFLAGS=`cat $TESTCLASSES/@debuggeeVMOptions` |
|
88 |
elif [ -r $TESTCLASSES/../@debuggeeVMOptions ] ; then |
|
89 |
DEBUGGEEFLAGS=`cat $TESTCLASSES/../@debuggeeVMOptions` |
|
90 |
fi |
|
91 |
||
92 |
# Figure out what the libarch path is |
|
93 |
os=`uname -s` |
|
94 |
||
95 |
jreloc=${TESTJAVA}/jre |
|
96 |
if [ ! -d ${jreloc} ] ; then |
|
97 |
jreloc=${TESTJAVA} |
|
98 |
fi |
|
99 |
||
100 |
libdir=${TESTCLASSES} |
|
101 |
||
9018
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
102 |
is_windows=false |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
103 |
is_cygwin=false |
2 | 104 |
case `uname -s` in |
105 |
SunOS) |
|
106 |
libarch=`uname -p` |
|
107 |
d64=`echo "${DEBUGGEEFLAGS}" | fgrep -- -d64` |
|
108 |
case `uname -p` in |
|
109 |
sparc) |
|
110 |
if [ "${d64}" != "" ] ; then |
|
111 |
libarch=sparcv9 |
|
112 |
fi |
|
113 |
;; |
|
114 |
i386) |
|
115 |
if [ "${d64}" != "" ] ; then |
|
116 |
libarch=amd64 |
|
117 |
fi |
|
118 |
;; |
|
119 |
*) |
|
120 |
echo "FAILURE: Unknown uname -p: " `uname -p` |
|
121 |
exit 1 |
|
122 |
;; |
|
123 |
esac |
|
124 |
libloc=${jreloc}/lib/${libarch} |
|
125 |
;; |
|
126 |
Linux) |
|
127 |
xx=`find ${jreloc}/lib -name libdt_socket.so` |
|
128 |
libloc=`dirname ${xx}` |
|
129 |
;; |
|
130 |
Windows*) |
|
9018
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
131 |
is_windows=true |
2 | 132 |
libloc=${jreloc}/bin |
133 |
sep=';' |
|
134 |
;; |
|
135 |
CYGWIN*) |
|
9018
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
136 |
is_windows=true |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
137 |
is_cygwin=true |
2 | 138 |
libloc=${jreloc}/bin |
139 |
sep=':' |
|
140 |
||
141 |
# This is going onto PATH and cygwin needs the form |
|
142 |
# /cygdrive/j/x..... for that. |
|
143 |
libdir=`cygpath -u "$TESTCLASSES"` |
|
144 |
;; |
|
145 |
*) |
|
146 |
echo "FAILURE: Unknown uname -s: " `uname -s` |
|
147 |
exit 1 |
|
148 |
;; |
|
149 |
esac |
|
150 |
||
151 |
# Create private transport library |
|
152 |
echo "Setup private transport library by copying an existing one and renaming" |
|
153 |
private_transport=private_dt_socket |
|
154 |
if [ -f ${libloc}/dt_socket.dll ] ; then |
|
155 |
fullpath=${libdir}/${private_transport}.dll |
|
156 |
rm -f ${fullpath} |
|
157 |
echo cp ${libloc}/dt_socket.dll ${fullpath} |
|
158 |
cp ${libloc}/dt_socket.dll ${fullpath} |
|
159 |
# make sure we can find libraries in current directory |
|
160 |
PATH="${PATH}${sep}${libdir}" |
|
161 |
export PATH |
|
162 |
echo PATH=${PATH} |
|
163 |
elif [ -f ${libloc}/libdt_socket.so ] ; then |
|
164 |
fullpath=${libdir}/lib${private_transport}.so |
|
165 |
rm -f ${fullpath} |
|
166 |
echo cp ${libloc}/libdt_socket.so ${fullpath} |
|
167 |
cp ${libloc}/libdt_socket.so ${fullpath} |
|
168 |
# make sure we can find libraries in current directory |
|
169 |
if [ "${LD_LIBRARY_PATH}" = "" ] ; then |
|
170 |
LD_LIBRARY_PATH=${libdir} |
|
171 |
else |
|
172 |
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${libdir} |
|
173 |
fi |
|
174 |
export LD_LIBRARY_PATH |
|
175 |
echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH} |
|
176 |
else |
|
177 |
echo "cannot find dt_socket in ${libloc} for ${private_transport}" |
|
178 |
fail "cannot find dt_socket in ${libloc} for ${private_transport}" |
|
179 |
fi |
|
180 |
||
181 |
# |
|
182 |
CP="-classpath \"${TESTCLASSES}\"" |
|
183 |
# |
|
9018
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
184 |
if [ "$is_windows" = "true" ]; then |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
185 |
if [ "$is_cygwin" = "true" ]; then |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
186 |
win_fullpath=`cygpath -m "$fullpath" \ |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
187 |
| sed -e 's#/#\\\\\\\\#g' -e 's/\.dll//'` |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
188 |
else |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
189 |
win_fullpath=`echo "$fullpath" \ |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
190 |
| sed -e 's#/#\\\\\\\\#g' -e 's/\.dll//'` |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
191 |
fi |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
192 |
DEBUGGEEFLAGS="$DEBUGGEEFLAGS -agentlib:jdwp=transport=${win_fullpath},server=y,suspend=n" |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
193 |
else |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
194 |
DEBUGGEEFLAGS="$DEBUGGEEFLAGS -agentlib:jdwp=transport=${private_transport},server=y,suspend=n" |
29184ade5361
7030400: 3/4 PrivateTransportTest.sh needs adjustment to work with 7003964
dcubed
parents:
5506
diff
changeset
|
195 |
fi |
2 | 196 |
|
197 |
echo ${TESTJAVA}/bin/java ${DEBUGGEEFLAGS} ${CP} ${TARGETCLASS} |
|
198 |
eval ${TESTJAVA}/bin/java ${DEBUGGEEFLAGS} ${CP} ${TARGETCLASS} |
|
199 |
status=$? |
|
200 |
echo "test status for ${DEBUGGERFLAGS} was: $status" |
|
201 |
if [ $status -ne 0 ] ; then |
|
202 |
fail "unspecified test failure" |
|
203 |
exit 1 |
|
204 |
fi |
|
205 |
||
206 |
pass "found private transport library" |
|
207 |
exit 0 |
|
208 |