author | gadams |
Thu, 21 Feb 2019 05:06:41 -0500 | |
changeset 53869 | 34906de6c017 |
parent 50018 | 3ba0d8631f24 |
permissions | -rw-r--r-- |
50018 | 1 |
/* |
53869
34906de6c017
8219388: Misleading log message "issuspended002a debuggee launched"
gadams
parents:
50018
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
50018 | 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 |
package nsk.jdi.ReferenceType.locationsOfLine_ssi; |
|
25 |
||
26 |
import nsk.share.*; |
|
27 |
import nsk.share.jpda.*; |
|
28 |
import nsk.share.jdi.*; |
|
29 |
||
30 |
import com.sun.jdi.*; |
|
31 |
import java.util.*; |
|
32 |
import java.io.*; |
|
33 |
||
34 |
/** |
|
35 |
* The test for the implementation of an object of the type <BR> |
|
36 |
* ReferenceType. <BR> |
|
37 |
* <BR> |
|
38 |
* The test checks up that results of the method <BR> |
|
39 |
* <code>com.sun.jdi.ReferenceType.locationsOfLine(String,String,int)</code> <BR> |
|
40 |
* complies with its specification. <BR> |
|
41 |
* <BR> |
|
42 |
* The test checks up that for each line in the List returned <BR> |
|
43 |
* by the method ReferenceType.allLineLocations(), <BR> |
|
44 |
* the method locationsOfLine(defaultStratum,null,lineNumber) <BR> |
|
45 |
* returns non-empty List object <BR> |
|
46 |
* in which each object is a Location object.<BR> |
|
47 |
* Not throwing AbsentInformationException is checked up as well.<BR> |
|
48 |
*/ |
|
49 |
||
50 |
public class locationsofline_ssi001 { |
|
51 |
||
52 |
//----------------------------------------------------- templete section |
|
53 |
static final int PASSED = 0; |
|
54 |
static final int FAILED = 2; |
|
55 |
static final int PASS_BASE = 95; |
|
56 |
||
57 |
//----------------------------------------------------- templete parameters |
|
58 |
static final String |
|
59 |
sHeader1 = "\n==> nsk/jdi/ReferenceType/locationsOfLine_ssi/locationsofline_ssi001 ", |
|
60 |
sHeader2 = "--> debugger: ", |
|
61 |
sHeader3 = "##> debugger: "; |
|
62 |
||
63 |
//----------------------------------------------------- main method |
|
64 |
||
65 |
public static void main (String argv[]) { |
|
66 |
||
67 |
int result = run(argv, System.out); |
|
68 |
||
69 |
System.exit(result + PASS_BASE); |
|
70 |
} |
|
71 |
||
72 |
public static int run (String argv[], PrintStream out) { |
|
73 |
||
74 |
return new locationsofline_ssi001().runThis(argv, out); |
|
75 |
} |
|
76 |
||
77 |
//-------------------------------------------------- log procedures |
|
78 |
||
79 |
private static Log logHandler; |
|
80 |
||
81 |
private static void log1(String message) { |
|
82 |
logHandler.display(sHeader1 + message); |
|
83 |
} |
|
84 |
private static void log2(String message) { |
|
85 |
logHandler.display(sHeader2 + message); |
|
86 |
} |
|
87 |
private static void log3(String message) { |
|
88 |
logHandler.complain(sHeader3 + message); |
|
89 |
} |
|
90 |
||
91 |
// ************************************************ test parameters |
|
92 |
||
93 |
private String debuggeeName = |
|
94 |
"nsk.jdi.ReferenceType.locationsOfLine_ssi.locationsofline_ssi001a"; |
|
95 |
||
96 |
String mName = "nsk.jdi.ReferenceType.locationsOfLine_ssi"; |
|
97 |
||
98 |
//====================================================== test program |
|
99 |
//------------------------------------------------------ common section |
|
100 |
||
101 |
static ArgumentHandler argsHandler; |
|
102 |
||
103 |
static int waitTime; |
|
104 |
||
105 |
static VirtualMachine vm = null; |
|
106 |
||
107 |
static int testExitCode = PASSED; |
|
108 |
||
109 |
//------------------------------------------------------ methods |
|
110 |
||
111 |
private int runThis (String argv[], PrintStream out) { |
|
112 |
||
113 |
Debugee debuggee; |
|
114 |
||
115 |
argsHandler = new ArgumentHandler(argv); |
|
116 |
logHandler = new Log(out, argsHandler); |
|
117 |
Binder binder = new Binder(argsHandler, logHandler); |
|
118 |
||
119 |
if (argsHandler.verbose()) { |
|
120 |
debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); |
|
121 |
} else { |
|
122 |
debuggee = binder.bindToDebugee(debuggeeName); |
|
123 |
} |
|
124 |
||
125 |
waitTime = argsHandler.getWaitTime(); |
|
126 |
||
127 |
||
128 |
IOPipe pipe = new IOPipe(debuggee); |
|
129 |
||
130 |
debuggee.redirectStderr(out); |
|
53869
34906de6c017
8219388: Misleading log message "issuspended002a debuggee launched"
gadams
parents:
50018
diff
changeset
|
131 |
log2(debuggeeName + " debuggee launched"); |
50018 | 132 |
debuggee.resume(); |
133 |
||
134 |
String line = pipe.readln(); |
|
135 |
if ((line == null) || !line.equals("ready")) { |
|
136 |
log3("signal received is not 'ready' but: " + line); |
|
137 |
return FAILED; |
|
138 |
} else { |
|
139 |
log2("'ready' recieved"); |
|
140 |
} |
|
141 |
||
142 |
vm = debuggee.VM(); |
|
143 |
||
144 |
//------------------------------------------------------ testing section |
|
145 |
log1(" TESTING BEGINS"); |
|
146 |
||
147 |
for (int i = 0; ; i++) { |
|
148 |
||
149 |
pipe.println("newcheck"); |
|
150 |
line = pipe.readln(); |
|
151 |
||
152 |
if (line.equals("checkend")) { |
|
153 |
log2(" : returned string is 'checkend'"); |
|
154 |
break ; |
|
155 |
} else if (!line.equals("checkready")) { |
|
156 |
log3("ERROR: returned string is not 'checkready'"); |
|
157 |
testExitCode = FAILED; |
|
158 |
break ; |
|
159 |
} |
|
160 |
||
161 |
log1("new checkready: #" + i); |
|
162 |
||
163 |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part |
|
164 |
||
165 |
List locations = null; |
|
166 |
ReferenceType refType = null; |
|
167 |
||
168 |
||
169 |
log2(" getting: List classes = vm.classesByName(mName + '.TestClass');"); |
|
170 |
List classes = vm.classesByName(mName + ".TestClass"); |
|
171 |
||
172 |
if (classes.size() != 1) { |
|
173 |
testExitCode = FAILED; |
|
174 |
log3("ERROR: classes.size() != 1"); |
|
175 |
break ; |
|
176 |
} |
|
177 |
||
178 |
log2("...... getting : String defaultStratum = vm.getDefaultStratum();"); |
|
179 |
String defaultStratum = vm.getDefaultStratum(); |
|
180 |
||
181 |
log2(" getting a tested ReferenceType object 'refType'"); |
|
182 |
refType = (ReferenceType) classes.get(0); |
|
183 |
||
184 |
log2("......locations = refType.allLineLocations(); no AbsentInformationException is expected"); |
|
185 |
try { |
|
186 |
locations = refType.allLineLocations(); |
|
187 |
} catch ( AbsentInformationException e ) { |
|
188 |
testExitCode = FAILED; |
|
189 |
log3("ERROR: AbsentInformationException"); |
|
190 |
log3(" ATTENTION: see the README file to this test"); |
|
191 |
break ; |
|
192 |
} |
|
193 |
||
194 |
log2("......checking up on a value of locations.size(); 0 is not expected"); |
|
195 |
int size = locations.size(); |
|
196 |
if (size == 0) { |
|
197 |
testExitCode = FAILED; |
|
198 |
log3("ERROR: locations.size() == 0"); |
|
199 |
break ; |
|
200 |
} |
|
201 |
||
202 |
ListIterator li1 = locations.listIterator(); |
|
203 |
||
204 |
log2("......the loop of checking locations in the returned list;"); |
|
205 |
log2(" AbsentInformationException is not expected"); |
|
206 |
||
207 |
label1: |
|
208 |
for (int ifor1 = 0; ifor1 < size; ifor1++) { |
|
209 |
||
210 |
int lineNumber = ((Location) li1.next()).lineNumber(); |
|
211 |
||
212 |
try { |
|
213 |
log2("......List lineLocations = refType.locationsOfLine(defaultStratum, null, " + lineNumber + ");"); |
|
214 |
List lineLocations = refType.locationsOfLine(defaultStratum, null, lineNumber); |
|
215 |
int size1 = lineLocations.size(); |
|
216 |
if (size1 == 0) { |
|
217 |
testExitCode = FAILED; |
|
218 |
log3("ERROR: lineLocations.size() == 0"); |
|
219 |
break label1; |
|
220 |
} |
|
221 |
ListIterator li2 = lineLocations.listIterator(); |
|
222 |
try { |
|
223 |
for (; li2.hasNext(); ) { |
|
224 |
Location loc = (Location) li2.next(); |
|
225 |
} |
|
226 |
} catch ( ClassCastException e) { |
|
227 |
testExitCode = FAILED; |
|
228 |
log3("ERROR: ClassCastException, that is, element is not Location"); |
|
229 |
break label1; |
|
230 |
} |
|
231 |
} catch ( AbsentInformationException e2 ) { |
|
232 |
testExitCode = FAILED; |
|
233 |
log3("ERROR: AbsentInformationException"); |
|
234 |
log3(" ATTENTION: see the README file to this test"); |
|
235 |
break label1; |
|
236 |
} |
|
237 |
} |
|
238 |
||
239 |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
240 |
} |
|
241 |
log1(" TESTING ENDS"); |
|
242 |
||
243 |
//-------------------------------------------------- test summary section |
|
244 |
//------------------------------------------------- standard end section |
|
245 |
||
246 |
pipe.println("quit"); |
|
247 |
log2("waiting for the debuggee to finish ..."); |
|
248 |
debuggee.waitFor(); |
|
249 |
||
250 |
int status = debuggee.getStatus(); |
|
251 |
if (status != PASSED + PASS_BASE) { |
|
252 |
log3("debuggee returned UNEXPECTED exit status: " + |
|
253 |
status + " != PASS_BASE"); |
|
254 |
testExitCode = FAILED; |
|
255 |
} else { |
|
256 |
log2("debuggee returned expected exit status: " + |
|
257 |
status + " == PASS_BASE"); |
|
258 |
} |
|
259 |
||
260 |
if (testExitCode != PASSED) { |
|
261 |
logHandler.complain("TEST FAILED"); |
|
262 |
} |
|
263 |
return testExitCode; |
|
264 |
} |
|
265 |
} |