Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/clear/clear003/clear003.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/clear/clear003.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* A negative test case for the 'clear <class_id>.<method>' command.32* The test sets 2 breakpoints and then tries to clear non-existent33* breakpoint after the first breakpoint is reached. The tests verifies34* that jdb correctly reports about attempt to clear non-existent35* breakpoint.36* COMMENTS37*38* @library /vmTestbase39* /test/lib40* @build nsk.jdb.clear.clear003.clear003a41* @run main/othervm42* nsk.jdb.clear.clear003.clear00343* -arch=${os.family}-${os.simpleArch}44* -waittime=545* -debugee.vmkind=java46* -transport.address=dynamic47* -jdb=${test.jdk}/bin/jdb48* -java.options="${test.vm.opts} ${test.java.opts}"49* -workdir=.50* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"51*/5253package nsk.jdb.clear.clear003;5455import nsk.share.*;56import nsk.share.jdb.*;5758import java.io.*;59import java.util.*;6061public class clear003 extends JdbTest {6263public static void main (String argv[]) {64System.exit(run(argv, System.out) + JCK_STATUS_BASE);65}6667public static int run(String argv[], PrintStream out) {68debuggeeClass = DEBUGGEE_CLASS;69firstBreak = FIRST_BREAK;70lastBreak = LAST_BREAK;71return new clear003().runTest(argv, out);72}7374static final String PACKAGE_NAME = "nsk.jdb.clear.clear003";75static final String TEST_CLASS = PACKAGE_NAME + ".clear003";76static final String DEBUGGEE_CLASS = TEST_CLASS + "a";77static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";78static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";79static final String METHOD4 = "func4";80static final String METHOD5 = "func5";81static final String METHOD_TO_CLEAR = DEBUGGEE_CLASS + "." + METHOD4;8283protected void runCases() {84String[] reply;85Paragrep grep;86int count;87Vector v;88String found;8990log.display("Setting breakpoint in method: " + METHOD5);91jdb.setBreakpointInMethod(DEBUGGEE_CLASS + "." + METHOD5);9293log.display("Clearing breakpoint.");94reply = jdb.receiveReplyFor(JdbCommand.clear + METHOD_TO_CLEAR);95grep = new Paragrep(reply);96count = grep.find("Removed:");97if (count > 0) {98log.complain("Cleared non-existent breakpoint in method: " + METHOD_TO_CLEAR);99success = false;100}101102jdb.contToExit(2);103104grep = new Paragrep(jdb.getTotalReply());105count = grep.find(Jdb.BREAKPOINT_HIT);106if (count != 2) {107log.complain("Should hit 2 breakpoints.");108log.complain("Breakpoint hit count reported: " + count);109success = false;110}111}112}113114115