SolarisDataModel.sh 4.8 KB
Newer Older
D
duke 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
# Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.

# @test
# @bug 4780570
# @run shell SolarisDataModel.sh
# @summary Verify Solaris SPARC -d32 and -d64 options work with preset LD_LIBRARY_PATH
# @author Joseph D. Darcy

# Test to see if presetting LD_LIBRARY_PATH affects the treatment of
# -d32 and -d64 options; also checks that -d<n> options result in the
# desired data model.

# If the test is not being run on a Solaris SPARC box SPARC the test
# succeeds immediately.

OS=`uname -s`;

case "$OS" in
	SunOS )
		# ARCH should be sparc or i386
		ARCH=`uname -p`
		case "$ARCH" in 
			sparc)
			PATHSEP=":"
			;;

			* )
			echo "Non-SPARC Solaris environment; test vacuously succeeds."
			exit 0
		esac
	;;

	* )
	echo "Not a Solaris SPARC environment; test vacuously succeeds."
	exit 0;
	;;
esac


# Verify directory context variables are set
if [ "${TESTJAVA}" = "" ]
then
  echo "TESTJAVA not set.  Test cannot execute.  Failed."
  exit 1
fi

if [ "${TESTSRC}" = "" ]
then
  echo "TESTSRC not set.  Test cannot execute.  Failed."
  exit 1
fi


if [ "${TESTCLASSES}" = "" ]
then
  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
  exit 1
fi


JAVAC="$TESTJAVA/bin/javac"

# Create our little Java tests on the fly
( printf "public class GetDataModel {"
  printf "   public static void main(String argv[]) {"
  printf "      System.out.println(System.getProperty(\"sun.arch.data.model\", \"none\"));"
  printf "   }"
  printf "}"
) > GetDataModel.java

$JAVAC  GetDataModel.java

( printf "public class GetLdLibraryPath {"
  printf "   public static void main(String argv[]) {"
  printf "      System.out.println(System.getProperty(\"java.library.path\"));"
  printf "   }"
  printf "}"
) > GetLdLibraryPath.java

$JAVAC  GetLdLibraryPath.java



# All preconditions are met; run the tests


# Construct path to 32-bit Java executable
JAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES${PATHSEP}."


# Construct path to 64-bit Java executable, might not exist
JAVA64="$TESTJAVA/bin/sparcv9/java -classpath $TESTCLASSES${PATHSEP}."
JAVA64FILE="$TESTJAVA/bin/sparcv9/java"


# java -d32 tests

LD_LIBRARY_PATH=""
export LD_LIBRARY_PATH

DM=`$JAVA -d32 GetDataModel`
case "$DM" in
        32 )
        ;;

        * )
	echo "The combination \"java -d32\" failed."
	echo $DM
        exit 1
esac

# Rerun test with LD_LIBRARY_PATH preset
LD_LIBRARY_PATH=`$JAVA GetLdLibraryPath`;
DM=`$JAVA -d32 GetDataModel`
case "$DM" in
        32 )
        ;;

        * )
	echo "The combination \"java -d32\" failed with preset LD_LIBRARY_PATH."
	echo $DM
        exit 1
esac

# Reset LD_LIBRARY_PATH
LD_LIBRARY_PATH=


# Test for 64-bit executable

if [ -f $JAVA64FILE ]; then

	DM=`$JAVA -d64 GetDataModel`
	case "$DM" in
        	64 )
        	;;

        	* )
		echo "The combination \"java -d64\" failed."
        	exit 1
	esac

	DM=`$JAVA64 -d32 GetDataModel`
	case "$DM" in
        	32 )
        	;;

        	* )
		echo "The combination \"sparcv9/java -d32\" failed."
        	exit 1
	esac

	DM=`$JAVA64 -d64 GetDataModel`
	case "$DM" in
        	64 )
        	;;

        	* )
		echo "The combination \"sparcv9/java -d64\" failed."
        	exit 1
	esac

	# Rerun tests with LD_LIBRARY_PATH preset
	LD_LIBRARY_PATH=`$JAVA GetLdLibraryPath`;
	echo "Presetting LD_LIBRARY_PATH"

	DM=`$JAVA -d64 GetDataModel`
	case "$DM" in
        	64 )
        	;;

        	* )
		echo "The combination \"java -d64\" failed with preset LD_LIBRARY_PATH."
        	exit 1
	esac

	DM=`$JAVA64 -d32 GetDataModel`
	case "$DM" in
        	32 )
        	;;

        	* )
		echo "The combination \"sparcv9/java -d32\" failed with preset LD_LIBRARY_PATH."
        	exit 1
	esac

	DM=`$JAVA64 -d64 GetDataModel`
	case "$DM" in
        	64 )
        	;;

        	* )
		echo "The combination \"sparcv9/java -d64\" failed with preset LD_LIBRARY_PATH."
        	exit 1
	esac

else
  echo "Warning: no 64-bit components found; only java -d32 tests have been run."
fi
exit 0;