J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | # Copyright 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 19 | # CA 95054 USA or visit www.sun.com if you need additional information or |
| 20 | # have any questions. |
| 21 | |
| 22 | # @test |
| 23 | # @bug 4780570 |
| 24 | # @run shell SolarisDataModel.sh |
| 25 | # @summary Verify Solaris SPARC -d32 and -d64 options work with preset LD_LIBRARY_PATH |
| 26 | # @author Joseph D. Darcy |
| 27 | |
| 28 | # Test to see if presetting LD_LIBRARY_PATH affects the treatment of |
| 29 | # -d32 and -d64 options; also checks that -d<n> options result in the |
| 30 | # desired data model. |
| 31 | |
| 32 | # If the test is not being run on a Solaris SPARC box SPARC the test |
| 33 | # succeeds immediately. |
| 34 | |
| 35 | OS=`uname -s`; |
| 36 | |
| 37 | case "$OS" in |
| 38 | SunOS ) |
| 39 | # ARCH should be sparc or i386 |
| 40 | ARCH=`uname -p` |
| 41 | case "$ARCH" in |
| 42 | sparc) |
| 43 | PATHSEP=":" |
| 44 | ;; |
| 45 | |
| 46 | * ) |
| 47 | echo "Non-SPARC Solaris environment; test vacuously succeeds." |
| 48 | exit 0 |
| 49 | esac |
| 50 | ;; |
| 51 | |
| 52 | * ) |
| 53 | echo "Not a Solaris SPARC environment; test vacuously succeeds." |
| 54 | exit 0; |
| 55 | ;; |
| 56 | esac |
| 57 | |
| 58 | |
| 59 | # Verify directory context variables are set |
| 60 | if [ "${TESTJAVA}" = "" ] |
| 61 | then |
| 62 | echo "TESTJAVA not set. Test cannot execute. Failed." |
| 63 | exit 1 |
| 64 | fi |
| 65 | |
| 66 | if [ "${TESTSRC}" = "" ] |
| 67 | then |
| 68 | echo "TESTSRC not set. Test cannot execute. Failed." |
| 69 | exit 1 |
| 70 | fi |
| 71 | |
| 72 | |
| 73 | if [ "${TESTCLASSES}" = "" ] |
| 74 | then |
| 75 | echo "TESTCLASSES not set. Test cannot execute. Failed." |
| 76 | exit 1 |
| 77 | fi |
| 78 | |
| 79 | |
| 80 | JAVAC="$TESTJAVA/bin/javac" |
| 81 | |
| 82 | # Create our little Java tests on the fly |
| 83 | ( printf "public class GetDataModel {" |
| 84 | printf " public static void main(String argv[]) {" |
| 85 | printf " System.out.println(System.getProperty(\"sun.arch.data.model\", \"none\"));" |
| 86 | printf " }" |
| 87 | printf "}" |
| 88 | ) > GetDataModel.java |
| 89 | |
| 90 | $JAVAC GetDataModel.java |
| 91 | |
| 92 | ( printf "public class GetLdLibraryPath {" |
| 93 | printf " public static void main(String argv[]) {" |
| 94 | printf " System.out.println(System.getProperty(\"java.library.path\"));" |
| 95 | printf " }" |
| 96 | printf "}" |
| 97 | ) > GetLdLibraryPath.java |
| 98 | |
| 99 | $JAVAC GetLdLibraryPath.java |
| 100 | |
| 101 | |
| 102 | |
| 103 | # All preconditions are met; run the tests |
| 104 | |
| 105 | |
| 106 | # Construct path to 32-bit Java executable |
| 107 | JAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES${PATHSEP}." |
| 108 | |
| 109 | |
| 110 | # Construct path to 64-bit Java executable, might not exist |
| 111 | JAVA64="$TESTJAVA/bin/sparcv9/java -classpath $TESTCLASSES${PATHSEP}." |
| 112 | JAVA64FILE="$TESTJAVA/bin/sparcv9/java" |
| 113 | |
| 114 | |
| 115 | # java -d32 tests |
| 116 | |
| 117 | LD_LIBRARY_PATH="" |
| 118 | export LD_LIBRARY_PATH |
| 119 | |
| 120 | DM=`$JAVA -d32 GetDataModel` |
| 121 | case "$DM" in |
| 122 | 32 ) |
| 123 | ;; |
| 124 | |
| 125 | * ) |
| 126 | echo "The combination \"java -d32\" failed." |
| 127 | echo $DM |
| 128 | exit 1 |
| 129 | esac |
| 130 | |
| 131 | # Rerun test with LD_LIBRARY_PATH preset |
| 132 | LD_LIBRARY_PATH=`$JAVA GetLdLibraryPath`; |
| 133 | DM=`$JAVA -d32 GetDataModel` |
| 134 | case "$DM" in |
| 135 | 32 ) |
| 136 | ;; |
| 137 | |
| 138 | * ) |
| 139 | echo "The combination \"java -d32\" failed with preset LD_LIBRARY_PATH." |
| 140 | echo $DM |
| 141 | exit 1 |
| 142 | esac |
| 143 | |
| 144 | # Reset LD_LIBRARY_PATH |
| 145 | LD_LIBRARY_PATH= |
| 146 | |
| 147 | |
| 148 | # Test for 64-bit executable |
| 149 | |
| 150 | if [ -f $JAVA64FILE ]; then |
| 151 | |
| 152 | DM=`$JAVA -d64 GetDataModel` |
| 153 | case "$DM" in |
| 154 | 64 ) |
| 155 | ;; |
| 156 | |
| 157 | * ) |
| 158 | echo "The combination \"java -d64\" failed." |
| 159 | exit 1 |
| 160 | esac |
| 161 | |
| 162 | DM=`$JAVA64 -d32 GetDataModel` |
| 163 | case "$DM" in |
| 164 | 32 ) |
| 165 | ;; |
| 166 | |
| 167 | * ) |
| 168 | echo "The combination \"sparcv9/java -d32\" failed." |
| 169 | exit 1 |
| 170 | esac |
| 171 | |
| 172 | DM=`$JAVA64 -d64 GetDataModel` |
| 173 | case "$DM" in |
| 174 | 64 ) |
| 175 | ;; |
| 176 | |
| 177 | * ) |
| 178 | echo "The combination \"sparcv9/java -d64\" failed." |
| 179 | exit 1 |
| 180 | esac |
| 181 | |
| 182 | # Rerun tests with LD_LIBRARY_PATH preset |
| 183 | LD_LIBRARY_PATH=`$JAVA GetLdLibraryPath`; |
| 184 | echo "Presetting LD_LIBRARY_PATH" |
| 185 | |
| 186 | DM=`$JAVA -d64 GetDataModel` |
| 187 | case "$DM" in |
| 188 | 64 ) |
| 189 | ;; |
| 190 | |
| 191 | * ) |
| 192 | echo "The combination \"java -d64\" failed with preset LD_LIBRARY_PATH." |
| 193 | exit 1 |
| 194 | esac |
| 195 | |
| 196 | DM=`$JAVA64 -d32 GetDataModel` |
| 197 | case "$DM" in |
| 198 | 32 ) |
| 199 | ;; |
| 200 | |
| 201 | * ) |
| 202 | echo "The combination \"sparcv9/java -d32\" failed with preset LD_LIBRARY_PATH." |
| 203 | exit 1 |
| 204 | esac |
| 205 | |
| 206 | DM=`$JAVA64 -d64 GetDataModel` |
| 207 | case "$DM" in |
| 208 | 64 ) |
| 209 | ;; |
| 210 | |
| 211 | * ) |
| 212 | echo "The combination \"sparcv9/java -d64\" failed with preset LD_LIBRARY_PATH." |
| 213 | exit 1 |
| 214 | esac |
| 215 | |
| 216 | else |
| 217 | echo "Warning: no 64-bit components found; only java -d32 tests have been run." |
| 218 | fi |
| 219 | exit 0; |