mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Bug 346789: fix startup sequence for remote JUnits tests
This commit is contained in:
parent
2810e3a1fc
commit
7f07eb597c
1 changed files with 42 additions and 22 deletions
|
@ -18,10 +18,12 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.dsf.datamodel.IDMEvent;
|
import org.eclipse.cdt.dsf.datamodel.IDMEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension.IBreakpointHitDMEvent;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||||
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
|
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
||||||
|
import org.eclipse.cdt.dsf.mi.service.command.events.IMIDMEvent;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
|
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
|
||||||
|
import org.eclipse.cdt.dsf.mi.service.command.output.MIFrame;
|
||||||
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession.SessionStartedListener;
|
import org.eclipse.cdt.dsf.service.DsfSession.SessionStartedListener;
|
||||||
|
@ -115,28 +117,46 @@ public class BaseTestCase {
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(IDMEvent<?> event) {
|
public void eventDispatched(IDMEvent<?> event) {
|
||||||
if (event instanceof MIStoppedEvent) {
|
// Wait for the program to have stopped on main.
|
||||||
// We get this low-level event first. Record the MI event; various
|
//
|
||||||
// tests use it for context
|
// We have to jump through hoops to properly handle the remote
|
||||||
synchronized(this) {
|
// case, because of differences between GDB <= 68 and GDB >= 7.0.
|
||||||
fInitialStoppedEvent = (MIStoppedEvent)event;
|
//
|
||||||
}
|
// With GDB >= 7.0, when connecting to the remote gdbserver,
|
||||||
}
|
// we get a first *stopped event at connection time. This is
|
||||||
else if (event instanceof IBreakpointHitDMEvent) {
|
// not the ISuspendedDMEvent event we want. We could instead
|
||||||
// We need to wait for a breakpoint event, not just a suspended event,
|
// listen for an IBreakpointHitDMEvent instead.
|
||||||
// this is because for remote tests, there is a suspended event when
|
// However, with GDB <= 6.8, temporary breakpoints are not
|
||||||
// we connect, and then, there is the breakpoint event at main()
|
// reported as breakpoint-hit, so we don't get an IBreakpointHitDMEvent
|
||||||
|
// for GDB <= 6.8.
|
||||||
// We get this higher level event shortly thereafter. We don't want
|
//
|
||||||
// to consider the session suspended until we get it. Set the event
|
// What I found to be able to know we have stopped at main, in all cases,
|
||||||
// semaphore that will allow the test to proceed
|
// is to look for an ISuspendedDMEvent and then confirming that it indicates
|
||||||
synchronized (fTargetSuspendedSem) {
|
// in its frame that it stopped at "main". This will allow us to skip
|
||||||
fTargetSuspended = true;
|
// the first *stopped event for GDB >= 7.0
|
||||||
fTargetSuspendedSem.notify();
|
if (event instanceof ISuspendedDMEvent) {
|
||||||
}
|
if (event instanceof IMIDMEvent) {
|
||||||
|
IMIDMEvent iMIEvent = (IMIDMEvent)event;
|
||||||
|
|
||||||
// no further need for this listener. Note fLaunch could be null if the test ran into a failure
|
Object miEvent = iMIEvent.getMIEvent();
|
||||||
fSession.removeServiceEventListener(this);
|
if (miEvent instanceof MIStoppedEvent) {
|
||||||
|
// Store the corresponding MI *stopped event
|
||||||
|
fInitialStoppedEvent = (MIStoppedEvent)miEvent;
|
||||||
|
|
||||||
|
// Check the content of the frame for "main"
|
||||||
|
MIFrame frame = fInitialStoppedEvent.getFrame();
|
||||||
|
if (frame != null && "main".equals(frame.getFunction())) {
|
||||||
|
// Set the event semaphore that will allow the test to proceed
|
||||||
|
synchronized (fTargetSuspendedSem) {
|
||||||
|
fTargetSuspended = true;
|
||||||
|
fTargetSuspendedSem.notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
// We found our event, no further need for this listener
|
||||||
|
fSession.removeServiceEventListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue