jdk/test/com/sun/jdi/Solaris32AndSolaris64Test.sh
changeset 20775 a7cd22051d8f
parent 20774 330ea6efa3fd
parent 20773 65f064b13df0
child 20776 6c440a257019
child 20777 ad30bd042ffd
equal deleted inserted replaced
20774:330ea6efa3fd 20775:a7cd22051d8f
     1 #!/bin/ksh -p
       
     2 
       
     3 #
       
     4 # Copyright (c) 2001, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22 # or visit www.oracle.com if you need additional information or have any
       
    23 # questions.
       
    24 #
       
    25 
       
    26 #
       
    27 #   @test       Solaris32AndSolaris64Test.sh
       
    28 #   @bug        4478312 4780570 4913748 6730273
       
    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:
       
    40 status=1
       
    41 
       
    42 #Call this from anywhere to fail the test with an error message
       
    43 # usage: fail "reason why the test failed"
       
    44 fail()
       
    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"
       
    53 pass()
       
    54  { echo "The test passed!!!"
       
    55    echo "$*" 1>&2
       
    56    exit 0
       
    57  } #end of pass()
       
    58 
       
    59 # end of subroutines
       
    60 
       
    61 if [ $# = 0 ] ; then
       
    62     echo "Error: no testname specified on cmd line"
       
    63     exit 1
       
    64 fi
       
    65 testName=$1
       
    66 shift
       
    67 
       
    68 #Set appropriate jdk
       
    69 
       
    70 if [ -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;
       
    87 fi
       
    88 echo "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 #
       
   101 OS=`uname -s`
       
   102 case "$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 | Darwin )
       
   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       ;;
       
   128 esac
       
   129 
       
   130 # Is the OS running in sparcv9 or amd64 mode?
       
   131 case "${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       ;;
       
   149 esac
       
   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
       
   154 if [ $? = 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"
       
   157 fi
       
   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:
       
   164 if [ -n "${STANDALONE}" ] ; then
       
   165    #if running standalone, compile the support files
       
   166    ${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
       
   167             -classpath "$TESTJAVA/lib/tools.jar${PATHSEP}${TESTSRC}" \
       
   168             TestScaffold.java VMConnection.java TargetListener.java TargetAdapter.java
       
   169    ${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
       
   170             -classpath "$TESTJAVA/lib/tools.jar${PATHSEP}${TESTSRC}" -g \
       
   171             FetchLocals.java DataModelTest.java
       
   172 fi
       
   173 
       
   174 # Get DEBUGGEE flags
       
   175 DEBUGGEEFLAGS=
       
   176 filename=$TESTCLASSES/@debuggeeVMOptions
       
   177 if [ ! -r ${filename} ] ; then
       
   178     filename=$TESTCLASSES/../@debuggeeVMOptions
       
   179 fi
       
   180 # Remove -d32, -d64 if present, and remove -XX:[+-]UseCompressedOops
       
   181 # if present since it is illegal in 32 bit mode.
       
   182 if [ -r ${filename} ] ; then
       
   183     DEBUGGEEFLAGS=`cat ${filename} | sed \
       
   184                         -e 's/-d32//g' \
       
   185                         -e 's/-d64//g' \
       
   186                         -e 's/-XX:.UseCompressedOops//g' \
       
   187                         `
       
   188 fi
       
   189 
       
   190 #
       
   191 CLASSPATH="$TESTJAVA/lib/tools.jar${PATHSEP}${TESTCLASSES}"
       
   192 export CLASSPATH
       
   193 CP="-classpath \"${CLASSPATH}\""
       
   194 
       
   195 for DEBUGGERMODEL in \
       
   196     32 \
       
   197     64 \
       
   198 ; do
       
   199 
       
   200     for TARGETMODEL in \
       
   201         32 \
       
   202         64 \
       
   203     ; do
       
   204         DEBUGGERFLAGS="-d${DEBUGGERMODEL} -showversion -DEXPECTED=${TARGETMODEL}"
       
   205         CONNECTSTRING="-connect 'com.sun.jdi.CommandLineLaunch:options=-d${TARGETMODEL} $DEBUGGEEFLAGS -showversion'"
       
   206 
       
   207         for TARGETCLASS in $testName ; do
       
   208             echo "--------------------------------------------"
       
   209             echo "debugger=${DEBUGGERMODEL} debugee=${TARGETMODEL} class=${TARGETCLASS}"
       
   210             echo "--------------------------------------------"
       
   211             echo ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${DEBUGGERFLAGS} ${CP} ${TARGETCLASS} ${CONNECTSTRING}
       
   212             eval ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${DEBUGGERFLAGS} ${CP} ${TARGETCLASS} ${CONNECTSTRING}
       
   213             status=$?
       
   214             if [ $status -ne "0" ];
       
   215                then fail "$DEBUGGERMODEL to $TARGETMODEL test failed for class=$TARGETCLASS!"
       
   216             fi
       
   217         done
       
   218     done
       
   219 done
       
   220 #
       
   221 # pass or fail the test based on status of the command
       
   222 if [ $status -eq "0" ];
       
   223    then pass ""
       
   224 
       
   225    else fail "unspecified test failure"
       
   226 fi