From 5d1be8f620f2a05102023f1def6125174c3fcf78 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sat, 5 Feb 2011 04:23:59 +0000 Subject: [PATCH] Bug 335324: Prepare JUnit tests for the container (process) being the breakpointTarget context --- .../cdt/tests/dsf/gdb/framework/SyncUtil.java | 26 +++++++++++-------- .../dsf/gdb/tests/MIBreakpointsTest.java | 11 ++++---- .../dsf/gdb/tests/MICatchpointsTest.java | 12 +++++---- .../GDBRemoteTracepointsTest_7_0.java | 15 ++++++----- 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java index 72902ee2afe..f2ec7530a88 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java @@ -73,8 +73,6 @@ public class SyncUtil { private static DsfSession fSession; private static CommandFactory fCommandFactory; - - private static IBreakpointsTargetDMContext fBreakpointsDmc; private static IGDBProcesses fProcessesService; // Initialize some common things, once the session has been established @@ -93,9 +91,7 @@ public class SyncUtil { fExpressions = tracker.getService(IExpressions.class); fProcessesService = tracker.getService(IGDBProcesses.class); fCommandFactory = fGdbControl.getCommandFactory(); - - fBreakpointsDmc = (IBreakpointsTargetDMContext)fGdbControl.getContext(); - + tracker.dispose(); } }; @@ -224,12 +220,14 @@ public class SyncUtil { public static int addBreakpoint(final String location, final boolean temporary, int timeout) throws Throwable { - + IContainerDMContext containerDmc = SyncUtil.getContainerContext(); + final IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); + Query query = new Query() { @Override protected void execute(DataRequestMonitor rm) { fGdbControl.queueCommand( - fCommandFactory.createMIBreakInsert(fBreakpointsDmc, temporary, false, null, 0, location, 0), + fCommandFactory.createMIBreakInsert(bpTargetDmc, temporary, false, null, 0, location, 0), rm); } }; @@ -241,10 +239,13 @@ public class SyncUtil { public static int[] getBreakpointList(int timeout) throws Throwable { - Query query = new Query() { + IContainerDMContext containerDmc = SyncUtil.getContainerContext(); + final IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); + + Query query = new Query() { @Override protected void execute(DataRequestMonitor rm) { - fGdbControl.queueCommand(fCommandFactory.createMIBreakList(fBreakpointsDmc), rm); + fGdbControl.queueCommand(fCommandFactory.createMIBreakList(bpTargetDmc), rm); } }; @@ -264,11 +265,14 @@ public class SyncUtil { } public static void deleteBreakpoint(final int[] breakpointIndices, int timeout) throws Throwable { - Query query = new Query() { + IContainerDMContext containerDmc = SyncUtil.getContainerContext(); + final IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); + + Query query = new Query() { @Override protected void execute(DataRequestMonitor rm) { fGdbControl.queueCommand( - fCommandFactory.createMIBreakDelete(fBreakpointsDmc, breakpointIndices), + fCommandFactory.createMIBreakDelete(bpTargetDmc, breakpointIndices), rm); } }; diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java index 9cfc4bd01dc..ebd91a9412b 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java @@ -21,6 +21,7 @@ import java.util.Map; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.service.IBreakpoints; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext; @@ -34,8 +35,8 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; import org.eclipse.cdt.dsf.debug.service.IFormattedValues; import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext; import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData; +import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; -import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.internal.DsfPlugin; import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; @@ -185,10 +186,6 @@ public class MIBreakpointsTest extends BaseTestCase { public void run() { fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId()); assert(fServicesTracker != null); - - ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class); - fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext(); - assert(fBreakpointsDmc != null); fRunControl = fServicesTracker.getService(MIRunControl.class); assert(fRunControl != null); @@ -206,6 +203,10 @@ public class MIBreakpointsTest extends BaseTestCase { } }; fSession.getExecutor().submit(runnable).get(); + + IContainerDMContext containerDmc = SyncUtil.getContainerContext(); + fBreakpointsDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); + assert(fBreakpointsDmc != null); } @After diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MICatchpointsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MICatchpointsTest.java index 52e53d48d38..5cea8052955 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MICatchpointsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MICatchpointsTest.java @@ -27,6 +27,7 @@ import java.util.Map; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.service.IBreakpoints; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext; @@ -40,8 +41,8 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; import org.eclipse.cdt.dsf.debug.service.IFormattedValues; import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext; import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData; +import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; -import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.internal.DsfPlugin; import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; @@ -166,10 +167,6 @@ public class MICatchpointsTest extends BaseTestCase { public void run() { fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId()); assertNotNull(fServicesTracker); - - ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class); - fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext(); - assertNotNull(fBreakpointsDmc); fRunControl = fServicesTracker.getService(MIRunControl.class); assertNotNull(fRunControl); @@ -188,6 +185,11 @@ public class MICatchpointsTest extends BaseTestCase { } }; fSession.getExecutor().submit(runnable).get(); + + IContainerDMContext containerDmc = SyncUtil.getContainerContext(); + fBreakpointsDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); + assertNotNull(fBreakpointsDmc); + } @After diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java index 5bbb99fbe93..5370d37bad3 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java @@ -20,6 +20,7 @@ import java.util.Map; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.debug.service.IBreakpoints; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMData; @@ -27,7 +28,7 @@ import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsAddedEvent; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsRemovedEvent; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsUpdatedEvent; -import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; +import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; @@ -37,6 +38,7 @@ 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.BaseTestCase; +import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; import org.junit.After; @@ -125,11 +127,6 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { public void run() { fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId()); - ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class); - fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext(); - assert(fBreakpointsDmc != null); - -// fTraceTargetDmc = (ITraceTargetDMContext)commandControl.getContext(); fBreakpointService = fServicesTracker.getService(IBreakpoints.class); // fTraceService = fServicesTracker.getService(ITraceControl.class); @@ -143,6 +140,12 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { } }; fSession.getExecutor().submit(runnable).get(); + + IContainerDMContext containerDmc = SyncUtil.getContainerContext(); + fBreakpointsDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); + assert(fBreakpointsDmc != null); +// fTraceTargetDmc = DMContexts.getAncestorOfType(containerDmc, ITraceTargetDMContext.class); + } @After