1 #!/bin/ksh -p
   2 
   3 #
   4 # Copyright (c) 2002, 2015, 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       JITDebug.sh 1.7 03/09/05
  28 #   @bug        4291701 4376819 4422312 4522770 4913748
  29 #   @summary    Test JIT debugging - assure that launching on
  30 #               uncaught exception works
  31 #   @author     Tim Bell
  32 #   Based on test/java/awt/TEMPLATE/AutomaticShellTest.sh
  33 #
  34 #   @modules jdk.jdi
  35 #   @run build TestScaffold VMConnection TargetListener TargetAdapter
  36 #   @run compile -g JITDebug.java
  37 #   @run shell JITDebug.sh
  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 
  62 # The beginning of the script proper
  63 
  64 OS=`uname -s`
  65 export TRANSPORT_METHOD
  66 case "$OS" in
  67    SunOS | Linux | Darwin | AIX )
  68       PATHSEP=":"
  69       TRANSPORT_METHOD=dt_socket
  70       ;;
  71 
  72    Windows* | CYGWIN*)
  73       PATHSEP=";"
  74       TRANSPORT_METHOD=dt_shmem
  75       ;;
  76 
  77    # catch all other OSs
  78    * )
  79       echo "Unrecognized system!  $OS"
  80       fail "Unrecognized system!  $OS"
  81       ;;
  82 esac
  83 #
  84 # Want this test to run standalone as well as in the harness, so do the
  85 #  following to copy the test's directory into the harness's scratch directory
  86 #  and set all appropriate variables:
  87 
  88 if [ -z "${TESTJAVA}" ] ; then
  89    # TESTJAVA is not set, so the test is running stand-alone.
  90    # TESTJAVA holds the path to the root directory of the build of the JDK
  91    # to be tested.  That is, any java files run explicitly in this shell
  92    # should use TESTJAVA in the path to the java interpreter.
  93    # So, we'll set this to the JDK spec'd on the command line.  If none
  94    # is given on the command line, tell the user that and use a default.
  95    # THIS IS THE JDK BEING TESTED.
  96    if [ -n "$1" ] ; then
  97           TESTJAVA=$1
  98       else
  99           TESTJAVA=$JAVA_HOME
 100    fi
 101    TESTSRC=.
 102    TESTCLASSES=.
 103    #Deal with .class files:
 104    #if running standalone (no test harness of any kind), compile the
 105    #support files and the test case
 106    ${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
 107             -classpath "${TESTSRC}" \
 108             TestScaffold.java VMConnection.java TargetListener.java TargetAdapter.java
 109    ${TESTJAVA}/bin/javac  -d ${TESTCLASSES} \
 110             -classpath "${TESTSRC}" -g \
 111             JITDebug.java
 112 fi
 113 echo "JDK under test is: $TESTJAVA"
 114 #
 115 CLASSPATH="${TESTCLASSES}"
 116 export CLASSPATH
 117 CP="-classpath \"${CLASSPATH}\""
 118 #
 119 TARGETCLASS=JITDebug
 120 RUNFLAGS='-showversion -DTRANSPORT_METHOD="${TRANSPORT_METHOD}"'
 121 RUNFLAGS="-Dtest.classes=${TESTCLASSES} ${RUNFLAGS}"
 122 #
 123 echo ""
 124 echo "Environment variable definitions are:"
 125 echo ""
 126 env | sort
 127 echo ""
 128 echo ""
 129 #
 130 echo "Starting test:"
 131 echo ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${RUNFLAGS} ${CP} ${TARGETCLASS}
 132 eval ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${RUNFLAGS} ${CP} ${TARGETCLASS}
 133 status=$?
 134 if [ $status -ne "0" ];
 135 then fail "test failed for class=$TARGETCLASS!"
 136 fi
 137 #
 138 # pass or fail the test based on status of the command
 139 if [ $status -eq "0" ];
 140    then pass ""
 141 
 142    else fail "unspecified test failure"
 143 fi