Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/threads/threads002/threads002.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/threads/threads002.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* This is a test for jdb 'threads' command.32* The debugee starts 5 'MyThreads' that are all suspended on the lock33* that the main thread posseses. The 'threads' command is issued34* at this point. The test passes if 5 suspended 'MyThreads' are reported.35* COMMENTS36* This test functionally equals to nsk/jdb/threads/threads001 test37* and replaces it.38*39* @library /vmTestbase40* /test/lib41* @build nsk.jdb.threads.threads002.threads002a42* @run main/othervm43* nsk.jdb.threads.threads002.threads00244* -arch=${os.family}-${os.simpleArch}45* -waittime=546* -debugee.vmkind=java47* -transport.address=dynamic48* -jdb=${test.jdk}/bin/jdb49* -java.options="${test.vm.opts} ${test.java.opts}"50* -workdir=.51* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"52*/5354package nsk.jdb.threads.threads002;5556import nsk.share.*;57import nsk.share.jdb.*;5859import java.io.*;60import java.util.*;6162public class threads002 extends JdbTest {6364public static void main (String argv[]) {65System.exit(run(argv, System.out) + JCK_STATUS_BASE);66}6768public static int run(String argv[], PrintStream out) {69debuggeeClass = DEBUGGEE_CLASS;70firstBreak = FIRST_BREAK;71lastBreak = LAST_BREAK;72return new threads002().runTest(argv, out);73}7475static final String PACKAGE_NAME = "nsk.jdb.threads.threads002";76static final String TEST_CLASS = PACKAGE_NAME + ".threads002";77static final String DEBUGGEE_CLASS = TEST_CLASS + "a";78static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";79static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";8081static final String THREAD_NAME = PACKAGE_NAME + ".MyThread";8283protected void runCases() {84String[] reply;85Paragrep grep;86int count;87Vector v;88String found;8990jdb.setBreakpointInMethod(LAST_BREAK);91jdb.receiveReplyFor(JdbCommand.cont);9293reply = jdb.receiveReplyFor(JdbCommand.threads);94grep = new Paragrep(reply);95count = grep.find(THREAD_NAME);96if (count != threads002a.numThreads ) {97failure("Unexpected number of " + THREAD_NAME + " was listed: " + count +98"\n\texpected value: " + threads002a.numThreads);99}100101jdb.contToExit(1);102}103}104105106