mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Improve waitForBreakpointEvent()
This commit is contained in:
parent
88a1ce45c2
commit
d5d9a9ca34
1 changed files with 25 additions and 7 deletions
|
@ -309,20 +309,38 @@ public class MIBreakpointsTest extends BaseTestCase {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suspends the thread until an event is flagged
|
/**
|
||||||
// NOTE: too simple for real life but good enough for this test suite
|
* Suspends the calling thread until [count] number of breakpoint events
|
||||||
private void waitForBreakpointEvent(int count) {
|
* have been received in the current test. NOTE: too simple for real life
|
||||||
|
* but good enough for this test suite
|
||||||
|
*
|
||||||
|
* @param count
|
||||||
|
* the number breakpoint events to wait for
|
||||||
|
* @param timeout
|
||||||
|
* max wait time, in milliseconds
|
||||||
|
*/
|
||||||
|
private void waitForBreakpointEvent(int count, int timeout) throws Exception {
|
||||||
|
long startMs = System.currentTimeMillis();
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
// Make sure we don't wait forever, in case an event never
|
// Make sure we don't wait forever, in case an event never
|
||||||
// arrives. The test will check if everything was received
|
// arrives. The test will check if everything was received
|
||||||
int loopIndex = 0;
|
while (fBreakpointEventCount < count) {
|
||||||
while (fBreakpointEventCount < count && loopIndex++ < 4) {
|
|
||||||
try {
|
try {
|
||||||
lock.wait(500);
|
lock.wait(30);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
}
|
}
|
||||||
|
if (System.currentTimeMillis() - startMs > timeout) {
|
||||||
|
throw new Exception("Timed out waiting for " + count + " breakpoint events to occur. Only " + fBreakpointEventCount + " occurred.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simplified variant that just waits up to two seconds
|
||||||
|
*/
|
||||||
|
private void waitForBreakpointEvent(int count) throws Exception {
|
||||||
|
waitForBreakpointEvent(count, TestsPlugin.massageTimeout(2000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue