Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/resume/resume002/resume002.java
40951 views
/*1* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/222324/*25* @test26*27* @summary converted from VM Testbase nsk/jdb/resume/resume002.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* This is a test for jdb 'resume all' and 'resume <thread id>' commands.32* The debuggee starts 5 'MyThreads' that are all suspended on the lock33* that the main thread holds. The the test driver issues the following34* commands for check:35* - 'suspend all' : "All threads suspended" message is expected in36* jdb output stream;37* - 'resume all' : "All threads resumed" message is expected in38* jdb output stream;39* - 'suspend <thread_id>' for each 'MyThread';40* - 'resume <thread_id>' for each 'MyThread'.41* The test consists of two parts:42* resume002.java - test driver, i.e. launches jdb and debuggee,43* writes commands to jdb, reads the jdb output,44* resume002a.java - the debugged application.45* COMMENTS46* This test functionally equals to nsk/jdb/resume/resume001 test47* and replaces it.48*49* @library /vmTestbase50* /test/lib51* @build nsk.jdb.resume.resume002.resume002a52* @run main/othervm53* nsk.jdb.resume.resume002.resume00254* -arch=${os.family}-${os.simpleArch}55* -waittime=556* -debugee.vmkind=java57* -transport.address=dynamic58* -jdb=${test.jdk}/bin/jdb59* -java.options="${test.vm.opts} ${test.java.opts}"60* -workdir=.61* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"62*/6364package nsk.jdb.resume.resume002;6566import nsk.share.*;67import nsk.share.jdb.*;6869import java.io.*;70import java.util.*;7172public class resume002 extends JdbTest {7374public static void main (String argv[]) {75System.exit(run(argv, System.out) + JCK_STATUS_BASE);76}7778public static int run(String argv[], PrintStream out) {79debuggeeClass = DEBUGGEE_CLASS;80firstBreak = FIRST_BREAK;81lastBreak = LAST_BREAK;82return new resume002().runTest(argv, out);83}8485static final String PACKAGE_NAME = "nsk.jdb.resume.resume002";86static final String TEST_CLASS = PACKAGE_NAME + ".resume002";87static final String DEBUGGEE_CLASS = TEST_CLASS + "a";88static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";89static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";9091static final String THREAD_NAME = "MyThread";9293protected void runCases() {94String[] reply;95Paragrep grep;96int count;97Vector v;98String found;99100jdb.setBreakpointInMethod(LAST_BREAK);101jdb.receiveReplyFor(JdbCommand.cont);102103String[] threadIds = jdb.getThreadIds(PACKAGE_NAME + "." + THREAD_NAME);104105reply = jdb.receiveReplyFor(JdbCommand.suspend);106grep = new Paragrep(reply);107if (grep.find("All threads suspended") == 0) {108failure("jdb cannot suspend all threads");109}110reply = jdb.receiveReplyFor(JdbCommand.resume, false);111grep = new Paragrep(reply);112if (grep.find("All threads resumed") == 0) {113failure("jdb cannot resume all threads");114}115116jdb.receiveReplyFor(JdbCommand.thread + threadIds[0]);117118for (int i = 0; i < resume002a.numThreads; i++) {119jdb.receiveReplyFor(JdbCommand.suspend + threadIds[i]);120jdb.receiveReplyFor(JdbCommand.resume + threadIds[i]);121}122123jdb.contToExit(1);124}125}126127128