jdk/test/com/sun/jdi/ShellScaffold.sh
author sla
Tue, 22 Mar 2016 19:29:25 +0100
changeset 37320 a802ccc88c30
parent 32427 c22b7e41adf3
child 37530 059353096b4e
permissions -rw-r--r--
8151887: com/sun/jdi/RedefineClearBreakpoint.sh failed with timeout Summary: Take timeout factor into account Reviewed-by: dsamersoff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#!/bin/sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
#
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
     4
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4325
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4325
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4325
diff changeset
    23
# questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
# jtreg runs this in a scratch dir.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
# It (and runregress -no) sets these env vars:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#    TESTSRC:      The dir that contains this file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#    TESTCLASSES:  Where .class files are compiled to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#    TESTJAVA:     The jdk to run
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
# This is a 'library' script that is included by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
# shell script test cases that want to run a .java file as the debuggee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
# and use jdb as the debugger.  This file contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
# several functions that support such a test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
# The caller script can also set these shell vars before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
# including this file:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#    pkg=<package name>       To use a package, define it here and put
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#                                package $pkg
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#                             in your java file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#    classname=<classnam>     Omit this to use the default class name, 'shtest'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#    compileOptions=<string>  compile options for at least the first compile, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#                             eg, compileOptions=-g
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#    compileOptions2=<string> Options for the 2nd, ..., compile. compileOptions1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#                             is used if this is not set.  To use no compile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#                             options for the 2nd ... compiles, do 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#                             compileOptions2=none
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#    mode=-Xcomp or mode=-Xint to run in these modes.  These should not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#                              really be used since the tests are normally
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#                              run in both modes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#    javacCmd=path-to-javac    to use a non-standard javac for compiling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#    compileOptions=<string>   Options to pass to javac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
# See RedefineException.sh as an example of a caller script.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
# To do RedefineClasses operations, embed @1 tags in the .java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
# file to tell this script how to modify it to produce the 2nd
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
# version of the .class file to be used in the redefine operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
# Here are examples of each editting tag and what change
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
# it causes in the new file.  Note that blanks are not preserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
# in these editing operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
# @1 uncomment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#  orig:   // @1 uncomment   gus = 89;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#  new:         gus = 89;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
# @1 commentout
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#  orig:   gus = 89      // @1 commentout
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#  new: // gus = 89      // @1 commentout
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
# @1 delete
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
#  orig:  gus = 89      // @1 delete
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#  new:   entire line deleted
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
# @1 newline
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#  orig:  gus = 89;     // @1 newline gus++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
#  new:   gus = 89;     //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
#         gus++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
# @1 replace
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#  orig:  gus = 89;     // @1 replace gus = 90;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#  new:   gus = 90;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
# The only other tag supported is @1 breakpoint.  The setbkpts function
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
# sets bkpts at all lines that contain this string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
# 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
# Currently, all these tags are start with @1.  It is envisioned that this script
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
# could be ehanced to allow multiple cycles of redefines by allowing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
# @2, @3, ... tags.  IE, processing the @i tags in the ith version of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
# the file will produce the i+1th version of the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
# 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
# There are problem with jtreg leaving behind orphan java and jdb processes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
# when this script is run.  Sometimes, on some platforms, it just doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
# get them all killed properly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
# The solution is to put a magic word in the cmd lines of background java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
# and jdb processes this script launches.  We can then do the right kind
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
# of ps cmds to find all these processes and kill them.  We do this by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
# trapping the completion of this script.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
# An associated problem is that our trap handler (cleanup) doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
# always get called when jtreg terminates a test.  This can leave tests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
# hanging but following tests should run ok because each test uses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
# unique names for the port and temp files (based on the PID returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
# by $$).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
# mks 6.2a on win 98 presents two problems:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
#   $! returns the PID as a negative number whereas ps returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
#      it in the form 0xFFF....  This means our trick of 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#      of using $! to get the PIDs of the jdb and debuggee processes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
#      doesn't work.  This will cause some error cases to fail
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#      with a jtreg timeout instead of failing more gracefully.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
#   There is no form of the ps command that will show the whole
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
#   cmd line.  Thus, the magic keyword trick doesn't work.  We
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
#   resort to just killing java.exe and jdb.exes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
# pid usage:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#   debuggeepid: used in jdb process to detect if debuggee has died.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
#                - waitForDebuggeeMsg: fail if debuggee is gone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
#   jdbpid:   dofail: used to detect if in main process or jdb process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
#             waitforfinish: quit if the jdb process is gone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
#killcmd=/bin/kill
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
killcmd=kill
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
# This can be increased if timing seems to be an issue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
sleep_seconds=1
37320
a802ccc88c30 8151887: com/sun/jdi/RedefineClearBreakpoint.sh failed with timeout
sla
parents: 32427
diff changeset
   134
if [ -n "$TIMEOUT_FACTOR" ] ; then
a802ccc88c30 8151887: com/sun/jdi/RedefineClearBreakpoint.sh failed with timeout
sla
parents: 32427
diff changeset
   135
  sleep_seconds=$(echo $TIMEOUT_FACTOR $sleep_seconds | awk '{printf "%d\n", int($1 * $2)}')
a802ccc88c30 8151887: com/sun/jdi/RedefineClearBreakpoint.sh failed with timeout
sla
parents: 32427
diff changeset
   136
fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
echo "ShellScaffold.sh: Version" >& 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
topPid=$$
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
# Be careful to echo to >& in these general functions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
# If they are called from the functions that are sending
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
# cmds to jdb, then stdout is redirected to jdb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
cleanup()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    if [ -r "$failFile" ] ; then
6119
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
   147
        ls -l "$failFile" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
   148
        echo "<cleanup:_begin_failFile_contents>" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
   149
        cat "$failFile" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
   150
        echo "<cleanup:_end_failFile_contents>" >&2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    # Kill all processes that have our special
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    # keyword in their cmd line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    killOrphans cleanup $jdbKeyword
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    killOrphans cleanup $debuggeeKeyword
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
# Kill all processes with $2 in their cmd lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
# Print a msg about this using $1 as the prefix
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
killOrphans()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    str=$2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    if [ -z "$isCygwin" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        toBeKilled=`$psCmd | $grep -v grep | $grep -i $str | awk '{print $1}' | tr '\n\r' '  '`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        # The cygwin ps command doesn't show the options passed to a cmd.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        # We will use jps to get the win PID of the command, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        # then use ps to find the cygwin pid to be killed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        # The form of a ps output line is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        # ^   ddddd    dddd    dddd    dddd.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        # where the 4th digits are the win pid and the first 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        # are the cygwin pid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if [ -r "$jdk/bin/$jstack" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            winPid=`$jdk/bin/jps -v | $grep -i $str | sed -e 's@ .*@@'`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            if [ ! -z "$winPid" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                # Here is a way to kill using a win cmd and the win PID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                #echo "$1: taskkill /F $winPid"  >& 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                #taskkill /F /PID $winPid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                toBeKilled=`$psCmd | $grep -v grep | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                            $grep '^ +[0-9]+ +[0-9]+ +[0-9]+ +'"$winPid" |\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                            awk '{print $1}' | tr '\n\r' '  '`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            # Well, too bad - we can't find what to kill.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            toBeKilled=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    if [ ! -z "$toBeKilled" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        echo "$1: kill -9 $toBeKilled"  >& 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        kill -9 $toBeKilled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    fi
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   196
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   198
# Returns 0 if $1 is the pid of a running process
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
findPid()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
{
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   201
    if [ -z "$1" ] ; then
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   202
        return 1
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   203
    fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   204
23881
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   205
    case "$osname" in
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   206
        SunOS | AIX)
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   207
            $psCmd | $grep '^ *'"$1 " > $devnull 2>&1
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   208
            res=$?
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   209
            ;;
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   210
        Windows* | CYGWIN*)
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   211
            # Don't use ps on cygwin since it sometimes misses
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   212
            # some processes (!).
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   213
            tasklist /NH | $grep " $1 " > $devnull 2>&1
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   214
            res=$?
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   215
            ;;
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   216
       *)
3954
19ed60dbd0b7 6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents: 2
diff changeset
   217
            #   Never use plain 'ps', which requires a "controlling terminal"
19ed60dbd0b7 6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents: 2
diff changeset
   218
            #     and will fail  with a "ps: no controlling terminal" error.
19ed60dbd0b7 6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents: 2
diff changeset
   219
            #     Running under 'rsh' will cause this ps error.
23881
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   220
            $psCmd -e | $grep '^ *'"$1 " > $devnull 2>&1
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   221
            res=$?
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   222
            ;;
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   223
    esac
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   224
    return $res
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
setup()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    failed=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    # This is used to tag each java and jdb cmd we issue so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    # we can kill them at the end of the run.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    orphanKeyword=HANGINGJAVA-$$
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    debuggeeKeyword=${orphanKeyword}_DEB
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    jdbKeyword=${orphanKeyword}_JDB
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    baseArgs=-D${debuggeeKeyword}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    if [ -z "$TESTCLASSES" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        echo "--Warning:  TESTCLASSES is not defined; using TESTCLASSES=."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        echo "  You should run: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        echo "    runregress $0 -no"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        echo "  or"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        echo "    (setenv TESTCLASSES .; $0 $*)"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        TESTCLASSES=.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    if [ ! -z "$TESTJAVA" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        jdk="$TESTJAVA"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    fi
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   251
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    ulimitCmd=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    osname=`uname -s`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    isCygwin=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    case "$osname" in
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   256
        Windows* | CYGWIN*)
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   257
            devnull=NUL
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   258
            case "$osname" in
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   259
                CYGWIN*)
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   260
                    isCygwin=1
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   261
                    devnull=/dev/null
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   262
                    ;;
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   263
            esac
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
28859
6c9e357aff59 8071464: Clear up SVC jdk/test/* JRE layout dependencies other than those on tools.jar
ykantser
parents: 26041
diff changeset
   265
            if [ -r $jdk/bin/dt_shmem.dll ] ; then
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   266
                transport=dt_shmem
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   267
                address=kkkk.$$
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   268
            else
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   269
                transport=dt_socket
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   270
                address=
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   271
            fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   272
            baseArgs="$baseArgs -XX:-ShowMessageBoxOnError"
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   273
            # jtreg puts \\s in TESTCLASSES and some uses, eg. echo
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   274
            # treat them as control chars on mks (eg \t is tab)
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   275
            # Oops; windows mks really seems to want this cat line
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   276
            # to start in column 1
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   277
            if [ -w "$SystemRoot" ] ; then
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   278
                tmpFile=$SystemRoot/tmp.$$
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   279
            elif [ -w "$SYSTEMROOT" ] ; then
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   280
                tmpFile=$SYSTEMROOT/tmp.$$
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   281
            else
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   282
                tmpFile=tmp.$$
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   283
            fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
cat <<EOF >$tmpFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
$TESTCLASSES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
EOF
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   287
            TESTCLASSES=`cat $tmpFile | sed -e 's@\\\\@/@g'`
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   288
            rm -f $tmpFile
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   289
            # on mks
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   290
            grep=egrep
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   291
            psCmd=ps
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   292
            jstack=jstack.exe
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   293
            ;;
22602
0d9a07b0d7e9 8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents: 21602
diff changeset
   294
       SunOS | Linux | Darwin | AIX)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
         transport=dt_socket
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
         address=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
         devnull=/dev/null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
         grep=egrep
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
         jstack=jstack
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
         # On linux, core files take a long time, and can leave
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
         # zombie processes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
         if [ "$osname" = SunOS ] ; then
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   303
             # Experiments show Solaris '/usr/ucb/ps -axwww' and
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   304
             # '/usr/bin/pgrep -f -l' provide the same small amount of the
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   305
             # argv string (PRARGSZ=80 in /usr/include/sys/procfs.h)
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   306
             #  1) This seems to have been working OK in ShellScaffold.
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   307
             #  2) OpenSolaris does not provide /usr/ucb/ps, so use pgrep
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   308
             #     instead
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   309
             # The alternative would be to use /usr/bin/pargs [pid] to get
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   310
             # all the args for a process, splice them back into one
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   311
             # long string, then grep.
4153
c019b5df1bf5 6893426: ShellScaffold.sh fails on Solaris 10 update releases: /usr/bin/id: illegal option -- u
tbell
parents: 3954
diff changeset
   312
             UU=`/usr/xpg4/bin/id -u -n`
3954
19ed60dbd0b7 6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents: 2
diff changeset
   313
             psCmd="pgrep -f -l -U $UU"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
         else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
             ulimit -c 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
             # See bug 6238593.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
             psCmd="ps axwww"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
         fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
         ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
       *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
         echo "--Error:  Unknown result from 'uname -s':  $osname"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
         exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
         ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    tmpFileDir=$TESTCLASSES/aa$$
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    TESTCLASSES=$tmpFileDir
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    mkdir -p $tmpFileDir
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    # This must not contain 'jdb' or it shows up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    # in grep of ps output for some platforms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    jdbOutFile=$tmpFileDir/jxdbOutput.txt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    rm -f $jdbOutFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    touch $jdbOutFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    debuggeeOutFile=$tmpFileDir/debuggeeOutput.txt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    failFile=$tmpFileDir/testFailed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    debuggeepidFile=$tmpFileDir/debuggeepid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    rm -f $failFile $debuggeepidFile
6119
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
   342
    if [ -f "$failFile" ]; then
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
   343
        echo "ERROR: unable to delete existing failFile:" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
   344
        ls -l "$failFile" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
   345
    fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    if [ -z "$pkg" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        pkgSlash=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        pkgDot=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        redefineSubdir=.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        pkgSlash=$pkg/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        pkgDot=$pkg.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        redefineSubdir=$pkgSlash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    if [ -z "$classname" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        classname=shtest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    if [ -z "$java" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        java=java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    if [ -z "$jdb" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        jdb=$jdk/bin/jdb
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
####################################################3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
####################################################3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
####################################################3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
####################################################3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
#  sol:  this gets all processes killed but 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
#        no jstack
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
#  linux same as above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
#  win mks:  No dice; processes still running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    trap "cleanup" 0 1 2 3 4 6 9 10 15
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   377
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    jdbOptions="$jdbOptions -J-D${jdbKeyword}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
docompile()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    if [ "$compile" = 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    saveDir=`pwd`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    cd $tmpFileDir
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    rm -f *.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    createJavaFile $classname
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    # Compile two versions of the file, the original and with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    # indicated lines modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    cp $classname.java.1 $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    echo "--Compiling first version of `pwd`/$classname.java with options: $compileOptions"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    # Result is in $pkgSlash$classname.class
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   396
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    if [ -z "$javacCmd" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        javacCmd=$jdk/bin/javac
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    echo "compiling " `ls *.java`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    $javacCmd $compileOptions -d . *.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    if [ $? != 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
       dofail "First compile failed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    if [ -r vers1 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        rm -rf vers1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    mkdir -p vers1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    mv *.class vers1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    if [ ! -z "$compileOptions2" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        if [ "$compileOptions2" = none ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            compileOptions=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            compileOptions=$compileOptions2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    while [ 1 = 1 ] ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        # Not really a loop; just a way to avoid goto
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        # by using breaks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        sed -e '/@1 *delete/ d' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            -e 's! *// *@1 *uncomment!     !' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            -e 's!\(.*@1 *commentout\)!//\1!' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            -e 's/@1 *newline/\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                 /' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            -e 's/.*@1 *replace//' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            $classname.java.1  >$classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        cmp -s $classname.java.1 $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        if [ $? = 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        echo 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        echo "--Compiling second version of `pwd`/$classname.java with $compileOptions"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        $javacCmd $compileOptions -d . $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        if [ $? != 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            dofail "Second compile failed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        if [ -r vers2 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            rm -rf vers2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        mkdir -p vers2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        mv *.class vers2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        mv $classname.java $classname.java.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        cp $classname.java.1 $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        ###### Do the same for @2, and @3 allowing 3 redefines to occur.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        ###### If I had more time to write sed cmds, I would do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        ###### this in a loop.  But, I don't think we will ever need
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        ###### more than 3 redefines.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        sed -e '/@2 *delete/ d' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            -e 's! *// *@2 *uncomment!     !' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            -e 's!\(.*@2 *commentout\)!//\1!' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            -e 's/@2 *newline/\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                 /' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            -e 's/.*@2 *replace//' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            $classname.java.2 >$classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        cmp -s $classname.java.2 $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        if [ $? = 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        echo 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        echo "--Compiling third version of `pwd`/$classname.java with $compileOptions"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        $javacCmd $compileOptions -d . $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        if [ $? != 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            dofail "Third compile failed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        if [ -r vers3 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            rm -rf vers3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        mkdir -p vers3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        mv *.class vers3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        mv $classname.java $classname.java.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        cp $classname.java.1 $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        ########
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        sed -e '/@3 *delete/ d' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            -e 's! *// *@3 *uncomment!     !' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            -e 's!\(.*@3 *commentout\)!//\1!' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            -e 's/@3 *newline/\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                    /' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            -e 's/.*@3 *replace//' \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            $classname.java.3 >$classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        cmp -s $classname.java.3 $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        if [ $? = 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        echo 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        echo "--Compiling fourth version of `pwd`/$classname.java with $compileOptions"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        $javacCmd $compileOptions -d . $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        if [ $? != 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            dofail "fourth compile failed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        if [ -r vers4 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            rm -rf vers4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        mkdir -p vers4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        mv *.class vers4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        mv $classname.java $classname.java.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        cp $classname.java.1 $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        fgrep @4 $classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        if [ $? = 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            echo "--Error: @4 and above are not yet allowed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    cp vers1/* $redefineSubdir
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    cd $saveDir
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
# Send a cmd to jdb and wait for the jdb prompt to appear.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
# We don't want to allow > as a prompt because if the debuggee
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
# runs for awhile after a command, jdb will show this prompt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
# but is not really ready to accept another command for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
# debuggee - ie, a cont in this state will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
# If it ever becomes necessary to send a jdb command before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
# a  main[10] form of prompt appears, then this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
# code will have to be modified.
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   522
#
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   523
# Specify $1 = allowExit to show that the command given
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   524
# allows JDB to exit
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   525
cmd()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
{
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   527
    allowExit=
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   528
    case "$1" in
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   529
        allowExit)
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   530
            allowExit="allowExit"
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   531
            shift
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   532
            ;;
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   533
        exitJdb)
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   534
            # Quit JDB only with this cmd() invocation
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   535
            echo "--Sending cmd: quit" >& 2
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   536
            echo quit
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   537
            echo "--Quit cmd was sent" >& 2
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   538
            # See 6562090. Maybe there is a way that the exit
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   539
            # can cause jdb to not get the quit.
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   540
            sleep 5
6119
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
   541
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   542
            # The exit code value here doesn't matter since this function
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   543
            # is called as part of a pipeline and it is not the last command
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   544
            # in the pipeline.
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   545
            exit 1
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   546
            ;;
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   547
    esac
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   548
    command=$*
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   549
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   550
    if [ -z "$command" ] ; then
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   551
        dofail "Command can't be a null string. Test failure"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    fi
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   553
    if [ "$command" = "quit" -o "$command" = "exit" ] ; then
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   554
        # We don't want the test to manually quit jdb,
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   555
        # we will do it in the end automatically
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   556
        dofail "It's not allowed to send quit or exit commands from the test"
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   557
    fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   558
    if [ -r "$failFile" ] ; then
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   559
        # failFile exists, it's better to finish execution
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   560
        dofinish "quit"
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   561
    fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   562
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    # $jdbOutFile always exists here and is non empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    # because after starting jdb, we waited 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    # for the prompt.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    fileSize=`wc -c $jdbOutFile | awk '{ print $1 }'`
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   567
    echo "--Sending cmd: " $command >&2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    # jjh: We have a few intermittent failures here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    # It is as if every so often, jdb doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    # get the first cmd that is sent to it here.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    # (actually, I have seen it get the first cmd ok,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    # but then not get some subsequent cmd).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    # It seems like jdb really doesn't get the cmd; jdb's response
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    # does not appear in the jxdboutput file. It contains:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    # main[1] 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    # The application has been disconnected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    # Is it possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    # that jdb got the cmd ok, but its response didn't make
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    # it to the jxdboutput file?  If so, why did 'The application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    # has been disconnected' make it?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    # This causes the following loop to timeout and the test to fail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    # The above echo works because the cmd (stop at ...)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    # is in the System.err shown in the .jtr file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    # Also, the cmd is shown in the 'jdb never responded ...'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    # msg output below after the timeout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    # And, we know jdb is started because the main[1] output is in the .jtr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    # file.  And, we wouldn't have gotten here if mydojdbcmds hadn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    # seen the ].  
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   592
    echo $command
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   594
    # Now we have to wait for the next jdb prompt.  We wait for a pattern
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   595
    # to appear in the last line of jdb output.  Normally, the prompt is
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   596
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   597
    # 1) ^main[89] @
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   598
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   599
    # where ^ means start of line, and @ means end of file with no end of line
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   600
    # and 89 is the current command counter. But we have complications e.g.,
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   601
    # the following jdb output can appear:
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   602
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   603
    # 2) a[89] = 10
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   604
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   605
    # The above form is an array assignment and not a prompt.
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   606
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   607
    # 3) ^main[89] main[89] ...
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   608
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   609
    # This occurs if the next cmd is one that causes no jdb output, e.g.,
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   610
    # 'trace methods'.
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   611
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   612
    # 4) ^main[89] [main[89]] .... > @
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   613
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   614
    # jdb prints a > as a prompt after something like a cont.
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   615
    # Thus, even though the above is the last 'line' in the file, it
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   616
    # isn't the next prompt we are waiting for after the cont completes.
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   617
    # HOWEVER, sometimes we see this for a cont command:
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   618
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   619
    #   ^main[89] $
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   620
    #      <lines output for hitting a bkpt>
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   621
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   622
    # 5) ^main[89] > @
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   623
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   624
    # i.e., the > prompt comes out AFTER the prompt we we need to wait for.
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   625
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   626
    # So, how do we know when the next prompt has appeared??
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   627
    # 1.  Search for 
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   628
    #         main[89] $
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   629
    #     This will handle cases 1, 2, 3
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   630
    # 2.  This leaves cases 4 and 5.
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   631
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   632
    # What if we wait for 4 more chars to appear and then search for
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   633
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   634
    #    main[89] [>]$
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   635
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   636
    # on the last line?
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   637
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   638
    # a.  if we are currently at
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   639
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   640
    #       ^main[89] main[89] @
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   641
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   642
    #     and a 'trace methods comes in, we will wait until at least
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   643
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   644
    #       ^main[89] main[89] main@
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   645
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   646
    #     and then the search will find the new prompt when it completes.
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   647
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   648
    # b.  if we are currently at
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   649
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   650
    #       ^main[89] main[89] @
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   651
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   652
    #     and the first form of cont comes in, then we will see
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   653
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   654
    #       ^main[89] main[89] > $
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   655
    #       ^x@
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   656
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   657
    #     where x is the first char of the msg output when the bkpt is hit
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   658
    #     and we will start our search, which will find the prompt
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   659
    #     when it comes out after the bkpt output, with or without the
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   660
    #     trailing >
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   661
    #
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   662
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   663
    # wait for 4 new chars to appear in the jdb output
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    count=0
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   665
    desiredFileSize=`expr $fileSize + 4`
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   666
    msg1=`echo At start: cmd/size/waiting : $command / $fileSize / \`date\``
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    while [ 1 = 1 ] ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        newFileSize=`wc -c $jdbOutFile | awk '{ print $1 } '`
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   669
        #echo jj: desired = $desiredFileSize, new = $newFileSize >& 2
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   670
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   671
        done=`expr $newFileSize \>= $desiredFileSize`
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   672
        if [ $done = 1 ] ; then
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        sleep ${sleep_seconds}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        count=`expr $count + 1`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        if [ $count = 30 -o $count = 60 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            # record some debug info.
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   679
            echo "--DEBUG: jdb $$ didn't responded to command in $count secs: $command" >& 2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            echo "--DEBUG:" $msg1 >& 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            echo "--DEBUG: "done size/waiting : / $newFileSize  / `date` >& 2
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   682
            echo "-- $jdbOutFile follows-------------------------------" >& 2
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   683
            cat $jdbOutFile >& 2
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   684
            echo "------------------------------------------" >& 2
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   685
            dojstack
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   686
            #$psCmd | sed -e '/com.sun.javatest/d' -e '/nsk/d' >& 2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            if [ $count = 60 ] ; then
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   688
                dofail "jdb never responded to command: $command"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    done
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   692
    # Note that this assumes just these chars in thread names.
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   693
    waitForJdbMsg '[a-zA-Z0-9_-][a-zA-Z0-9_-]*\[[1-9][0-9]*\] [ >]*$' 1 $allowExit
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
setBkpts()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    # Can set multiple bkpts, but only in one class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    # $1 is the bkpt name, eg, @1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    allLines=`$grep -n "$1 *breakpoint" $tmpFileDir/$classname.java.1 | sed -e 's@^\([0-9]*\).*@\1@g'`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    for ii in $allLines ; do
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   702
        cmd "stop at $pkgDot$classname:$ii"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
runToBkpt()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
{
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   708
    # Don't pass allowExit here as we don't want JDB to unexpectedly exit
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    cmd run
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   710
    # Don't need to do this - the above waits for the next prompt which comes out
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   711
    # AFTER the Breakpoint hit message.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    # Wait for jdb to hit the bkpt
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   713
    #waitForJdbMsg "Breakpoint hit" 5
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
contToBkpt()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
{
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   718
    # Don't pass allowExit here as we don't want JDB to unexpectedly exit
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    cmd cont
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   720
    # Don't need to do this - the above waits for the next prompt which comes out
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   721
    # AFTER the Breakpoint hit message.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    # Wait for jdb to hit the bkpt
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   723
    #waitForJdbMsg "Breakpoint hit" 5
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
# Wait until string $1 appears in the output file, within the last $2 lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
# If $3 is allowExit, then don't fail if jdb exits before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
# the desired string appears.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
waitForJdbMsg()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    # This can be called from the jdb thread which doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    # have access to $debuggeepid, so we have to read it from the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    nlines=$2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    allowExit="$3"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    myCount=0
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   737
    timeLimit=40  # wait a max of this many secs for a response from a jdb command
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    while [ 1 = 1 ] ; do 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        if [  -r $jdbOutFile ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
            # Something here causes jdb to complain about Unrecognized cmd on x86.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            tail -$nlines $jdbOutFile | $grep -s "$1" > $devnull 2>&1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
            if [ $? = 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                # Found desired string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
            fi
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   746
        fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   747
        tail -2 $jdbOutFile | $grep -s "The application exited" > $devnull 2>&1
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   748
        if [ $? = 0 ] ; then
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            # Found 'The application exited'
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   750
            echo "--JDB finished: The application exited" >&2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            if [ ! -z "$allowExit" ] ; then
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   752
                # Exit is allowed
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   753
                dofinish
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            # Otherwise, it is an error if we don't find $1
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   756
            if [  -r $jdbOutFile ] ; then 
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   757
                tail -$nlines $jdbOutFile | $grep -s "$1" > $devnull 2>&1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                if [ $? = 0 ] ; then
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   759
                    break
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   760
                fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   761
            fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   762
            dofail "JDB unexpectedly finished: Waited for jdb msg $1, but it never appeared"
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   763
        fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        sleep ${sleep_seconds}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        findPid $topPid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        if [ $? != 0 ] ; then
23881
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   768
            echo "--Top process ($topPid) is dead.  We better die too" >&2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            dojstack
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        myCount=`expr $myCount + ${sleep_seconds}`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        if [ $myCount -gt $timeLimit ] ; then
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   775
            echo "--Fail: waitForJdbMsg timed out after $timeLimit seconds, looking for /$1/, in $nlines lines; exitting" >> $failFile
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   776
            echo "vv jdbOutFile  vvvvvvvvvvvvvvvvvvvvvvvvvvvv" >& 2
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   777
            cat $jdbOutFile >& 2
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
   778
            echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" >& 2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            dojstack
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
            exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   786
# Finishes JDB execution
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   787
# Specify command to finish if it's needed
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   788
dofinish()
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   789
{
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   790
    if [ ! -z "$*" ] ; then
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   791
        echo "--Finish execution with sending \"$*\" command to JDB" >&2
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   792
        cmd "exitJdb" "$*"
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   793
    else
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   794
        echo "--Finish without sending \"quit\" command to JDB" >&2
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   795
    fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   796
    exit 0
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   797
}
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   798
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
# $1 is the string to print.  If $2 exists,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
# it is the name of a file to print, ie, the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
# of the file that contains the $1 string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
dofail()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    if [ ! -z "$jdbpid" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        # we are in the main process instead of the jdb process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        echo " " >> $failFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        echo "--Fail: main: $*" >> $failFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        # Kill the debuggee ; it could be hung so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        # we want to get rid of it as soon as possible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        killOrphans "killing debuggee" $debuggeeKeyword
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   812
        # Kill debugger, it could be hung
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   813
        killOrphans "killing debugger" $jdbKeyword
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        echo " "  >>$failFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        echo "--Fail: $*" >> $failFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    if [ ! -z "$2" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        echo  "---- contents of $2 follows -------" >> $failFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        cat "$2" >> $failFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        echo "---------------" >>$failFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   827
redefineClass()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    if [ -z "$1" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        vers=2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        vers=`echo $1 | sed -e 's/@//'`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        vers=`expr $vers + 1`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    fi
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   835
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   836
    cmd "redefine $pkgDot$classname $tmpFileDir/vers$vers/$classname.class"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    cp $tmpFileDir/$classname.java.$vers \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
       $tmpFileDir/$classname.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
mydojdbCmds()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
   # Wait for jdb to start before we start sending cmds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
   waitForJdbMsg ']' 1
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   846
   # Send commands from the test
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
   dojdbCmds
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   848
   # Finish jdb with quit command
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   849
   dofinish "quit"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
startJdb()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    if [ ! -r "$jdb" -a ! -r "$jdb.exe" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        dofail "$jdb does not exist"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    echo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    echo "--Starting jdb, address=$address"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    if [ -z "$address" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
       # Let jdb choose the port and write it to stdout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
       mydojdbCmds | $jdb $jdbOptions -listenany | tee $jdbOutFile &
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
       while [ 1 ] ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
           lastLine=`$grep 'Listening at address' $jdbOutFile`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
           if [ ! -z "$lastLine" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
               break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
           fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
           sleep 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
       done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
       # jjh: we got the address ok, and seemed to start the debuggee
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
       address=`echo $lastLine | sed -e 's@.*: *@@'`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
       mydojdbCmds | $jdb $jdbOptions -listen $address | tee $jdbOutFile &
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    #echo address = $address
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    # this gets the pid of tee, at least it does on solaris
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    jdbpid=$!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
    # This fails on linux because there is an entry for each thread in jdb
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    # so we get a list of numbers in jdbpid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    # jdbpid=`$psCmd | $grep -v grep | $grep ${orphanKeyword}_JDB | awk '{print $1}'  | tr '\n\r' '  '`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
startDebuggee()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
{
26041
ca1b8bdbe663 8055673: test/com/sun/jdi/ShellScaffold.sh does not honor -javaoption
sla
parents: 25217
diff changeset
   888
    args="$TESTVMOPTS $TESTJAVAOPTS"
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   889
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    if [ ! -z "$args" ] ; then
25217
2d687ea8608a 8048892: TEST_BUG: shell script tests need to be change to not use retired @debuggeeVMOptions mechanism
ykantser
parents: 23881
diff changeset
   891
       echo "--Starting debuggee with args from TESTVMOPTS and/or TESTJAVAOPTS: $args"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
       echo "--Starting debuggee"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    debuggeepid=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    waitForJdbMsg Listening 4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
23603
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   899
    beOption="-agentlib:jdwp=transport=$transport,address=$address,server=n,suspend=y" 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
#   beOption="-Xdebug -Xrunjdwp:transport=$transport,address=$address,server=n,suspend=y"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    thecmd="$jdk/bin/$java $mode -classpath $tmpFileDir $baseArgs $args \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
            -Djtreg.classDir=$TESTCLASSES \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            -showversion \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
             $beOption \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
             $pkgDot$classname"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    echo "Cmd: $thecmd"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    sh -c "$thecmd | tee $debuggeeOutFile" &
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    # Note that the java cmd and the tee cmd will be children of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    # the sh process.  We can use that to find them to kill them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    debuggeepid=$!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    # Save this in a place where the jdb process can find it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    # Note that it is possible for the java cmd to abort during startup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    # due to a bad classpath or whatever.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    echo $debuggeepid > $debuggeepidFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
dojstack()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    if [ -r "$jdk/bin/$jstack" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        # If jstack exists, so will jps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        # Show stack traces of jdb and debuggee as a possible debugging aid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
        jdbCmd=`$jdk/bin/jps -v | $grep $jdbKeyword`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        realJdbPid=`echo "$jdbCmd" | sed -e 's@ TTY.*@@'`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        if [ ! -z "$realJdbPid" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            echo "-- jdb process info ----------------------" >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
            echo "      $jdbCmd"                              >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            echo "-- jdb threads: jstack $realJdbPid"         >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            $jdk/bin/$jstack $realJdbPid                      >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            echo "------------------------------------------" >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
            echo                                              >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        debuggeeCmd=`$jdk/bin/jps -v | $grep $debuggeeKeyword`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        realDebuggeePid=`echo "$debuggeeCmd" | sed -e 's@ .*@@'`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        if [ ! -z "$realDebuggeePid" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            echo "-- debuggee process info ----------------------" >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
            echo "      $debuggeeCmd"                              >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            echo "-- debuggee threads: jstack $moption $realDebuggeePid" >&2
28859
6c9e357aff59 8071464: Clear up SVC jdk/test/* JRE layout dependencies other than those on tools.jar
ykantser
parents: 26041
diff changeset
   942
            $jdk/bin/$jstack $realDebuggeePid                      >&2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            echo "============================================="   >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
            echo                                                   >&2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
waitForFinish()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    # This is the main process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    # Wait for the jdb process to finish, or some error to occur
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    while [ 1 = 1 ] ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        findPid $jdbpid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        if [ $? != 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
            break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        fi
23603
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   959
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   960
        # (Don't use jdbFailIfPresent here since it is not safe 
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   961
        # to call from different processes)
23881
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   962
        $grep -s 'Input stream closed' $jdbOutFile > $devnull 2>&1
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   963
        if [ $? = 0 ] ; then
23603
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   964
            dofail "jdb input stream closed prematurely"
23881
f4fc1826e04a 8038963: com/sun/jdi tests fail because cygwin's ps sometimes misses processes
sla
parents: 23603
diff changeset
   965
        fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        # If a failure has occured, quit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        if [ -r "$failFile" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        sleep ${sleep_seconds}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
    done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   975
    # jdb exited because its input stream closed prematurely
23603
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   976
    # (Don't use jdbFailIfPresent here since it is not safe 
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   977
    # to call from different processes)
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   978
    $grep -s 'Input stream closed' $jdbOutFile > $devnull 2>&1
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   979
    if [ $? = 0 ] ; then
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   980
        dofail "jdb input stream closed prematurely"
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
   981
    fi
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   982
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   983
    # It is necessary here to avoid the situation when JDB exited but
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   984
    # mydojdbCmds() didn't finish because it waits for JDB message
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   985
    # in waitForJdbMsg(), at the same time main process will finish
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   986
    # the execution with no errors.
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   987
    # To avoid that, wait for spawned processes to finish
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   988
    case "$osname" in
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   989
        SunOS)
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   990
            # `wait` function doesn't work in Solaris shell as in bash,
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   991
            # so create replacement that finds mydojdbCmds() shell process
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   992
            # and waits for its finish
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   993
            cmdsPid=
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   994
            # get list of processes except main process with $topPid
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   995
            processes=`$psCmd | $grep -v "$grep" | $grep -v $topPid | awk '{print $1}'`
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   996
            for pid in $processes; do
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   997
                # for each process grep its full args string for test name $0
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   998
                # $0 contains full test name with path
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
   999
                pargs -l $pid 2>$devnull | $grep "$0" >$devnull 2>&1
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1000
                if [ $? = 0 ] ; then
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1001
                    cmdsPid=$pid
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1002
                    break
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1003
                fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1004
            done
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1005
            echo "--waitForFinish: Waiting for mydojdbCmds() to finish" >&2
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1006
            while [ 1 = 1 ] ; do
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1007
                findPid $cmdsPid
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1008
                if [ $? != 0 ] ; then
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1009
                    break
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1010
                fi
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1011
                sleep ${sleep_seconds}
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1012
            done
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1013
            ;;
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1014
        *)
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1015
            echo "--waitForFinish: Waiting for all processes to finish" >&2
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1016
            wait
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1017
            ;;
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1018
    esac
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1019
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
    if [ -r "$failFile" ] ; then
6119
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1021
        ls -l "$failFile" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1022
        echo "<waitForFinish:_begin_failFile_contents>" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1023
        cat "$failFile" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1024
        echo "<waitForFinish:_end_failFile_contents>" >&2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
# $1 is the filename, $2 is the string to look for,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
# $3 is the number of lines to search (from the end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
grepForString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
    if [ -z "$3" ] ; then
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
  1034
        theCmd=cat
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
    else
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
  1036
        theCmd="tail -$3"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    fi
6119
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1038
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
  1039
    case "$2" in 
6119
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1040
    *\>*)
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1041
        # Target string contains a '>' so we better not ignore it
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
  1042
        $theCmd $1 | $grep -s "$2"  > $devnull 2>&1
6119
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1043
        stat="$?"
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
  1044
        ;;
6119
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1045
    *)
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1046
        # Target string does not contain a '>'.
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1047
        # NOTE:  if $1 does not end with a new line, piping it to sed
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1048
        # doesn't include the chars on the last line.  Detect this
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1049
        # case, and add a new line.
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1050
        theFile="$1"
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1051
        if [ `tail -1 "$theFile" | wc -l | sed -e 's@ @@g'` = 0 ] ; then
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1052
            # The target file doesn't end with a new line so we have
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1053
            # add one to a copy of the target file so the sed command
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1054
            # below can filter that last line.
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1055
            cp "$theFile" "$theFile.tmp"
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1056
            theFile="$theFile.tmp"
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1057
            echo >> "$theFile"
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1058
        fi
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1059
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1060
        # See bug 6220903. Sometimes the jdb prompt chars ('> ') can
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1061
        # get interleaved in the target file which can keep us from
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1062
        # matching the target string.
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1063
        $theCmd "$theFile" | sed -e 's@> @@g' -e 's@>@@g' \
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1064
            | $grep -s "$2" > $devnull 2>&1
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1065
        stat=$?
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1066
        if [ "$theFile" != "$1" ]; then
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1067
            # remove the copy of the target file
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1068
            rm -f "$theFile"
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1069
        fi
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1070
        unset theFile
4325
38a035021ba1 6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents: 4153
diff changeset
  1071
    esac
23603
c561991073ad 8037345: com/sun/jdi/* tests can fail, with race condition on log files
sla
parents: 23046
diff changeset
  1072
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
    return $stat
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
21602
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1076
# $1 is the filename, $2 is the regexp to match and return,
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1077
# $3 is the number of lines to search (from the end)
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1078
matchRegexp()
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1079
{
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1080
    if [ -z "$3" ] ; then
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1081
        theCmd=cat
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1082
    else
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1083
        theCmd="tail -$3"
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1084
    fi
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1085
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1086
    case "$2" in 
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1087
    *\>*)
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1088
        # Target string contains a '>' so we better not ignore it
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1089
        res=`$theCmd $1 | sed -e "$2"`
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1090
        ;;
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1091
    *)
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1092
        # Target string does not contain a '>'.
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1093
        # NOTE:  if $1 does not end with a new line, piping it to sed
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1094
        # doesn't include the chars on the last line.  Detect this
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1095
        # case, and add a new line.
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1096
        theFile="$1"
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1097
        if [ `tail -1 "$theFile" | wc -l | sed -e 's@ @@g'` = 0 ] ; then
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1098
            # The target file doesn't end with a new line so we have
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1099
            # add one to a copy of the target file so the sed command
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1100
            # below can filter that last line.
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1101
            cp "$theFile" "$theFile.tmp"
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1102
            theFile="$theFile.tmp"
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1103
            echo >> "$theFile"
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1104
        fi
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1105
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1106
        # See bug 6220903. Sometimes the jdb prompt chars ('> ') can
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1107
        # get interleaved in the target file which can keep us from
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1108
        # matching the target string.
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1109
        res=`$theCmd "$theFile" | sed -e 's@> @@g' -e 's@>@@g' \
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1110
            | sed -e "$2"`
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1111
        if [ "$theFile" != "$1" ]; then
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1112
            # remove the copy of the target file
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1113
            rm -f "$theFile"
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1114
        fi
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1115
        unset theFile
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1116
    esac
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1117
    return $res
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1118
}
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1119
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
# $1 is the filename, $2 is the string to look for,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
# $3 is the number of lines to search (from the end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
failIfPresent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
    if [ -r "$1" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
        grepForString "$1" "$2" "$3"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        if [ $? = 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
            dofail "Error output found: \"$2\" in $1" $1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
# $1 is the filename, $2 is the string to look for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
# $3 is the number of lines to search (from the end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
failIfNotPresent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
    if [ ! -r "$1" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
        dofail "Required output \"$2\" not found in $1"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
    grepForString "$1" "$2" "$3"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
    if [ $? != 0 ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        dofail "Required output \"$2\" not found in $1" $1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
# fail if $1 is not in the jdb output
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
# $2 is the number of lines to search (from the end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
jdbFailIfNotPresent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
    failIfNotPresent $jdbOutFile "$1" $2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
# fail if $1 is not in the debuggee output
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
# $2 is the number of lines to search (from the end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
debuggeeFailIfNotPresent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    failIfNotPresent $debuggeeOutFile "$1" $2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
# fail if $1 is in the jdb output
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
# $2 is the number of lines to search (from the end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
jdbFailIfPresent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
    failIfPresent $jdbOutFile "$1" $2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
# fail if $1 is in the debuggee output
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
# $2 is the number of lines to search (from the end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
debuggeeFailIfPresent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
    failIfPresent $debuggeeOutFile "$1" $2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
21602
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1174
# match and return the output from the regexp $1 in the debuggee output
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1175
# $2 is the number of lines to search (from the end)
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1176
debuggeeMatchRegexp()
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1177
{
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1178
    matchRegexp $debuggeeOutFile "$1" $2
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1179
}
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1180
85bdffaf5e5d 8027705: com/sun/jdi/JdbMethodExitTest.sh fails when a background thread is generating events.
sla
parents: 14342
diff changeset
  1181
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
# This should really be named 'done' instead of pass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
pass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
    if [ ! -r "$failFile" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
        echo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        echo "--Done: test passed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
        exit 0
6119
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1189
    else
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1190
        ls -l "$failFile" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1191
        echo "<pass:_begin_failFile_contents>" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1192
        cat "$failFile" >&2
296bbd35a3f4 6962804: 4/4 ShellScaffold tests can fail without a specific reason
dcubed
parents: 5506
diff changeset
  1193
        echo "<pass:_end_failFile_contents>" >&2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
runit()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
    setup
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    docompile
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 22602
diff changeset
  1201
    startJdb
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
    startDebuggee
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    waitForFinish
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
    # in hs_err file from 1.3.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
    debuggeeFailIfPresent "Virtual Machine Error"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
    # in hs_err file from 1.4.2, 1.5:  An unexpected error
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    debuggeeFailIfPresent "An unexpected error"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    # in hs_err file from 1.4.2, 1.5:  Internal error
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
    debuggeeFailIfPresent "Internal error"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
    # Don't know how this arises
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
    debuggeeFailIfPresent "An unexpected exception"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
    # Don't know how this arises
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    debuggeeFailIfPresent "Internal exception"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
}