From be1c53102bd9c809c4602a02b8978257ce6b6061 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 25 Apr 2011 16:02:27 +0000 Subject: [PATCH] Bug 343745: JUnit tests can be delayed 2 seconds unnecessarily --- .../cdt/tests/dsf/gdb/framework/BaseTestCase.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java index 962bfcf3816..381d5d4a2cb 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java @@ -177,13 +177,16 @@ public class BaseTestCase { fLaunch = (GdbLaunch)lc.launch(ILaunchManager.DEBUG_MODE, new NullProgressMonitor()); DsfSession.removeSessionStartedListener(sessionStartedListener); - // Wait for the program to hit the breakpoint at main() before + // If we haven't hit main() yet, + // wait for the program to hit the breakpoint at main() before // proceeding. All tests assume that stable initial state. Two // seconds is plenty; we typically get to that state in a few // hundred milliseconds with the tiny test programs we use. - synchronized (fTargetSuspendedSem) { - fTargetSuspendedSem.wait(TestsPlugin.massageTimeout(2000)); - Assert.assertTrue(fTargetSuspended); + if (!fTargetSuspended) { + synchronized (fTargetSuspendedSem) { + fTargetSuspendedSem.wait(TestsPlugin.massageTimeout(2000)); + Assert.assertTrue(fTargetSuspended); + } } // This should be a given if the above check passes