50220
|
1 |
/*
|
|
2 |
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
|
|
25 |
/*
|
|
26 |
* @test
|
|
27 |
*
|
|
28 |
* @summary converted from VM Testbase nsk/jdb/clear/clear003.
|
|
29 |
* VM Testbase keywords: [jpda, jdb]
|
|
30 |
* VM Testbase readme:
|
|
31 |
* DECSRIPTION
|
|
32 |
* A negative test case for the 'clear <class_id>.<method>' command.
|
|
33 |
* The test sets 2 breakpoints and then tries to clear non-existent
|
|
34 |
* breakpoint after the first breakpoint is reached. The tests verifies
|
|
35 |
* that jdb correctly reports about attempt to clear non-existent
|
|
36 |
* breakpoint.
|
|
37 |
* COMMENTS
|
|
38 |
*
|
|
39 |
* @library /vmTestbase
|
|
40 |
* /test/lib
|
|
41 |
* @run driver jdk.test.lib.FileInstaller . .
|
|
42 |
* @build nsk.jdb.clear.clear003.clear003
|
|
43 |
* nsk.jdb.clear.clear003.clear003a
|
|
44 |
* @run main/othervm PropertyResolvingWrapper nsk.jdb.clear.clear003.clear003
|
|
45 |
* -arch=${os.family}-${os.simpleArch}
|
|
46 |
* -waittime=5
|
|
47 |
* -debugee.vmkind=java
|
|
48 |
* -transport.address=dynamic
|
|
49 |
* -jdb=${test.jdk}/bin/jdb
|
|
50 |
* -java.options="${test.vm.opts} ${test.java.opts}"
|
|
51 |
* -workdir=.
|
|
52 |
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
|
53 |
*/
|
|
54 |
|
|
55 |
package nsk.jdb.clear.clear003;
|
|
56 |
|
|
57 |
import nsk.share.*;
|
|
58 |
import nsk.share.jdb.*;
|
|
59 |
|
|
60 |
import java.io.*;
|
|
61 |
import java.util.*;
|
|
62 |
|
|
63 |
public class clear003 extends JdbTest {
|
|
64 |
|
|
65 |
public static void main (String argv[]) {
|
|
66 |
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
|
67 |
}
|
|
68 |
|
|
69 |
public static int run(String argv[], PrintStream out) {
|
|
70 |
debuggeeClass = DEBUGGEE_CLASS;
|
|
71 |
firstBreak = FIRST_BREAK;
|
|
72 |
lastBreak = LAST_BREAK;
|
|
73 |
return new clear003().runTest(argv, out);
|
|
74 |
}
|
|
75 |
|
|
76 |
static final String PACKAGE_NAME = "nsk.jdb.clear.clear003";
|
|
77 |
static final String TEST_CLASS = PACKAGE_NAME + ".clear003";
|
|
78 |
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
|
79 |
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
|
80 |
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
|
81 |
static final String METHOD4 = "func4";
|
|
82 |
static final String METHOD5 = "func5";
|
|
83 |
static final String METHOD_TO_CLEAR = DEBUGGEE_CLASS + "." + METHOD4;
|
|
84 |
|
|
85 |
protected void runCases() {
|
|
86 |
String[] reply;
|
|
87 |
Paragrep grep;
|
|
88 |
int count;
|
|
89 |
Vector v;
|
|
90 |
String found;
|
|
91 |
|
|
92 |
log.display("Setting breakpoint in method: " + METHOD5);
|
|
93 |
jdb.setBreakpointInMethod(DEBUGGEE_CLASS + "." + METHOD5);
|
|
94 |
|
|
95 |
log.display("Clearing breakpoint.");
|
|
96 |
reply = jdb.receiveReplyFor(JdbCommand.clear + METHOD_TO_CLEAR);
|
|
97 |
grep = new Paragrep(reply);
|
|
98 |
count = grep.find("Removed:");
|
|
99 |
if (count > 0) {
|
|
100 |
log.complain("Cleared non-existent breakpoint in method: " + METHOD_TO_CLEAR);
|
|
101 |
success = false;
|
|
102 |
}
|
|
103 |
|
|
104 |
jdb.contToExit(2);
|
|
105 |
|
|
106 |
grep = new Paragrep(jdb.getTotalReply());
|
|
107 |
count = grep.find(Jdb.BREAKPOINT_HIT);
|
|
108 |
if (count != 2) {
|
|
109 |
log.complain("Should hit 2 breakpoints.");
|
|
110 |
log.complain("Breakpoint hit count reported: " + count);
|
|
111 |
success = false;
|
|
112 |
}
|
|
113 |
}
|
|
114 |
}
|