diff options
author | Paul Pazderski | 2020-02-17 12:26:57 +0000 |
---|---|---|
committer | Paul Pazderski | 2020-02-17 14:10:37 +0000 |
commit | 5692fb7afd12f93763cb82d05aa276b2b510a903 (patch) | |
tree | ca3f6cd52765ac9fd874aa2ff08bbbfa7a3cec3c | |
parent | 6e2746047336862f17bf2e0a73cb95e43565a658 (diff) | |
download | eclipse.platform.debug-I20200217-1800.tar.gz eclipse.platform.debug-I20200217-1800.tar.xz eclipse.platform.debug-I20200217-1800.zip |
Bug 251642 - [Tests] Fix race condition in testTerminateTimeStampY20200219-1055Y20200219-0850Y20200218-1420Y20200218-1210Y20200218-0315Y20200218-0120X20200221-0440X20200221-0310X20200221-0050X20200220-1900X20200220-0700X20200219-1900X20200219-0700X20200219-0500X20200218-0510X20200217-1120S4_15_0_M3I20200219-1800I20200219-0600I20200218-1800I20200218-0600I20200217-1800
Process termination is recognized in a separate thread. Looking for
termination timestamp without waiting for termination is a bad idea.
Change-Id: I2fe934b898b689a7cfba9e2eaec4676bd97103cd
Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
-rw-r--r-- | org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java index 3dc17e159..837e0ef94 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java @@ -33,6 +33,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileSystem; import org.eclipse.core.resources.IContainer; @@ -53,6 +55,7 @@ import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.ILaunchesListener2; import org.eclipse.debug.core.Launch; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.internal.core.LaunchConfiguration; @@ -1207,14 +1210,40 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau public void testTerminateTimeStamp() throws Exception { ILaunchConfigurationWorkingCopy workingCopy = newConfiguration(null, "test-time-stamp"); //$NON-NLS-1$ ILaunch launch = workingCopy.launch(ILaunchManager.DEBUG_MODE, null); + AtomicBoolean launchTerminated = new AtomicBoolean(); + ILaunchesListener2 listener = new ILaunchesListener2() { + @Override + public void launchesRemoved(ILaunch[] launches) { + } + + @Override + public void launchesChanged(ILaunch[] launches) { + } + + @Override + public void launchesAdded(ILaunch[] launches) { + } + + @Override + public void launchesTerminated(ILaunch[] launches) { + for (ILaunch l : launches) { + if (l == launch) { + launchTerminated.set(true); + } + } + } + }; + DebugPlugin.getDefault().getLaunchManager().addLaunchListener(listener); IProcess process = null; try { process = DebugPlugin.newProcess(launch, new MockProcess(0), "test-terminate-timestamp"); + waitWhile(c -> !launchTerminated.get(), testTimeout, c -> "Launch did not finished"); String stamp = launch.getAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP); assertNotNull("missing time stamp", stamp); //$NON-NLS-1$ long lstamp = Long.parseLong(stamp); // should be a long - will throw NumberFormatException if not assertTrue("Time travel launch", lstamp <= System.currentTimeMillis()); } finally { + DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(listener); if (launch != null) { getLaunchManager().removeLaunch(launch); } |