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# @run build TestScaffold VMConnection TargetListener TargetAdapter
35# @run compile -g JITDebug.java
36# @run shell JITDebug.sh
37
38# Beginning of subroutines:
39status=1
40
41#Call this from anywhere to fail the test with an error message
42# usage: fail "reason why the test failed"
43fail()
44 { echo "The test failed :-("
45   echo "$*" 1>&2
46   echo "exit status was $status"
47   exit $status
48 } #end of fail()
49
50#Call this from anywhere to pass the test with a message
51# usage: pass "reason why the test passed if applicable"
52pass()
53 { echo "The test passed!!!"
54   echo "$*" 1>&2
55   exit 0
56 } #end of pass()
57
58# end of subroutines
59
60
61# The beginning of the script proper
62
63OS=`uname -s`
64export TRANSPORT_METHOD
65case "$OS" in
66   SunOS | Linux | Darwin | AIX )
67      PATHSEP=":"
68      TRANSPORT_METHOD=dt_socket
69      ;;
70
71   Windows* | CYGWIN*)
72      PATHSEP=";"
73      TRANSPORT_METHOD=dt_shmem
74      ;;
75
76   # catch all other OSs
77   * )
78      echo "Unrecognized system!  $OS"
79      fail "Unrecognized system!  $OS"
80      ;;
81esac
82#
83# Want this test to run standalone as well as in the harness, so do the
84#  following to copy the test's directory into the harness's scratch directory
85#  and set all appropriate variables:
86
87if [ -z "${TESTJAVA}" ] ; then
88   # TESTJAVA is not set, so the test is running stand-alone.
89   # TESTJAVA holds the path to the root directory of the build of the JDK
90   # to be tested.  That is, any java files run explicitly in this shell
91   # should use TESTJAVA in the path to the java interpreter.
92   # So, we'll set this to the JDK spec'd on the command line.  If none
93   # is given on the command line, tell the user that and use a default.
94   # THIS IS THE JDK BEING TESTED.
95   if [ -n "$1" ] ; then
96          TESTJAVA=$1
97      else
98          TESTJAVA=$JAVA_HOME
99   fi
100   TESTSRC=.
101   TESTCLASSES=.
102   #Deal with .class files:
103   #if running standalone (no test harness of any kind), compile the
104   #support files and the test case
105   ${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
106            -classpath "${TESTSRC}" \
107            TestScaffold.java VMConnection.java TargetListener.java TargetAdapter.java
108   ${TESTJAVA}/bin/javac  -d ${TESTCLASSES} \
109            -classpath "${TESTSRC}" -g \
110            JITDebug.java
111fi
112echo "JDK under test is: $TESTJAVA"
113#
114CLASSPATH="${TESTCLASSES}"
115export CLASSPATH
116CP="-classpath \"${CLASSPATH}\""
117#
118TARGETCLASS=JITDebug
119RUNFLAGS='-showversion -DTRANSPORT_METHOD="${TRANSPORT_METHOD}"'
120RUNFLAGS="-Dtest.classes=${TESTCLASSES} ${RUNFLAGS}"
121#
122echo ""
123echo "Environment variable definitions are:"
124echo ""
125env | sort
126echo ""
127echo ""
128#
129echo "Starting test:"
130echo ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${RUNFLAGS} ${CP} ${TARGETCLASS}
131eval ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${RUNFLAGS} ${CP} ${TARGETCLASS}
132status=$?
133if [ $status -ne "0" ];
134then fail "test failed for class=$TARGETCLASS!"
135fi
136#
137# pass or fail the test based on status of the command
138if [ $status -eq "0" ];
139   then pass ""
140
141   else fail "unspecified test failure"
142fi
143