Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/locals/locals002/locals002.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/locals/locals002.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DESCRIPTION31* This is a test for the 'locals' command.32* The test sets breakpoints in 'allKindsOfLocals' and 'allKindsOfArgs'33* methods of debugged 'locals002a' class. Once the debuggee is34* suspended in method, the test via 'locals' command compares35* the values of all visible variables with expected ones.36* The test consists of two parts:37* locals002.java - test driver, i.e. launches jdb and debuggee,38* writes commands to jdb, reads the jdb output,39* locals002a.java - the debugged application.40* COMMENTS41* The test functionally equals to nsk/jdb/locals/locals001 test42* and replaces it.43* Test fixed according to test bug:44* 5045859 TEST_BUG: some JDB tests do not recognize JDB prompt45*46* @library /vmTestbase47* /test/lib48* @build nsk.jdb.locals.locals002.locals00249*50* @comment make sure locals002a is compiled w/ full debug info51* @clean nsk.jdb.locals.locals002.locals002a52* @compile -g:lines,source,vars locals002a.java53*54* @run main/othervm55* nsk.jdb.locals.locals002.locals00256* -arch=${os.family}-${os.simpleArch}57* -waittime=558* -debugee.vmkind=java59* -transport.address=dynamic60* -jdb=${test.jdk}/bin/jdb61* -java.options="${test.vm.opts} ${test.java.opts}"62* -workdir=.63* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"64*/6566package nsk.jdb.locals.locals002;6768import nsk.share.*;69import nsk.share.jdb.*;7071import java.io.*;72import java.util.*;7374public class locals002 extends JdbTest {7576public static void main (String argv[]) {77System.exit(run(argv, System.out) + JCK_STATUS_BASE);78}7980public static int run(String argv[], PrintStream out) {81debuggeeClass = DEBUGGEE_CLASS;82firstBreak = FIRST_BREAK;83lastBreak = LAST_BREAK;84compoundPromptIdent = COMPOUND_PROMPT_IDENT;85return new locals002().runTest(argv, out);86}8788static final String PACKAGE_NAME = "nsk.jdb.locals.locals002";89static final String TEST_CLASS = PACKAGE_NAME + ".locals002";90static final String DEBUGGEE_CLASS = TEST_CLASS + "a";91static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";92static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";93static final String COMPOUND_PROMPT_IDENT = "main";94static final int BREAKPOINT_LINE1 = 84;95static final int BREAKPOINT_LINE2 = 100;9697static final String LOCALS[][] = new String[][] {98{ "boolVar" , "true" , "false" },99{ "byteVar" , "27" , "12" },100{ "charVar" , "V" , "A" },101{ "shortVar" , "767" , "327" },102{ "intVar" , "1474" , "3647" },103{ "longVar" , "21345" , "65789" },104{ "floatVar" , "3.141" , "4.852" },105{ "doubleVar", "2.578" , "3.8976" },106{ "objVar" , "objVarString" , "objArgString" },107{ "arrVar" , "int[5]" , "int[3]" }108109};110111protected void runCases() {112String[] reply;113Paragrep grep;114int count;115Vector v;116String found;117118jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + BREAKPOINT_LINE1);119jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + BREAKPOINT_LINE2);120121jdb.receiveReplyFor(JdbCommand.cont);122reply = jdb.receiveReplyFor(JdbCommand.locals);123grep = new Paragrep(reply);124for (int i = 0; i < LOCALS.length; i++) {125v = new Vector();126v.add(LOCALS[i][0]);127v.add(LOCALS[i][2]);128if (grep.find(v) == 0) {129failure("Cannot find " + LOCALS[0][0] +130" with expected value: " + LOCALS[i][2]);131}132}133134jdb.receiveReplyFor(JdbCommand.cont);135reply = jdb.receiveReplyFor(JdbCommand.locals);136grep = new Paragrep(reply);137for (int i = 0; i < LOCALS.length; i++) {138v = new Vector();139v.add(LOCALS[i][0]);140v.add(LOCALS[i][1]);141if (grep.find(v) == 0) {142failure("Cannot find " + LOCALS[0][0] +143" with expected value: " + LOCALS[i][1]);144}145}146147jdb.contToExit(1);148}149150private boolean checkStop () {151Paragrep grep;152String[] reply;153String found;154Vector v;155boolean result = true;156157return result;158}159}160161162