test/hotspot/jtreg/vmTestbase/nsk/jdb/down/down002/down002.java
changeset 50220 31361382634b
equal deleted inserted replaced
50219:4ab066d71956 50220:31361382634b
       
     1 /*
       
     2  * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 
       
    25 /*
       
    26  * @test
       
    27  *
       
    28  * @summary converted from VM Testbase nsk/jdb/down/down002.
       
    29  * VM Testbase keywords: [jpda, jdb]
       
    30  * VM Testbase readme:
       
    31  * DECSRIPTION
       
    32  *  This tests the jdb 'down' command. The test sets a breakpoint
       
    33  *  at 'func5' method in debugged 'nsk.jdb.down.down002a' class and then
       
    34  *  runs the debugee.  Once, an execution suspends at 'func5' method,
       
    35  *  the 'down' command is issued to the debugger several times.
       
    36  *  The output is processed by counting the number of times
       
    37  *  each method name appears in the stack trace. The test passes
       
    38  *  if the obtained count matches the expected one.
       
    39  * COMMENTS
       
    40  *  This test functionally equals to nsk/jdb/down/down001 test and
       
    41  *  replaces it.
       
    42  *
       
    43  * @library /vmTestbase
       
    44  *          /test/lib
       
    45  * @run driver jdk.test.lib.FileInstaller . .
       
    46  * @build nsk.jdb.down.down002.down002
       
    47  *        nsk.jdb.down.down002.down002a
       
    48  * @run main/othervm PropertyResolvingWrapper nsk.jdb.down.down002.down002
       
    49  *      -arch=${os.family}-${os.simpleArch}
       
    50  *      -waittime=5
       
    51  *      -debugee.vmkind=java
       
    52  *      -transport.address=dynamic
       
    53  *      -jdb=${test.jdk}/bin/jdb
       
    54  *      -java.options="${test.vm.opts} ${test.java.opts}"
       
    55  *      -workdir=.
       
    56  *      -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
       
    57  */
       
    58 
       
    59 package nsk.jdb.down.down002;
       
    60 
       
    61 import nsk.share.*;
       
    62 import nsk.share.jdb.*;
       
    63 
       
    64 import java.io.*;
       
    65 import java.util.*;
       
    66 
       
    67 public class down002 extends JdbTest {
       
    68 
       
    69     public static void main (String argv[]) {
       
    70         System.exit(run(argv, System.out) + JCK_STATUS_BASE);
       
    71     }
       
    72 
       
    73     public static int run(String argv[], PrintStream out) {
       
    74         debuggeeClass =  DEBUGGEE_CLASS;
       
    75         firstBreak = FIRST_BREAK;
       
    76         lastBreak = LAST_BREAK;
       
    77         return new down002().runTest(argv, out);
       
    78     }
       
    79 
       
    80     static final String PACKAGE_NAME     = "nsk.jdb.down.down002";
       
    81     static final String TEST_CLASS       = PACKAGE_NAME + ".down002";
       
    82     static final String DEBUGGEE_CLASS   = TEST_CLASS + "a";
       
    83     static final String FIRST_BREAK      = DEBUGGEE_CLASS + ".main";
       
    84     static final String LAST_BREAK       = DEBUGGEE_CLASS + ".lastBreak";
       
    85 
       
    86     static final String[][] FRAMES = new String[][] {
       
    87         {"[1]", DEBUGGEE_CLASS + ".func5"},
       
    88         {"[2]", DEBUGGEE_CLASS + ".func4"},
       
    89         {"[3]", DEBUGGEE_CLASS + ".func3"},
       
    90         {"[4]", DEBUGGEE_CLASS + ".func2"},
       
    91         {"[5]", DEBUGGEE_CLASS + ".func1"},
       
    92         {"[6]", DEBUGGEE_CLASS + ".runIt"},
       
    93         {"[7]", DEBUGGEE_CLASS + ".main"}
       
    94                                                 };
       
    95 
       
    96     protected void runCases() {
       
    97         String[] reply;
       
    98         Paragrep grep;
       
    99         int count;
       
   100         Vector v;
       
   101         String found;
       
   102 
       
   103         jdb.receiveReplyFor(JdbCommand.stop_in + DEBUGGEE_CLASS + ".func5");
       
   104         jdb.receiveReplyFor(JdbCommand.cont);
       
   105 
       
   106         for (int i = 0; i < (FRAMES.length-1); i++) {
       
   107             jdb.receiveReplyFor(JdbCommand.up);
       
   108         }
       
   109 
       
   110         for (int i = 0; i < (FRAMES.length-1); i++) {
       
   111             jdb.receiveReplyFor(JdbCommand.down);
       
   112             jdb.receiveReplyFor(JdbCommand.where);
       
   113         }
       
   114 
       
   115         jdb.contToExit(1);
       
   116 
       
   117         reply = jdb.getTotalReply();
       
   118         grep = new Paragrep(reply);
       
   119 
       
   120         for (int i = 1; i < (FRAMES.length-1); i++) {
       
   121             v = new Vector();
       
   122             v.add(FRAMES[i][0]);
       
   123             v.add(FRAMES[i][1]);
       
   124             count = grep.find(v);
       
   125             if (count != (i+1)) {
       
   126                 failure("Unexpected number of the stack frame: " + FRAMES[i][1] +
       
   127                     "\n\texpected value : " + (i+1) + ", got : " + count);
       
   128             }
       
   129         }
       
   130 
       
   131     }
       
   132 
       
   133 }