132
133 debuggee.redirectStderr(out);
134 log2("newinstance001a debuggee launched");
135 debuggee.resume();
136
137 String line = pipe.readln();
138 if ((line == null) || !line.equals("ready")) {
139 log3("signal received is not 'ready' but: " + line);
140 return FAILED;
141 } else {
142 log2("'ready' recieved");
143 }
144
145 VirtualMachine vm = debuggee.VM();
146
147 //------------------------------------------------------ testing section
148 log1(" TESTING BEGINS");
149
150 for (int i = 0; ; i++) {
151 pipe.println("newcheck");
152 line = pipe.readln();
153
154 if (line.equals("checkend")) {
155 log2(" : returned string is 'checkend'");
156 break ;
157 } else if (!line.equals("checkready")) {
158 log3("ERROR: returned string is not 'checkready'");
159 testExitCode = FAILED;
160 break ;
161 }
162
163 log1("new check: #" + i);
164
165 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
166
167 List listOfDebuggeeExecClasses = vm.classesByName(debuggeeName);
168 if (listOfDebuggeeExecClasses.size() != 1) {
169 testExitCode = FAILED;
170 log3("ERROR: listOfDebuggeeExecClasses.size() != 1");
171 break ;
172 }
173 ReferenceType execClass =
342
343 default: expresult = 2;
344 break ;
345 }
346
347 if (expresult == 2) {
348 log2(" test cases finished");
349 break ;
350 } else if (expresult == 1) {
351 log3("ERROR: expresult != true; check # = " + i);
352 testExitCode = FAILED;
353 }
354 }
355 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
356 }
357 log1(" TESTING ENDS");
358
359 //-------------------------------------------------- test summary section
360 //------------------------------------------------- standard end section
361
362 pipe.println("quit");
363 log2("waiting for the debuggee to finish ...");
364 debuggee.waitFor();
365
366 int status = debuggee.getStatus();
367 if (status != PASSED + PASS_BASE) {
368 log3("debuggee returned UNEXPECTED exit status: " +
369 status + " != PASS_BASE");
370 testExitCode = FAILED;
371 } else {
372 log2("debuggee returned expected exit status: " +
373 status + " == PASS_BASE");
374 }
375
376 if (testExitCode != PASSED) {
377 System.out.println("TEST FAILED");
378 }
379 return testExitCode;
380 }
381 }
|
132
133 debuggee.redirectStderr(out);
134 log2("newinstance001a debuggee launched");
135 debuggee.resume();
136
137 String line = pipe.readln();
138 if ((line == null) || !line.equals("ready")) {
139 log3("signal received is not 'ready' but: " + line);
140 return FAILED;
141 } else {
142 log2("'ready' recieved");
143 }
144
145 VirtualMachine vm = debuggee.VM();
146
147 //------------------------------------------------------ testing section
148 log1(" TESTING BEGINS");
149
150 for (int i = 0; ; i++) {
151 pipe.println("newcheck");
152
153 // There are potentially other non-test Java threads allocating objects and triggering
154 // GC's so we need to suspend the target VM to avoid the objects created in the test
155 // from being accidentally GC'ed. However, we need the target VM temporary resumed
156 // while reading its response. Below we resume the target VM (if required) and suspend
157 // it only after pipe.readln() returns.
158
159 // On the first iteration the target VM is not suspended yet.
160 if (i > 0) {
161 debuggee.resume();
162 }
163 line = pipe.readln();
164
165 // Suspending target VM to prevent other non-test Java threads from triggering GCs.
166 debuggee.suspend();
167
168 if (line.equals("checkend")) {
169 log2(" : returned string is 'checkend'");
170 break ;
171 } else if (!line.equals("checkready")) {
172 log3("ERROR: returned string is not 'checkready'");
173 testExitCode = FAILED;
174 break ;
175 }
176
177 log1("new check: #" + i);
178
179 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
180
181 List listOfDebuggeeExecClasses = vm.classesByName(debuggeeName);
182 if (listOfDebuggeeExecClasses.size() != 1) {
183 testExitCode = FAILED;
184 log3("ERROR: listOfDebuggeeExecClasses.size() != 1");
185 break ;
186 }
187 ReferenceType execClass =
356
357 default: expresult = 2;
358 break ;
359 }
360
361 if (expresult == 2) {
362 log2(" test cases finished");
363 break ;
364 } else if (expresult == 1) {
365 log3("ERROR: expresult != true; check # = " + i);
366 testExitCode = FAILED;
367 }
368 }
369 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
370 }
371 log1(" TESTING ENDS");
372
373 //-------------------------------------------------- test summary section
374 //------------------------------------------------- standard end section
375
376 debuggee.resume();
377 pipe.println("quit");
378 log2("waiting for the debuggee to finish ...");
379 debuggee.waitFor();
380
381 int status = debuggee.getStatus();
382 if (status != PASSED + PASS_BASE) {
383 log3("debuggee returned UNEXPECTED exit status: " +
384 status + " != PASS_BASE");
385 testExitCode = FAILED;
386 } else {
387 log2("debuggee returned expected exit status: " +
388 status + " == PASS_BASE");
389 }
390
391 if (testExitCode != PASSED) {
392 System.out.println("TEST FAILED");
393 }
394 return testExitCode;
395 }
396 }
|