ChangeDataModel.sh revision 2078
0N/A#
0N/A# Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
0N/A# published by the Free Software Foundation.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
0N/A# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A# CA 95054 USA or visit www.sun.com if you need additional information or
0N/A# have any questions.
0N/A#
0N/A
0N/A# @test
0N/A# @bug 4894330 4810347 6277269
0N/A# @run shell ChangeDataModel.sh
0N/A# @summary Verify -d32 and -d64 options are accepted(rejected) on all platforms
0N/A# @author Joseph D. Darcy
0N/A
0N/AOS=`uname -s`;
0N/A
2078N/A# To remove CR from output, needed for java apps in CYGWIN, harmless otherwise
2078N/ASED_CR="sed -e s@\\r@@g"
2078N/A
0N/Acase "$OS" in
0N/A Windows* | CYGWIN* )
0N/A PATHSEP=";"
0N/A ;;
0N/A
0N/A * )
0N/A PATHSEP=":"
0N/A ;;
0N/Aesac
0N/A
0N/A# Verify directory context variables are set
0N/Aif [ "${TESTJAVA}" = "" ]
0N/Athen
0N/A echo "TESTJAVA not set. Test cannot execute. Failed."
0N/A exit 1
0N/Afi
0N/A
0N/Aif [ "${TESTSRC}" = "" ]
0N/Athen
0N/A echo "TESTSRC not set. Test cannot execute. Failed."
0N/A exit 1
0N/Afi
0N/A
0N/Aif [ "${TESTCLASSES}" = "" ]
0N/Athen
0N/A echo "TESTCLASSES not set. Test cannot execute. Failed."
0N/A exit 1
0N/Afi
0N/A
0N/A# Construct paths to default Java executables
0N/AJAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES${PATHSEP}."
0N/AJAVAC="$TESTJAVA/bin/javac"
0N/A
0N/A
0N/A# Create our little Java test on the fly
0N/A( printf "public class GetDataModel {"
0N/A printf " public static void main(String argv[]) {"
0N/A printf " System.out.println(System.getProperty(\"sun.arch.data.model\", \"none\"));"
0N/A printf " }"
0N/A printf "}"
0N/A) > GetDataModel.java
0N/A
0N/A$JAVAC GetDataModel.java
0N/A
0N/A
0N/A# All preconditions are met; run the tests.
0N/A
0N/A
0N/A# Verify data model flag for default data model is accepted
0N/A
2078N/ADM=`$JAVA GetDataModel | ${SED_CR}`
0N/Acase "$DM" in
0N/A 32 )
2078N/A DM2=`${JAVA} -d32 GetDataModel | ${SED_CR}`
0N/A if [ "${DM2}" != "32" ]
0N/A then
0N/A echo "Data model flag -d32 not accepted or had improper effect."
0N/A exit 1
0N/A fi
0N/A ;;
0N/A
0N/A 64 )
2078N/A DM2=`${JAVA} -d64 GetDataModel | ${SED_CR}`
0N/A if [ "${DM2}" != "64" ]
0N/A then
0N/A echo "Data model flag -d64 not accepted or had improper effect."
0N/A exit 1
0N/A fi
0N/A ;;
0N/A
0N/A * )
0N/A echo "Unrecognized data model: $DM"
0N/A exit 1
0N/A ;;
0N/Aesac
0N/A
0N/A# Determine if platform might be dual-mode capable.
0N/A
0N/Acase "$OS" in
0N/A SunOS )
0N/A # ARCH should be sparc or i386
0N/A ARCH=`uname -p`
0N/A case "${ARCH}" in
0N/A sparc )
0N/A DUALMODE=true
0N/A PATH64=sparcv9
0N/A ;;
0N/A
0N/A i386 )
0N/A DUALMODE=true
0N/A PATH64=amd64
0N/A ;;
0N/A
0N/A * )
0N/A DUALMODE=false
0N/A ;;
0N/A esac
0N/A ;;
0N/A
0N/A
0N/A Linux )
0N/A # ARCH should be ia64, x86_64, or i*86
0N/A ARCH=`uname -m`
0N/A case "${ARCH}" in
0N/A ia64 )
0N/A DUALMODE=false
0N/A ;;
0N/A
0N/A x86_64 )
0N/A DUALMODE=true
0N/A PATH64=amd64
0N/A ;;
0N/A
0N/A * )
0N/A DUALMODE=false;
0N/A ;;
0N/A esac
0N/A ;;
0N/A
0N/A Windows* | CYGWIN* )
0N/A ARCH=`uname -m`
0N/A case "${ARCH}" in
0N/A * )
0N/A DUALMODE=false;
0N/A ;;
0N/A esac
0N/A ;;
0N/A
0N/A * )
0N/A echo "Warning: unknown environment."
0N/A DUALMODE=false
0N/A ;;
0N/Aesac
0N/A
0N/Aif [ "${DUALMODE}" = "true" ]
0N/Athen
0N/A # Construct path to 64-bit Java executable, might not exist
0N/A JAVA64FILE="${TESTJAVA}/bin/${PATH64}/java"
0N/A JAVA64="${JAVA64FILE} -classpath ${TESTCLASSES}${PATHSEP}."
0N/A
0N/A if [ -f ${JAVA64FILE} ]; then
0N/A # Verify that, at least on Solaris, only one exec is
0N/A # used to change data models
0N/A if [ "${OS}" = "SunOS" ]
0N/A then
0N/A rm -f truss.out
0N/A truss -texec ${JAVA} -d64 GetDataModel > /dev/null 2> truss.out
0N/A execCount=`grep -c execve truss.out`
0N/A if [ "${execCount}" -gt 2 ]
0N/A then
0N/A echo "Maximum exec count of 2 exceeded: got $execCount."
0N/A exit 1
0N/A fi
0N/A
0N/A rm -f truss.out
0N/A truss -texec ${JAVA64} -d32 GetDataModel > /dev/null 2> truss.out
0N/A execCount=`grep -c execve truss.out`
0N/A if [ "${execCount}" -gt 2 ]
0N/A then
0N/A echo "Maximum exec count of 2 exceeded: got $execCount."
0N/A exit 1
0N/A fi
0N/A fi
0N/A
0N/A DM2=`${JAVA} -d64 GetDataModel`
0N/A if [ "${DM2}" != "64" ]
0N/A then
0N/A echo "Data model flag -d64 not accepted or had improper effect."
0N/A exit 1
0N/A fi
0N/A
0N/A DM2=`${JAVA64} GetDataModel`
0N/A if [ "${DM2}" != "64" ]
0N/A then
0N/A echo "Improper data model returned."
0N/A exit 1
0N/A fi
0N/A
0N/A DM2=`${JAVA64} -d64 GetDataModel`
0N/A if [ "${DM2}" != "64" ]
0N/A then
0N/A echo "Data model flag -d64 not accepted or had improper effect."
0N/A exit 1
0N/A fi
0N/A
0N/A DM2=`${JAVA64} -d32 GetDataModel`
0N/A if [ "${DM2}" != "32" ]
0N/A then
0N/A echo "Data model flag -d32 not accepted or had improper effect."
0N/A exit 1
0N/A fi
0N/A
0N/A else
0N/A echo "Warning: no 64-bit components found; only one data model tested."
0N/A fi
0N/Aelse
0N/A# Negative tests for non-dual mode platforms to ensure the other data model is
0N/A# rejected
2078N/A DM=`$JAVA GetDataModel | ${SED_CR}`
0N/A case "$DM" in
0N/A 32 )
2078N/A DM2=`${JAVA} -d64 GetDataModel | ${SED_CR}`
0N/A if [ "x${DM2}" != "x" ]
0N/A then
0N/A echo "Data model flag -d64 was accepted."
0N/A exit 1
0N/A fi
0N/A ;;
0N/A
0N/A 64 )
2078N/A DM2=`${JAVA} -d32 GetDataModel | ${SED_CR}`
0N/A if [ "x${DM2}" != "x" ]
0N/A then
0N/A echo "Data model flag -d32 was accepted."
0N/A exit 1
0N/A fi
0N/A ;;
0N/A
0N/A * )
0N/A echo "Unrecognized data model: $DM"
0N/A exit 1
0N/A ;;
0N/A esac
0N/Afi
0N/A
0N/Aexit 0;