8328303: 3 JDI tests timed out with UT enabled
Reviewed-by: cjplummer, sspitsyn, dcubed
This commit is contained in:
parent
476421efe5
commit
bc73963974
@ -28,6 +28,8 @@ import com.sun.jdi.event.*;
|
|||||||
import com.sun.jdi.request.*;
|
import com.sun.jdi.request.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import nsk.share.*;
|
import nsk.share.*;
|
||||||
@ -68,7 +70,8 @@ public class refType001 {
|
|||||||
{"AnotherThread", "Inter", "0"}
|
{"AnotherThread", "Inter", "0"}
|
||||||
};
|
};
|
||||||
|
|
||||||
static private volatile boolean testFailed, eventsReceived, threadsStarted;
|
static private volatile boolean testFailed;
|
||||||
|
static private CountDownLatch eventsReceivedLatch;
|
||||||
static private int eventTimeout;
|
static private int eventTimeout;
|
||||||
|
|
||||||
public static void main (String argv[]) {
|
public static void main (String argv[]) {
|
||||||
@ -82,9 +85,7 @@ public class refType001 {
|
|||||||
String command;
|
String command;
|
||||||
|
|
||||||
testFailed = false;
|
testFailed = false;
|
||||||
eventsReceived = false;
|
eventsReceivedLatch = new CountDownLatch(1);
|
||||||
threadsStarted = false;
|
|
||||||
|
|
||||||
|
|
||||||
argHandler = new ArgumentHandler(args);
|
argHandler = new ArgumentHandler(args);
|
||||||
log = new Log(out, argHandler);
|
log = new Log(out, argHandler);
|
||||||
@ -114,8 +115,10 @@ public class refType001 {
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// handle events until all threads started and all expected events received
|
boolean isConnected = true;
|
||||||
while (!(threadsStarted && eventsReceived)) {
|
boolean allEventsReceived = false;
|
||||||
|
// handle events until debuggee is disconnected
|
||||||
|
while (isConnected) {
|
||||||
EventSet eventSet = null;
|
EventSet eventSet = null;
|
||||||
try {
|
try {
|
||||||
eventSet = vm.eventQueue().remove(TIMEOUT_DELTA);
|
eventSet = vm.eventQueue().remove(TIMEOUT_DELTA);
|
||||||
@ -133,8 +136,10 @@ public class refType001 {
|
|||||||
Event event = eventIterator.nextEvent();
|
Event event = eventIterator.nextEvent();
|
||||||
// log.display("\nEvent received:\n " + event);
|
// log.display("\nEvent received:\n " + event);
|
||||||
|
|
||||||
// handle ClassPrepareEvent
|
if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
|
||||||
if (event instanceof ClassPrepareEvent) {
|
log.display("eventHandler got " + event);
|
||||||
|
isConnected = false;
|
||||||
|
} else if (event instanceof ClassPrepareEvent) {
|
||||||
ClassPrepareEvent castedEvent = (ClassPrepareEvent)event;
|
ClassPrepareEvent castedEvent = (ClassPrepareEvent)event;
|
||||||
log.display("\nClassPrepareEvent received:\n " + event);
|
log.display("\nClassPrepareEvent received:\n " + event);
|
||||||
|
|
||||||
@ -198,11 +203,20 @@ public class refType001 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that all expected ClassPrepareEvent are received
|
// Check that all expected ClassPrepareEvent(s) are received.
|
||||||
eventsReceived = true;
|
if (!allEventsReceived) {
|
||||||
|
allEventsReceived = true;
|
||||||
for (int i = 0; i < checkedTypes.length; i++) {
|
for (int i = 0; i < checkedTypes.length; i++) {
|
||||||
if (checkedTypes[i][2] == "0")
|
// checkedTypes[i][2] is "0" initially,
|
||||||
eventsReceived = false;
|
// "1" after corresponding ClassPrepareEvent is received.
|
||||||
|
if (checkedTypes[i][2] == "0") {
|
||||||
|
allEventsReceived = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (allEventsReceived) {
|
||||||
|
eventsReceivedLatch.countDown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,7 +233,9 @@ public class refType001 {
|
|||||||
} // event handled
|
} // event handled
|
||||||
|
|
||||||
// log.display("Resuming event set");
|
// log.display("Resuming event set");
|
||||||
|
if (isConnected) {
|
||||||
eventSet.resume();
|
eventSet.resume();
|
||||||
|
}
|
||||||
|
|
||||||
} // event set handled
|
} // event set handled
|
||||||
|
|
||||||
@ -260,15 +276,10 @@ public class refType001 {
|
|||||||
testFailed = true;
|
testFailed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify EventHandler that all threads started
|
|
||||||
threadsStarted = true;
|
|
||||||
|
|
||||||
// wait for all expected events received or timeout exceeds
|
// wait for all expected events received or timeout exceeds
|
||||||
try {
|
try {
|
||||||
eventHandler.join(eventTimeout);
|
if (!eventsReceivedLatch.await(eventTimeout, TimeUnit.MILLISECONDS)) {
|
||||||
if (eventHandler.isAlive()) {
|
log.complain("FAILURE 20: Timeout waiting for all events was exceeded");
|
||||||
log.complain("FAILURE 20: Timeout for waiting event was exceeded");
|
|
||||||
eventHandler.interrupt();
|
|
||||||
testFailed = true;
|
testFailed = true;
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -28,6 +28,8 @@ import com.sun.jdi.event.*;
|
|||||||
import com.sun.jdi.request.*;
|
import com.sun.jdi.request.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import nsk.share.*;
|
import nsk.share.*;
|
||||||
@ -72,7 +74,8 @@ public class thread001 {
|
|||||||
|
|
||||||
static private int threadStatus;
|
static private int threadStatus;
|
||||||
|
|
||||||
static private volatile boolean testFailed, eventsReceived, threadsStarted;
|
static private volatile boolean testFailed;
|
||||||
|
static private CountDownLatch eventsReceivedLatch;
|
||||||
static private int eventTimeout;
|
static private int eventTimeout;
|
||||||
|
|
||||||
public static void main (String argv[]) {
|
public static void main (String argv[]) {
|
||||||
@ -86,8 +89,7 @@ public class thread001 {
|
|||||||
String command;
|
String command;
|
||||||
|
|
||||||
testFailed = false;
|
testFailed = false;
|
||||||
eventsReceived = false;
|
eventsReceivedLatch = new CountDownLatch(1);
|
||||||
threadsStarted = false;
|
|
||||||
|
|
||||||
argHandler = new ArgumentHandler(args);
|
argHandler = new ArgumentHandler(args);
|
||||||
log = new Log(out, argHandler);
|
log = new Log(out, argHandler);
|
||||||
@ -134,8 +136,10 @@ public class thread001 {
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// handle events until all threads started and all expected events received
|
boolean isConnected = true;
|
||||||
while (!(threadsStarted && eventsReceived)) {
|
boolean allEventsReceived = false;
|
||||||
|
// handle events until debuggee is disconnected
|
||||||
|
while (isConnected) {
|
||||||
EventSet eventSet = null;
|
EventSet eventSet = null;
|
||||||
try {
|
try {
|
||||||
eventSet = vm.eventQueue().remove(TIMEOUT_DELTA);
|
eventSet = vm.eventQueue().remove(TIMEOUT_DELTA);
|
||||||
@ -153,8 +157,10 @@ public class thread001 {
|
|||||||
Event event = eventIterator.nextEvent();
|
Event event = eventIterator.nextEvent();
|
||||||
// log.display("\nEvent received:\n " + event);
|
// log.display("\nEvent received:\n " + event);
|
||||||
|
|
||||||
// handle ClassPrepareEvent
|
if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
|
||||||
if (event instanceof ClassPrepareEvent) {
|
log.display("eventHandler got " + event);
|
||||||
|
isConnected = false;
|
||||||
|
} else if (event instanceof ClassPrepareEvent) {
|
||||||
ClassPrepareEvent castedEvent = (ClassPrepareEvent)event;
|
ClassPrepareEvent castedEvent = (ClassPrepareEvent)event;
|
||||||
log.display("\nClassPrepareEvent received:\n " + event);
|
log.display("\nClassPrepareEvent received:\n " + event);
|
||||||
|
|
||||||
@ -227,11 +233,19 @@ public class thread001 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that all expected ClassPrepareEvent are received
|
// Check that all expected ClassPrepareEvent(s) are received.
|
||||||
eventsReceived = true;
|
if (!allEventsReceived) {
|
||||||
|
allEventsReceived = true;
|
||||||
for (int i = 0; i < checkedThreads.length; i++) {
|
for (int i = 0; i < checkedThreads.length; i++) {
|
||||||
|
// checkedTypes[i][2] is "0" initially,
|
||||||
|
// "1" after corresponding ClassPrepareEvent is received.
|
||||||
if (checkedThreads[i][2] == "0") {
|
if (checkedThreads[i][2] == "0") {
|
||||||
eventsReceived = false;
|
allEventsReceived = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (allEventsReceived) {
|
||||||
|
eventsReceivedLatch.countDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,7 +257,9 @@ public class thread001 {
|
|||||||
} // event handled
|
} // event handled
|
||||||
|
|
||||||
// log.display("Resuming event set");
|
// log.display("Resuming event set");
|
||||||
|
if (isConnected) {
|
||||||
eventSet.resume();
|
eventSet.resume();
|
||||||
|
}
|
||||||
|
|
||||||
} // event set handled
|
} // event set handled
|
||||||
|
|
||||||
@ -283,15 +299,10 @@ public class thread001 {
|
|||||||
testFailed = true;
|
testFailed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify EventHandler that all threads started
|
|
||||||
threadsStarted = true;
|
|
||||||
|
|
||||||
// wait for all expected events received or timeout exceeds
|
// wait for all expected events received or timeout exceeds
|
||||||
try {
|
try {
|
||||||
eventHandler.join(eventTimeout);
|
if (!eventsReceivedLatch.await(eventTimeout, TimeUnit.MILLISECONDS)) {
|
||||||
if (eventHandler.isAlive()) {
|
log.complain("FAILURE 20: Timeout waiting for all events was exceeded");
|
||||||
log.complain("FAILURE 20: Timeout for waiting event was exceeded");
|
|
||||||
eventHandler.interrupt();
|
|
||||||
testFailed = true;
|
testFailed = true;
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -171,8 +171,8 @@ public class thrdeathreq001 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int quitDebuggee() {
|
private int quitDebuggee() {
|
||||||
|
pipe.println(COMMAND_QUIT);
|
||||||
if (elThread != null) {
|
if (elThread != null) {
|
||||||
elThread.isConnected = false;
|
|
||||||
try {
|
try {
|
||||||
if (elThread.isAlive())
|
if (elThread.isAlive())
|
||||||
elThread.join();
|
elThread.join();
|
||||||
@ -183,7 +183,6 @@ public class thrdeathreq001 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe.println(COMMAND_QUIT);
|
|
||||||
debuggee.waitFor();
|
debuggee.waitFor();
|
||||||
int debStat = debuggee.getStatus();
|
int debStat = debuggee.getStatus();
|
||||||
if (debStat != (JCK_STATUS_BASE + PASSED)) {
|
if (debStat != (JCK_STATUS_BASE + PASSED)) {
|
||||||
@ -198,32 +197,26 @@ public class thrdeathreq001 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class EventListener extends Thread {
|
class EventListener extends Thread {
|
||||||
public volatile boolean isConnected = true;
|
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
boolean isConnected = true;
|
||||||
do {
|
do {
|
||||||
EventSet eventSet = vm.eventQueue().remove(1000);
|
EventSet eventSet = vm.eventQueue().remove(1000);
|
||||||
if (eventSet != null) { // there is not a timeout
|
if (eventSet != null) { // there is not a timeout
|
||||||
EventIterator it = eventSet.eventIterator();
|
EventIterator it = eventSet.eventIterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Event event = it.nextEvent();
|
Event event = it.nextEvent();
|
||||||
if (event instanceof VMDeathEvent) {
|
if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
|
||||||
tot_res = FAILED;
|
log.display("EventListener: got " + event);
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
log.complain("TEST FAILED: unexpected VMDeathEvent");
|
} else {
|
||||||
} else if (event instanceof VMDisconnectEvent) {
|
|
||||||
tot_res = FAILED;
|
|
||||||
isConnected = false;
|
|
||||||
log.complain("TEST FAILED: unexpected VMDisconnectEvent");
|
|
||||||
} else
|
|
||||||
log.display("EventListener: following JDI event occured: "
|
log.display("EventListener: following JDI event occured: "
|
||||||
+ event.toString());
|
+ event.toString());
|
||||||
}
|
|
||||||
if (isConnected) {
|
|
||||||
eventSet.resume();
|
eventSet.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} while (isConnected);
|
} while (isConnected);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
tot_res = FAILED;
|
tot_res = FAILED;
|
||||||
|
Loading…
Reference in New Issue
Block a user