source: trunk/openjdk/jdk/test/tools/launcher/SolarisRunpath.sh

Last change on this file was 278, checked in by dmik, 14 years ago

trunk: Merged in openjdk6 b22 from branches/vendor/oracle.

File size: 5.7 KB
Line 
1# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3#
4# This code is free software; you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 2 only, as
6# published by the Free Software Foundation.
7#
8# This code is distributed in the hope that it will be useful, but WITHOUT
9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11# version 2 for more details (a copy is included in the LICENSE file that
12# accompanied this code).
13#
14# You should have received a copy of the GNU General Public License version
15# 2 along with this work; if not, write to the Free Software Foundation,
16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17#
18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19# or visit www.oracle.com if you need additional information or have any
20# questions.
21
22
23# @test
24# @bug 4731671
25# @build libraryCaller
26# @run shell SolarisRunpath.sh
27# @summary Verify that Solaris LD_LIBRARY_PATH rules are followed
28# @author Joseph D. Darcy
29
30# The launcher has been updated to properly take account of Solaris
31# LD_LIBRARY_PATH rules when constructing the runpath for the Java
32# executable. That is, data model dependent LD_LIBRARY_PATH variables
33# are tested for and override LD_LIBRARY_PATH if present. The current
34# launcher design relies on LD_LIBRARY_PATH settings to ensure the
35# proper jre/jdk libraries are opening during program execution. In
36# the future, this dependence might be removed by having the vm
37# explicitly dlopen the needed files. If that change occurs, this
38# test will be harmless but no long relevant.
39
40# A more robust test for Solaris SPARC would set the different
41# LD_LIBRARY_PATH variables while also varying the -d[32|64] options
42# to make sure the LD_LIBRARY_PATH of the *target* data model were
43# being respected. That is "java -d64" should use the 64-bit
44# LD_LIBRARY_PATH while "java -d32" should use the 32-bit
45# LD_LIBRARY_PATH regardless of the data model of the "java" binary.
46# However, by default builds do not contain both 32 and 64 bit
47# components so such a test would often not be applicable.
48
49
50# If the test is not being run on a Solaris box, SPARC or x86, the
51# test succeeds immediately.
52
53OS=`uname -s`;
54
55case "$OS" in
56 SunOS )
57 PATHSEP=":"
58 ;;
59
60 * )
61 echo "Not a Solaris environment; test vacuously succeeds."
62 exit 0;
63 ;;
64esac
65
66# Verify directory context variables are set
67if [ "${TESTJAVA}" = "" ]
68then
69 echo "TESTJAVA not set. Test cannot execute. Failed."
70 exit 1
71fi
72
73if [ "${TESTSRC}" = "" ]
74then
75 echo "TESTSRC not set. Test cannot execute. Failed."
76 exit 1
77fi
78
79
80if [ "${TESTCLASSES}" = "" ]
81then
82 echo "TESTCLASSES not set. Test cannot execute. Failed."
83 exit 1
84fi
85
86# Construct paths to default Java executables
87JAVAC="$TESTJAVA/bin/javac"
88
89
90# Create our little Java test on the fly
91( printf "public class GetDataModel {"
92 printf " public static void main(String argv[]) {"
93 printf " System.out.println(System.getProperty(\"sun.arch.data.model\", \"none\"));"
94 printf " }"
95 printf "}"
96) > GetDataModel.java
97
98$JAVAC GetDataModel.java
99
100
101# ARCH should be sparc or i386
102ARCH=`uname -p`
103case "$ARCH" in
104 sparc | i386 )
105 ;;
106
107 * )
108 echo "Unrecognized architecture; test fails."
109 exit 1
110esac
111
112# The following construction may not work as desired in a
113# 64-bit build.
114JAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES${PATHSEP}."
115
116# Determine data model
117DM=`$JAVA GetDataModel`
118
119# verify DM is 32 or 64
120case "$DM" in
121 32 )
122 ODM=64;
123 ;;
124
125 64 )
126 ODM=32;
127 ;;
128
129 * )
130 echo "Unknown data model \"$DM\"; test fails."
131 exit 1
132esac
133
134# -------------------- Test 1 --------------------
135
136LD_LIBRARY_PATH=$TESTSRC/lib/$ARCH/lib$DM
137export LD_LIBRARY_PATH
138unset LD_LIBRARY_PATH_32
139unset LD_LIBRARY_PATH_64
140
141# With plain LD_LIBRARY_PATH, result should always be 0
142RESULT=`$JAVA libraryCaller`
143if [ "${RESULT}" != "0" ];
144then
145 echo "Not using LD_LIBRARY_PATH; test fails."
146 exit 1
147fi
148
149# The following two tests sets both data model dependent
150# LD_LIBRARY_PATH variables individually.
151
152# -------------------- Test 2 --------------------
153
154# Set opposite data model variable; should return same result
155# as plain LD_LIBRARY_PATH.
156
157if [ "${DM}" = "32" ]; then
158 LD_LIBRARY_PATH_64=$TESTSRC/lib/$ARCH/lib$DM/lib$DM
159 export LD_LIBRARY_PATH_64
160else
161 LD_LIBRARY_PATH_32=$TESTSRC/lib/$ARCH/lib$DM/lib$DM
162 export LD_LIBRARY_PATH_32
163fi
164
165RESULT=`$JAVA libraryCaller`
166if [ "${RESULT}" != "0" ];
167then
168 echo "Using LD_LIBRARY_PATH_$ODM for $DM binary;"
169 echo "test fails."
170 exit 1
171fi
172
173unset LD_LIBRARY_PATH_32
174unset LD_LIBRARY_PATH_64
175
176# -------------------- Test 3 --------------------
177
178# Set appropriate data model variable; result should match
179# data model.
180if [ "${DM}" = "32" ]; then
181 LD_LIBRARY_PATH_32=$TESTSRC/lib/$ARCH/lib$DM/lib$DM
182 export LD_LIBRARY_PATH_32
183else
184 LD_LIBRARY_PATH_64=$TESTSRC/lib/$ARCH/lib$DM/lib$DM
185 export LD_LIBRARY_PATH_64
186fi
187
188RESULT=`$JAVA libraryCaller`
189if [ "${RESULT}" != "$DM" ];
190then
191 echo "Data model dependent LD_LIBRARY_PATH_$DM"
192 echo "not overriding LD_LIBRARY_PATH; test fails."
193 exit 1
194fi
195
196unset LD_LIBRARY_PATH
197unset LD_LIBRARY_PATH_32
198unset LD_LIBRARY_PATH_64
199
200# -------------------- Test 4 --------------------
201
202# Have only data model dependent LD_LIBRARY_PATH set; result
203# should match data model.
204
205if [ "${DM}" = "32" ]; then
206 LD_LIBRARY_PATH_32=$TESTSRC/lib/$ARCH/lib$DM/lib$DM
207 export LD_LIBRARY_PATH_32
208else
209 LD_LIBRARY_PATH_64=$TESTSRC/lib/$ARCH/lib$DM/lib$DM
210 export LD_LIBRARY_PATH_64
211fi
212
213RESULT=`$JAVA libraryCaller`
214if [ "${RESULT}" != "$DM" ];
215then
216 echo "Not using data-model dependent LD_LIBRARY_PATH; test fails."
217 exit 1
218fi
219
220# All tests have passed
221exit 0
Note: See TracBrowser for help on using the repository browser.