mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
debug tests: Remove fWait field from GDBProcessesTest
Re-using the waitor between tests possibly a dependency between tests (e.g. on the order they are ran). It would be easy to forget to add an fWait.waitReset() to a test and break another test. It is safer to create a new one every time, while the performance hit is negligible. Change-Id: I404d240b29dddffb07899e7e529e7205282bd1d2 Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
This commit is contained in:
parent
a96fcd5a37
commit
3cf7241ccb
1 changed files with 24 additions and 52 deletions
|
@ -11,25 +11,24 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.tests.dsf.gdb.tests;
|
package org.eclipse.cdt.tests.dsf.gdb.tests;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.Query;
|
||||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
||||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.AsyncCompletionWaitor;
|
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
|
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
|
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
|
||||||
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
|
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
|
||||||
|
@ -51,12 +50,6 @@ public class GDBProcessesTest extends BaseTestCase {
|
||||||
|
|
||||||
private IMIProcesses fProcService;
|
private IMIProcesses fProcService;
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a waiter and a generic completion object. They will be used to
|
|
||||||
* wait for asynchronous call completion.
|
|
||||||
*/
|
|
||||||
private final AsyncCompletionWaitor fWait = new AsyncCompletionWaitor();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doBeforeTest() throws Exception {
|
public void doBeforeTest() throws Exception {
|
||||||
super.doBeforeTest();
|
super.doBeforeTest();
|
||||||
|
@ -95,45 +88,24 @@ public class GDBProcessesTest extends BaseTestCase {
|
||||||
* Get the process data for the current program. Process is executable name in case of GDB back end
|
* Get the process data for the current program. Process is executable name in case of GDB back end
|
||||||
*/
|
*/
|
||||||
public void getProcessData() throws InterruptedException, ExecutionException, TimeoutException {
|
public void getProcessData() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
|
final IProcessDMContext processContext = DMContexts.getAncestorOfType(
|
||||||
/*
|
SyncUtil.getContainerContext(), IProcessDMContext.class);
|
||||||
* Create a request monitor
|
Query<IThreadDMData> query = new Query<IThreadDMData>() {
|
||||||
*/
|
|
||||||
final DataRequestMonitor<IThreadDMData> rm =
|
|
||||||
new DataRequestMonitor<IThreadDMData>(fSession.getExecutor(), null) {
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleCompleted() {
|
protected void execute(DataRequestMonitor<IThreadDMData> rm) {
|
||||||
if (isSuccess()) {
|
fProcService.getExecutionData(processContext, rm);
|
||||||
fWait.setReturnInfo(getData());
|
|
||||||
}
|
|
||||||
fWait.waitFinished(getStatus());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
fProcService.getExecutor().execute(query);
|
||||||
* Ask the service to get model data for the process.
|
|
||||||
* There is only one process in case of GDB back end.
|
|
||||||
*/
|
|
||||||
final IProcessDMContext processContext = DMContexts.getAncestorOfType(SyncUtil.getContainerContext(), IProcessDMContext.class);
|
|
||||||
fSession.getExecutor().submit(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
fProcService.getExecutionData(processContext, rm);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/*
|
|
||||||
* Wait for the operation to complete and validate success.
|
|
||||||
*/
|
|
||||||
fWait.waitUntilDone(TestsPlugin.massageTimeout(2000));
|
|
||||||
Assert.assertTrue(fWait.getMessage(), fWait.isOK());
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get process data. Name of the process is the executable name in case of GDB back-end.
|
* Get process data. Name of the process is the executable name in case of GDB back-end.
|
||||||
*/
|
*/
|
||||||
IThreadDMData processData = (IThreadDMData)fWait.getReturnInfo();
|
IThreadDMData processData = query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
|
||||||
Assert.assertNotNull("No process data is returned for Process DMC", processData);
|
Assert.assertNotNull("No process data is returned for Process DMC", processData);
|
||||||
Assert.assertTrue("Process data should be executable name " + EXEC_NAME + "but we got " + processData.getName(),
|
Assert.assertTrue("Process data should be executable name " + EXEC_NAME +
|
||||||
processData.getName().contains(EXEC_NAME));
|
"but we got " + processData.getName(), processData.getName().contains(EXEC_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue