Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/use/use001/use001.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/use/use001.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* A positive test case for the 'use [source file path]' command.32* The test checks if jdb correctly sets and shows source file path.33* Working directory is added to the current path using 'use' command34* with argument composed of old value and current working directory.35* The test passes if working directory is encountered in reply message36* returned by subsequent 'use' command.37* The test consists of two program:38* use001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,39* use001a.java - the debugged application.40* COMMENTS41*42* @library /vmTestbase43* /test/lib44* @build nsk.jdb.use.use001.use001a45* @run main/othervm46* nsk.jdb.use.use001.use00147* -arch=${os.family}-${os.simpleArch}48* -waittime=549* -debugee.vmkind=java50* -transport.address=dynamic51* -jdb=${test.jdk}/bin/jdb52* -java.options="${test.vm.opts} ${test.java.opts}"53* -workdir=.54* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"55*/5657package nsk.jdb.use.use001;5859import nsk.share.*;60import nsk.share.jdb.*;61import jdk.test.lib.Utils;6263import java.io.*;64import java.util.*;6566public class use001 extends JdbTest {6768public static void main (String argv[]) {69System.exit(run(argv, System.out) + JCK_STATUS_BASE);70}7172public static int run(String argv[], PrintStream out) {73debuggeeClass = DEBUGGEE_CLASS;74firstBreak = FIRST_BREAK;75lastBreak = LAST_BREAK;76return new use001().runTest(argv, out);77}7879static final String PACKAGE_NAME = "nsk.jdb.use.use001";80static final String TEST_CLASS = PACKAGE_NAME + ".use001";81static final String DEBUGGEE_CLASS = TEST_CLASS + "a";82static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";83static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";8485protected void runCases() {86String[] reply;87Paragrep grep;88int count;89Vector v;90String found;9192String path = "";93String srcdir = Utils.TEST_SRC;9495// jdb.setBreakpointInMethod(LAST_BREAK);96// reply = jdb.receiveReplyFor(JdbCommand.cont);9798while (true) {99reply = jdb.receiveReplyFor(JdbCommand.use);100/*101if (reply.length == 0) {102log.complain("Empty reply on first 'use' command");103success = false;104break;105}106*/107if (reply.length > 0) {108path = reply[0];109}110/*111grep = new Paragrep(reply);112count = grep.find(srcdir);113if (count == 0) {114log.complain("Not found current source directory in source file path");115success = false;116break;117}118*/119reply = jdb.receiveReplyFor(JdbCommand.use + srcdir + File.pathSeparator + path);120if (reply.length == 0) {121log.complain("Empty reply on third 'use' command");122success = false;123break;124}125126reply = jdb.receiveReplyFor(JdbCommand.use);127grep = new Paragrep(reply);128if (grep.find(srcdir) == 0) {129log.complain("Current source directory should be in source file path");130success = false;131break;132}133134break;135}136137jdb.contToExit(1);138}139}140141142