test/jdk/com/sun/jdi/CatchPatternTest.sh
author amenkov
Fri, 21 Sep 2018 11:28:14 -0700
changeset 51837 46ca82c15f6c
parent 47216 71c04702a3d5
permissions -rw-r--r--
8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4 Reviewed-by: jcbeyler, sspitsyn, cjplummer
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
#
45028
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 40468
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: 2
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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
#  @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#  @bug 4671838
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#  @summary TTY: surprising ExceptionSpec.resolveEventRequest() wildcard results
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#  @author Tim Bell
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#
32018
91c91b3d50a0 8132094: Mark intermittently failuring core-svc tests
ykantser
parents: 31909
diff changeset
    31
#  @key intermittent
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#  @run shell CatchPatternTest.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
classname=CatchPatternTestTarg
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
createJavaFile()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    cat <<EOF > $classname.java.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
public class $classname {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    public void bark(int i) {
23057
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    39
        System.out.println(" bark: " + i);
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    40
        switch (i) {
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    41
        case 0:
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    42
            throw new IllegalArgumentException("IllegalArgumentException");
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    43
        case 1:
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    44
            throw new ArithmeticException("ArithmeticException");
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    45
        case 2:
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    46
            throw new IllegalMonitorStateException("IllegalMonitorStateException");
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    47
        case 3:
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    48
            throw new IndexOutOfBoundsException("IndexOutOfBoundsException");
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    49
        default:
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    50
            throw new Error("should not happen");
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    51
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public void loop(int max) {
23057
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    54
        for (int i = 0; i <= max; i++) {
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    55
            try {
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    56
                bark(i);
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    57
            } catch(RuntimeException re) {
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    58
                System.out.println(" loop: " + re.getMessage() +
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    59
                       " caught and ignored.");
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    60
            }
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    61
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public void partOne() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        loop(2);
23057
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    65
        System.out.println("partOne completed");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public void partTwo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        loop(3);
23057
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    69
        System.out.println("partTwo completed");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public static void main(String[] args) {
23057
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    72
        System.out.println("Howdy!");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        $classname my = new $classname();
23057
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    74
        my.partOne();
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    75
        my.partTwo();
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    76
        System.out.println("Goodbye from $classname!");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
# This is called to feed cmds to jdb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
dojdbCmds()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
   #set -x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
   cmd stop in ${classname}.main
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
   cmd stop in ${classname}.partTwo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
   runToBkpt
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   cmd ignore uncaught java.lang.Throwable
40468
ae9bae97a312 8164012: com/sun/jdi/CatchPatternTest.sh fails on jdk9/hs with Required output "Exception occurred: java.lang.IllegalMonitorStateException" not found
sla
parents: 32018
diff changeset
    90
   # Instead of matching java.lang.I* we use two more specific
ae9bae97a312 8164012: com/sun/jdi/CatchPatternTest.sh fails on jdk9/hs with Required output "Exception occurred: java.lang.IllegalMonitorStateException" not found
sla
parents: 32018
diff changeset
    91
   # patterns here. The reason is to avoid matching IncompatibleClassChangeError
ae9bae97a312 8164012: com/sun/jdi/CatchPatternTest.sh fails on jdk9/hs with Required output "Exception occurred: java.lang.IllegalMonitorStateException" not found
sla
parents: 32018
diff changeset
    92
   # (or the subclass NoSuchMethodError) thrown by the
ae9bae97a312 8164012: com/sun/jdi/CatchPatternTest.sh fails on jdk9/hs with Required output "Exception occurred: java.lang.IllegalMonitorStateException" not found
sla
parents: 32018
diff changeset
    93
   # java.lang.invoke infrastructure.
ae9bae97a312 8164012: com/sun/jdi/CatchPatternTest.sh fails on jdk9/hs with Required output "Exception occurred: java.lang.IllegalMonitorStateException" not found
sla
parents: 32018
diff changeset
    94
   cmd catch all java.lang.Il*
ae9bae97a312 8164012: com/sun/jdi/CatchPatternTest.sh fails on jdk9/hs with Required output "Exception occurred: java.lang.IllegalMonitorStateException" not found
sla
parents: 32018
diff changeset
    95
   cmd catch all java.lang.Ind*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
   cmd cont
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
   cmd cont
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
   cmd cont
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
   cmd ignore all java.lang.I*
23046
0b0407b1e2a5 6946101: ShellScaffold.sh based tests can issue "write error: Broken pipe" messages
iignatyev
parents: 5506
diff changeset
   100
   cmd allowExit cont
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
mysetup()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    if [ -z "$TESTSRC" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        TESTSRC=.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    for ii in . $TESTSRC $TESTSRC/.. ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        if [ -r "$ii/ShellScaffold.sh" ] ; then
45028
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 40468
diff changeset
   111
            . $ii/ShellScaffold.sh
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
# You could replace this next line with the contents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
# of ShellScaffold.sh and this script will run just the same.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
mysetup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
runit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
jdbFailIfNotPresent "Exception occurred: java.lang.IllegalArgumentException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
jdbFailIfNotPresent "Exception occurred: java.lang.IllegalMonitorStateException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
jdbFailIfPresent "Exception occurred: ArithmeticException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
jdbFailIfPresent "Exception occurred: IndexOutOfBoundsException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
jdbFailIfPresent "Exception occurred: IllegalStateException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
jdbFailIfPresent "should not happen"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
debuggeeFailIfNotPresent "partOne completed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
debuggeeFailIfNotPresent "partTwo completed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
pass