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