ChangeDataModel.sh revision 0
0N/A#
553N/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
553N/A# published by the Free Software Foundation.
0N/A#
553N/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
553N/A# have any questions.
553N/A#
553N/A
0N/A# @test
0N/A# @bug 4894330 4810347 6277269
538N/A# @run shell ChangeDataModel.sh
0N/A# @summary Verify -d32 and -d64 options are accepted(rejected) on all platforms
538N/A# @author Joseph D. Darcy
0N/A
538N/AOS=`uname -s`;
0N/A
538N/Acase "$OS" in
0N/A Windows* | CYGWIN* )
0N/A PATHSEP=";"
0N/A ;;
538N/A
538N/A * )
538N/A PATHSEP=":"
538N/A ;;
538N/Aesac
538N/A
538N/A# Verify directory context variables are set
538N/Aif [ "${TESTJAVA}" = "" ]
538N/Athen
538N/A echo "TESTJAVA not set. Test cannot execute. Failed."
538N/A exit 1
538N/Afi
538N/A
538N/Aif [ "${TESTSRC}" = "" ]
538N/Athen
538N/A echo "TESTSRC not set. Test cannot execute. Failed."
538N/A exit 1
538N/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
538N/AJAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES${PATHSEP}."
0N/AJAVAC="$TESTJAVA/bin/javac"
538N/A
0N/A
538N/A# Create our little Java test on the fly
0N/A( printf "public class GetDataModel {"
538N/A printf " public static void main(String argv[]) {"
0N/A printf " System.out.println(System.getProperty(\"sun.arch.data.model\", \"none\"));"
538N/A printf " }"
0N/A printf "}"
538N/A) > GetDataModel.java
0N/A
0N/A$JAVAC GetDataModel.java
538N/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
538N/A
0N/ADM=`$JAVA GetDataModel`
538N/Acase "$DM" in
538N/A 32 )
538N/A DM2=`${JAVA} -d32 GetDataModel`
0N/A if [ "${DM2}" != "32" ]
0N/A then
538N/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 )
0N/A DM2=`${JAVA} -d64 GetDataModel`
538N/A if [ "${DM2}" != "64" ]
0N/A then
538N/A echo "Data model flag -d64 not accepted or had improper effect."
0N/A exit 1
538N/A fi
0N/A ;;
538N/A
0N/A * )
538N/A echo "Unrecognized data model: $DM"
0N/A exit 1
538N/A ;;
0N/Aesac
538N/A
0N/A# Determine if platform might be dual-mode capable.
538N/A
0N/Acase "$OS" in
538N/A SunOS )
0N/A # ARCH should be sparc or i386
538N/A ARCH=`uname -p`
0N/A case "${ARCH}" in
538N/A sparc )
0N/A DUALMODE=true
0N/A PATH64=sparcv9
538N/A ;;
0N/A
538N/A i386 )
0N/A DUALMODE=true
538N/A PATH64=amd64
0N/A ;;
538N/A
0N/A * )
538N/A DUALMODE=false
;;
esac
;;
Linux )
# ARCH should be ia64, x86_64, or i*86
ARCH=`uname -m`
case "${ARCH}" in
ia64 )
DUALMODE=false
;;
x86_64 )
DUALMODE=true
PATH64=amd64
;;
* )
DUALMODE=false;
;;
esac
;;
Windows* | CYGWIN* )
ARCH=`uname -m`
case "${ARCH}" in
* )
DUALMODE=false;
;;
esac
;;
* )
echo "Warning: unknown environment."
DUALMODE=false
;;
esac
if [ "${DUALMODE}" = "true" ]
then
# Construct path to 64-bit Java executable, might not exist
JAVA64FILE="${TESTJAVA}/bin/${PATH64}/java"
JAVA64="${JAVA64FILE} -classpath ${TESTCLASSES}${PATHSEP}."
if [ -f ${JAVA64FILE} ]; then
# Verify that, at least on Solaris, only one exec is
# used to change data models
if [ "${OS}" = "SunOS" ]
then
rm -f truss.out
truss -texec ${JAVA} -d64 GetDataModel > /dev/null 2> truss.out
execCount=`grep -c execve truss.out`
if [ "${execCount}" -gt 2 ]
then
echo "Maximum exec count of 2 exceeded: got $execCount."
exit 1
fi
rm -f truss.out
truss -texec ${JAVA64} -d32 GetDataModel > /dev/null 2> truss.out
execCount=`grep -c execve truss.out`
if [ "${execCount}" -gt 2 ]
then
echo "Maximum exec count of 2 exceeded: got $execCount."
exit 1
fi
fi
DM2=`${JAVA} -d64 GetDataModel`
if [ "${DM2}" != "64" ]
then
echo "Data model flag -d64 not accepted or had improper effect."
exit 1
fi
DM2=`${JAVA64} GetDataModel`
if [ "${DM2}" != "64" ]
then
echo "Improper data model returned."
exit 1
fi
DM2=`${JAVA64} -d64 GetDataModel`
if [ "${DM2}" != "64" ]
then
echo "Data model flag -d64 not accepted or had improper effect."
exit 1
fi
DM2=`${JAVA64} -d32 GetDataModel`
if [ "${DM2}" != "32" ]
then
echo "Data model flag -d32 not accepted or had improper effect."
exit 1
fi
else
echo "Warning: no 64-bit components found; only one data model tested."
fi
else
# Negative tests for non-dual mode platforms to ensure the other data model is
# rejected
DM=`$JAVA GetDataModel`
case "$DM" in
32 )
DM2=`${JAVA} -d64 GetDataModel`
if [ "x${DM2}" != "x" ]
then
echo "Data model flag -d64 was accepted."
exit 1
fi
;;
64 )
DM2=`${JAVA} -d32 GetDataModel`
if [ "x${DM2}" != "x" ]
then
echo "Data model flag -d32 was accepted."
exit 1
fi
;;
* )
echo "Unrecognized data model: $DM"
exit 1
;;
esac
fi
exit 0;