blob: 5ddb871b20b25e38a4053222fadbbbc03abe193d [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001#!/bin/ksh -p
2
3#
4# Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
5# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6#
7# This code is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 2 only, as
9# published by the Free Software Foundation.
10#
11# This code is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14# version 2 for more details (a copy is included in the LICENSE file that
15# accompanied this code).
16#
17# You should have received a copy of the GNU General Public License version
18# 2 along with this work; if not, write to the Free Software Foundation,
19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20#
21# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22# CA 95054 USA or visit www.sun.com if you need additional information or
23# have any questions.
24#
25
26#
27# @test Solaris32AndSolaris64Test.sh
28# @bug 4478312 4780570 4913748
29# @summary Test debugging with mixed 32/64bit VMs.
30# @author Tim Bell
31# Based on test/java/awt/TEMPLATE/AutomaticShellTest.sh
32#
33# @run build TestScaffold VMConnection TargetListener TargetAdapter
34# @run compile -g FetchLocals.java
35# @run compile -g DataModelTest.java
36# @run shell/timeout=240 Solaris32AndSolaris64Test.sh DataModelTest
37# @run shell/timeout=240 Solaris32AndSolaris64Test.sh FetchLocals
38
39# Beginning of subroutines:
40status=1
41
42#Call this from anywhere to fail the test with an error message
43# usage: fail "reason why the test failed"
44fail()
45 { echo "The test failed :-("
46 echo "$*" 1>&2
47 echo "exit status was $status"
48 exit $status
49 } #end of fail()
50
51#Call this from anywhere to pass the test with a message
52# usage: pass "reason why the test passed if applicable"
53pass()
54 { echo "The test passed!!!"
55 echo "$*" 1>&2
56 exit 0
57 } #end of pass()
58
59# end of subroutines
60
61if [ $# = 0 ] ; then
62 echo "Error: no testname specified on cmd line"
63 exit 1
64fi
65testName=$1
66shift
67
68#Set appropriate jdk
69
70if [ -z "${TESTJAVA}" ] ; then
71 # TESTJAVA is not set, so the test is running stand-alone.
72 # TESTJAVA holds the path to the root directory of the build of the JDK
73 # to be tested. That is, any java files run explicitly in this shell
74 # should use TESTJAVA in the path to the java interpreter.
75 # So, we'll set this to the JDK spec'd on the command line. If none
76 # is given on the command line, tell the user that and use a default.
77 # THIS IS THE JDK BEING TESTED.
78 if [ -n "$1" ] ; then
79 TESTJAVA=$1
80 else
81 echo "no JDK specified on command line so using JAVA_HOME=$JAVA_HOME"
82 TESTJAVA=$JAVA_HOME
83 fi
84 TESTSRC=.
85 TESTCLASSES=.
86 STANDALONE=1;
87fi
88echo "JDK under test is: $TESTJAVA"
89
90
91# The beginning of the script proper
92
93# Checking for proper OS and processor type.
94#
95# This test is only interested in SunOS SPARC sparcv9 and SunOS AMD64
96# (supporting both 32 and 64 bit Solaris binaries).
97#
98# All other platforms will instantly complete with passing
99# status.
100#
101OS=`uname -s`
102case "$OS" in
103 SunOS )
104 PATHSEP=":"
105 PTYPE=`uname -p`
106 if [ -x /usr/bin/isainfo ]; then
107 # Instruction set being used by the OS
108 ISET=`isainfo -k`
109 else
110 #SunOS 5.6 didn't have "isainfo"
111 pass "This test always passes on $OS/$PTYPE (32-bit ${ISET})"
112 fi
113 ;;
114
115 Linux )
116 pass "This test always passes on $OS"
117 ;;
118
119 Windows* | CYGWIN*)
120 pass "This test always passes on $OS"
121 ;;
122
123 # catch all other OSs
124 * )
125 echo "Unrecognized system! $OS"
126 fail "Unrecognized system! $OS"
127 ;;
128esac
129
130# Is the OS running in sparcv9 or amd64 mode?
131case "${ISET}" in
132 sparc )
133 pass "This test always passes on $OS/$PTYPE (32-bit ${ISET})"
134 ;;
135 i386 )
136 pass "This test always passes on $OS/$PTYPE (32-bit ${ISET})"
137 ;;
138 amd64 )
139 echo "OS is running in ${ISET} mode"
140 ;;
141 sparcv9 )
142 echo "OS is running in ${ISET} mode"
143 ;;
144 # catch all others
145 * )
146 echo "Unrecognized instruction set! $OS/$PTYPE/${ISET}"
147 fail "Unrecognized instruction set! $OS/$PTYPE/${ISET}"
148 ;;
149esac
150
151# SunOS 32 and 64 bit binaries must be available
152# to test in the remainder of the script below.
153$TESTJAVA/bin/java -d64 -version > /dev/null 2<&1
154if [ $? = 1 ]; then
155 # The 64 bit version is not installed. Make the test pass.
156 pass "This test always passes on $OS/$PTYPE if 64 bit jdk is not installed"
157fi
158
159# Want this test to run standalone as well as in the harness, so do the
160# following to copy the test's directory into the harness's scratch directory
161# and set all appropriate variables:
162
163#Deal with .class files:
164if [ -n "${STANDALONE}" ] ; then
165 #if running standalone, compile the support files
166 ${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
167 -classpath "$TESTJAVA/lib/tools.jar${PATHSEP}." \
168 TestScaffold.java VMConnection.java TargetListener.java TargetAdapter.java
169 ${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
170 -classpath "$TESTJAVA/lib/tools.jar${PATHSEP}." -g \
171 FetchLocals.java DataModelTest.java
172fi
173
174# Get DEBUGGEE flags
175DEBUGGEEFLAGS=
176filename=$TESTCLASSES/@debuggeeVMOptions
177if [ ! -r ${filename} ] ; then
178 filename=$TESTCLASSES/../@debuggeeVMOptions
179fi
180if [ -r ${filename} ] ; then
181 DEBUGGEEFLAGS=`cat ${filename} | sed -e 's/-d32//g' -e 's/-d64//g'`
182fi
183
184#
185CLASSPATH="$TESTJAVA/lib/tools.jar${PATHSEP}${TESTCLASSES}"
186export CLASSPATH
187CP="-classpath \"${CLASSPATH}\""
188
189for DEBUGGERMODEL in \
190 32 \
191 64 \
192; do
193
194 for TARGETMODEL in \
195 32 \
196 64 \
197 ; do
198 DEBUGGERFLAGS="-d${DEBUGGERMODEL} -showversion -DEXPECTED=${TARGETMODEL}"
199 CONNECTSTRING="-connect 'com.sun.jdi.CommandLineLaunch:options=-d${TARGETMODEL} $DEBUGGEEFLAGS -showversion'"
200
201 for TARGETCLASS in $testName ; do
202 echo "--------------------------------------------"
203 echo "debugger=${DEBUGGERMODEL} debugee=${TARGETMODEL} class=${TARGETCLASS}"
204 echo "--------------------------------------------"
205 echo ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${DEBUGGERFLAGS} ${CP} ${TARGETCLASS} ${CONNECTSTRING}
206 eval ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${DEBUGGERFLAGS} ${CP} ${TARGETCLASS} ${CONNECTSTRING}
207 status=$?
208 if [ $status -ne "0" ];
209 then fail "$DEBUGGERMODEL to $TARGETMODEL test failed for class=$TARGETCLASS!"
210 fi
211 done
212 done
213done
214#
215# pass or fail the test based on status of the command
216if [ $status -eq "0" ];
217 then pass ""
218
219 else fail "unspecified test failure"
220fi