test/hotspot/jtreg/vmTestbase/nsk/jdb/options/connect/connect005/connect005.java
changeset 50220 31361382634b
equal deleted inserted replaced
50219:4ab066d71956 50220:31361382634b
       
     1 /*
       
     2  * Copyright (c) 2004, 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/options/connect/connect005.
       
    29  * VM Testbase keywords: [quick, jpda, jdb]
       
    30  * VM Testbase readme:
       
    31  * DESCRIPTION
       
    32  *  This is a test for '-connect' option with 'com.sun.jdi.SharedMemoryListen"
       
    33  *  connector.
       
    34  *  Jdb is started with particular connector argument.
       
    35  *  The 'run' command is issued in the superclass of test driver class.
       
    36  *  The test is passed if "run nsk.jdb.options.connect.connect005a" string
       
    37  *  is found in jdb's output stream:
       
    38  *  The test consists of two parts:
       
    39  *   connect005.java  - test driver, i.e. launches jdb and debuggee,
       
    40  *                  writes commands to jdb, reads the jdb output,
       
    41  *   connect005a.java - the debugged application.
       
    42  * COMMENTS
       
    43  *  The test is similar to nsk/jdb/run/run002, but uses particular connector
       
    44  *  overriding settings in ini-file.
       
    45  *
       
    46  * @library /vmTestbase
       
    47  *          /test/lib
       
    48  * @run driver jdk.test.lib.FileInstaller . .
       
    49  * @build nsk.jdb.options.connect.connect005.connect005
       
    50  *        nsk.jdb.options.connect.connect005.connect005a
       
    51  * @run main/othervm PropertyResolvingWrapper nsk.jdb.options.connect.connect005.connect005
       
    52  *      -arch=${os.family}-${os.simpleArch}
       
    53  *      -waittime=5
       
    54  *      -debugee.vmkind=java
       
    55  *      -transport.address=dynamic
       
    56  *      -connector=listening
       
    57  *      -transport=shmem
       
    58  *      -jdb=${test.jdk}/bin/jdb
       
    59  *      -java.options="${test.vm.opts} ${test.java.opts}"
       
    60  *      -workdir=.
       
    61  *      -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
       
    62  */
       
    63 
       
    64 package nsk.jdb.options.connect.connect005;
       
    65 
       
    66 import nsk.share.*;
       
    67 import nsk.share.jdb.*;
       
    68 
       
    69 import java.io.*;
       
    70 import java.util.*;
       
    71 
       
    72 public class connect005 extends JdbTest {
       
    73 
       
    74     public static void main (String argv[]) {
       
    75         System.exit(run(argv, System.out) + JCK_STATUS_BASE);
       
    76     }
       
    77 
       
    78     public static int run(String argv[], PrintStream out) {
       
    79         debuggeeClass =  DEBUGGEE_CLASS;
       
    80         firstBreak = FIRST_BREAK;
       
    81         lastBreak = LAST_BREAK;
       
    82         return new connect005().runTest(argv, out);
       
    83     }
       
    84 
       
    85     static final String PACKAGE_NAME = "nsk.jdb.options.connect.connect005";
       
    86     static final String TEST_CLASS = PACKAGE_NAME + ".connect005";
       
    87     static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
       
    88     static final String FIRST_BREAK        = DEBUGGEE_CLASS + ".main";
       
    89     static final String LAST_BREAK         = DEBUGGEE_CLASS + ".lastBreak";
       
    90 
       
    91     protected boolean shouldPass() {
       
    92         String feature = "com.sun.jdi.SharedMemoryListen";
       
    93         if (argumentHandler.shouldPass(feature)) {
       
    94             log.println("Test passes because of not implemented feature: " + feature);
       
    95             return true;
       
    96         }
       
    97         return super.shouldPass();
       
    98     }
       
    99 
       
   100     protected void runCases() {
       
   101         String[] reply;
       
   102         Paragrep grep;
       
   103         int count;
       
   104         Vector v;
       
   105         String found;
       
   106 
       
   107         jdb.contToExit(1);
       
   108 
       
   109         if (argumentHandler.isLaunchingConnector()) {
       
   110             reply = jdb.getTotalReply();
       
   111             grep = new Paragrep(reply);
       
   112             v = new Vector();
       
   113             v.add(JdbCommand.run);
       
   114             v.add(DEBUGGEE_CLASS);
       
   115             if (grep.find(v) != 1) {
       
   116                 failure("jdb failed to run debugged application.");
       
   117             }
       
   118         }
       
   119     }
       
   120 }