|
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/locals/locals002. |
|
29 * VM Testbase keywords: [jpda, jdb] |
|
30 * VM Testbase readme: |
|
31 * DESCRIPTION |
|
32 * This is a test for the 'locals' command. |
|
33 * The test sets breakpoints in 'allKindsOfLocals' and 'allKindsOfArgs' |
|
34 * methods of debugged 'locals002a' class. Once the debuggee is |
|
35 * suspended in method, the test via 'locals' command compares |
|
36 * the values of all visible variables with expected ones. |
|
37 * The test consists of two parts: |
|
38 * locals002.java - test driver, i.e. launches jdb and debuggee, |
|
39 * writes commands to jdb, reads the jdb output, |
|
40 * locals002a.java - the debugged application. |
|
41 * COMMENTS |
|
42 * The test functionally equals to nsk/jdb/locals/locals001 test |
|
43 * and replaces it. |
|
44 * Test fixed according to test bug: |
|
45 * 5045859 TEST_BUG: some JDB tests do not recognize JDB prompt |
|
46 * |
|
47 * @library /vmTestbase |
|
48 * /test/lib |
|
49 * @run driver jdk.test.lib.FileInstaller . . |
|
50 * @build nsk.jdb.locals.locals002.locals002 |
|
51 * |
|
52 * @comment make sure locals002a is compiled w/ full debug info |
|
53 * @clean nsk.jdb.locals.locals002.locals002a |
|
54 * @compile -g:lines,source,vars locals002a.java |
|
55 * |
|
56 * @run main/othervm PropertyResolvingWrapper nsk.jdb.locals.locals002.locals002 |
|
57 * -arch=${os.family}-${os.simpleArch} |
|
58 * -waittime=5 |
|
59 * -debugee.vmkind=java |
|
60 * -transport.address=dynamic |
|
61 * -jdb=${test.jdk}/bin/jdb |
|
62 * -java.options="${test.vm.opts} ${test.java.opts}" |
|
63 * -workdir=. |
|
64 * -debugee.vmkeys="${test.vm.opts} ${test.java.opts}" |
|
65 */ |
|
66 |
|
67 package nsk.jdb.locals.locals002; |
|
68 |
|
69 import nsk.share.*; |
|
70 import nsk.share.jdb.*; |
|
71 |
|
72 import java.io.*; |
|
73 import java.util.*; |
|
74 |
|
75 public class locals002 extends JdbTest { |
|
76 |
|
77 public static void main (String argv[]) { |
|
78 System.exit(run(argv, System.out) + JCK_STATUS_BASE); |
|
79 } |
|
80 |
|
81 public static int run(String argv[], PrintStream out) { |
|
82 debuggeeClass = DEBUGGEE_CLASS; |
|
83 firstBreak = FIRST_BREAK; |
|
84 lastBreak = LAST_BREAK; |
|
85 compoundPromptIdent = COMPOUND_PROMPT_IDENT; |
|
86 return new locals002().runTest(argv, out); |
|
87 } |
|
88 |
|
89 static final String PACKAGE_NAME = "nsk.jdb.locals.locals002"; |
|
90 static final String TEST_CLASS = PACKAGE_NAME + ".locals002"; |
|
91 static final String DEBUGGEE_CLASS = TEST_CLASS + "a"; |
|
92 static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main"; |
|
93 static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak"; |
|
94 static final String COMPOUND_PROMPT_IDENT = "main"; |
|
95 static final int BREAKPOINT_LINE1 = 84; |
|
96 static final int BREAKPOINT_LINE2 = 100; |
|
97 |
|
98 static final String LOCALS[][] = new String[][] { |
|
99 { "boolVar" , "true" , "false" }, |
|
100 { "byteVar" , "27" , "12" }, |
|
101 { "charVar" , "V" , "A" }, |
|
102 { "shortVar" , "767" , "327" }, |
|
103 { "intVar" , "1474" , "3647" }, |
|
104 { "longVar" , "21345" , "65789" }, |
|
105 { "floatVar" , "3.141" , "4.852" }, |
|
106 { "doubleVar", "2.578" , "3.8976" }, |
|
107 { "objVar" , "objVarString" , "objArgString" }, |
|
108 { "arrVar" , "int[5]" , "int[3]" } |
|
109 |
|
110 }; |
|
111 |
|
112 protected void runCases() { |
|
113 String[] reply; |
|
114 Paragrep grep; |
|
115 int count; |
|
116 Vector v; |
|
117 String found; |
|
118 |
|
119 jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + BREAKPOINT_LINE1); |
|
120 jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + BREAKPOINT_LINE2); |
|
121 |
|
122 jdb.receiveReplyFor(JdbCommand.cont); |
|
123 reply = jdb.receiveReplyFor(JdbCommand.locals); |
|
124 grep = new Paragrep(reply); |
|
125 for (int i = 0; i < LOCALS.length; i++) { |
|
126 v = new Vector(); |
|
127 v.add(LOCALS[i][0]); |
|
128 v.add(LOCALS[i][2]); |
|
129 if (grep.find(v) == 0) { |
|
130 failure("Cannot find " + LOCALS[0][0] + |
|
131 " with expected value: " + LOCALS[i][2]); |
|
132 } |
|
133 } |
|
134 |
|
135 jdb.receiveReplyFor(JdbCommand.cont); |
|
136 reply = jdb.receiveReplyFor(JdbCommand.locals); |
|
137 grep = new Paragrep(reply); |
|
138 for (int i = 0; i < LOCALS.length; i++) { |
|
139 v = new Vector(); |
|
140 v.add(LOCALS[i][0]); |
|
141 v.add(LOCALS[i][1]); |
|
142 if (grep.find(v) == 0) { |
|
143 failure("Cannot find " + LOCALS[0][0] + |
|
144 " with expected value: " + LOCALS[i][1]); |
|
145 } |
|
146 } |
|
147 |
|
148 jdb.contToExit(1); |
|
149 } |
|
150 |
|
151 private boolean checkStop () { |
|
152 Paragrep grep; |
|
153 String[] reply; |
|
154 String found; |
|
155 Vector v; |
|
156 boolean result = true; |
|
157 |
|
158 return result; |
|
159 } |
|
160 } |