mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
update test to Eclipse 3.0
This commit is contained in:
parent
1662c1895f
commit
6b222b30ad
5 changed files with 637 additions and 631 deletions
|
@ -1,11 +1,9 @@
|
||||||
package org.eclipse.cdt.debug.core.tests;
|
package org.eclipse.cdt.debug.core.tests;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
@ -43,31 +41,32 @@ import org.eclipse.core.runtime.Path;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BreakpointTests extends TestCase {
|
public class BreakpointTests extends TestCase {
|
||||||
|
|
||||||
IWorkspace workspace;
|
IWorkspace workspace;
|
||||||
IWorkspaceRoot root;
|
IWorkspaceRoot root;
|
||||||
static ICProject testProject=null;
|
static ICProject testProject = null;
|
||||||
NullProgressMonitor monitor;
|
NullProgressMonitor monitor;
|
||||||
static ICDISession session=null;
|
static ICDISession session = null;
|
||||||
static ICDITarget targets[] = null;
|
static ICDITarget targets[] = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for BreakpointTests
|
* Constructor for BreakpointTests
|
||||||
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public BreakpointTests(String name) {
|
public BreakpointTests(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
/***
|
/***********************************************************************
|
||||||
* The tests assume that they have a working workspace
|
* The tests assume that they have a working workspace and workspace
|
||||||
* and workspace root object to use to create projects/files in,
|
* root object to use to create projects/files in, so we need to get
|
||||||
* so we need to get them setup first.
|
* them setup first.
|
||||||
*/
|
*/
|
||||||
workspace= ResourcesPlugin.getWorkspace();
|
workspace = ResourcesPlugin.getWorkspace();
|
||||||
root= workspace.getRoot();
|
root = workspace.getRoot();
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
if (workspace==null)
|
if (workspace == null)
|
||||||
fail("Workspace was not setup");
|
fail("Workspace was not setup");
|
||||||
if (root==null)
|
if (root == null)
|
||||||
fail("Workspace root was not setup");
|
fail("Workspace root was not setup");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -82,35 +81,37 @@ public class BreakpointTests extends TestCase {
|
||||||
*/
|
*/
|
||||||
protected static void oneTimeSetUp() throws CoreException, InvocationTargetException, IOException {
|
protected static void oneTimeSetUp() throws CoreException, InvocationTargetException, IOException {
|
||||||
ResourcesPlugin.getWorkspace().getDescription().setAutoBuilding(false);
|
ResourcesPlugin.getWorkspace().getDescription().setAutoBuilding(false);
|
||||||
/***
|
/***********************************************************************
|
||||||
* Create a new project and import the test source.
|
* Create a new project and import the test source.
|
||||||
*/
|
*/
|
||||||
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.debug.ui.tests").find(new Path("/")).getFile();
|
Path imputFile = new Path("resources/debugTest.zip");
|
||||||
pluginRoot=pluginRoot+"resources/debugTest.zip";
|
testProject = CProjectHelper.createCProjectWithImport("filetest", imputFile);
|
||||||
testProject=CProjectHelper.createCProjectWithImport("filetest", pluginRoot);
|
if (testProject == null)
|
||||||
if (testProject==null)
|
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
/* Build the test project.. */
|
/* Build the test project.. */
|
||||||
|
|
||||||
testProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
|
testProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tears down the test fixture.
|
* Tears down the test fixture.
|
||||||
*
|
*
|
||||||
* Called after every test case method.
|
* Called after every test case method.
|
||||||
*/
|
*/
|
||||||
protected void tearDown() throws CoreException {
|
protected void tearDown() throws CoreException {
|
||||||
if (targets!=null) {
|
if (targets != null) {
|
||||||
try {
|
try {
|
||||||
targets[0].terminate();
|
targets[0].terminate();
|
||||||
targets=null;
|
targets = null;
|
||||||
} catch (CDIException e) {}
|
} catch (CDIException e) {
|
||||||
}
|
}
|
||||||
if (session!=null) {
|
}
|
||||||
|
if (session != null) {
|
||||||
try {
|
try {
|
||||||
session.terminate();
|
session.terminate();
|
||||||
session=null;
|
session = null;
|
||||||
} catch (CDIException e) {}
|
} catch (CDIException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,33 +121,36 @@ public class BreakpointTests extends TestCase {
|
||||||
* Called after every test case method.
|
* Called after every test case method.
|
||||||
*/
|
*/
|
||||||
protected static void oneTimeTearDown() throws CoreException {
|
protected static void oneTimeTearDown() throws CoreException {
|
||||||
if (targets!=null) {
|
if (targets != null) {
|
||||||
try {
|
try {
|
||||||
targets[0].terminate();
|
targets[0].terminate();
|
||||||
} catch (CDIException e) {}
|
} catch (CDIException e) {
|
||||||
}
|
}
|
||||||
if (session!=null) {
|
}
|
||||||
|
if (session != null) {
|
||||||
try {
|
try {
|
||||||
session.terminate();
|
session.terminate();
|
||||||
} catch (CDIException e) {}
|
} catch (CDIException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CProjectHelper.delete(testProject);
|
CProjectHelper.delete(testProject);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite= new TestSuite(BreakpointTests.class);
|
TestSuite suite = new TestSuite(BreakpointTests.class);
|
||||||
/***
|
/***********************************************************************
|
||||||
* Create a wrapper suite around the test suite we created above to
|
* Create a wrapper suite around the test suite we created above to
|
||||||
* allow us to only do the general setup once for all the tests. This
|
* allow us to only do the general setup once for all the tests. This is
|
||||||
* is needed because the creation of the source and target projects
|
* needed because the creation of the source and target projects takes a
|
||||||
* takes a long time and we really only need to do it once. We could
|
* long time and we really only need to do it once. We could do the
|
||||||
* do the setup in the constructor, but we need to be able to remove
|
* setup in the constructor, but we need to be able to remove everything
|
||||||
* everything when we are done.
|
* when we are done.
|
||||||
*/
|
*/
|
||||||
TestSetup wrapper = new TestSetup(suite) {
|
TestSetup wrapper = new TestSetup(suite) {
|
||||||
|
|
||||||
protected void setUp() throws FileNotFoundException, IOException, InterruptedException, InvocationTargetException, CoreException {
|
protected void setUp() throws FileNotFoundException, IOException, InterruptedException, InvocationTargetException,
|
||||||
|
CoreException {
|
||||||
oneTimeSetUp();
|
oneTimeSetUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,12 +158,10 @@ public class BreakpointTests extends TestCase {
|
||||||
oneTimeTearDown();
|
oneTimeTearDown();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return(wrapper);
|
return (wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
/***
|
|
||||||
* A couple tests to make sure setting breakpoints on functions works as
|
* A couple tests to make sure setting breakpoints on functions works as
|
||||||
* expected.
|
* expected.
|
||||||
*/
|
*/
|
||||||
|
@ -167,60 +169,61 @@ public class BreakpointTests extends TestCase {
|
||||||
ICDISession session;
|
ICDISession session;
|
||||||
ICDIBreakpointManager breaks;
|
ICDIBreakpointManager breaks;
|
||||||
ICDILocation location;
|
ICDILocation location;
|
||||||
boolean caught=false;
|
boolean caught = false;
|
||||||
session=CDebugHelper.createSession("main", testProject);
|
session = CDebugHelper.createSession("main", testProject);
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
breaks=session.getBreakpointManager();
|
breaks = session.getBreakpointManager();
|
||||||
assertNotNull(breaks);
|
assertNotNull(breaks);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on a generic function
|
* Create a break point on a generic function
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location=breaks.createLocation(null, "func1", 0);
|
location = breaks.createLocation(null, "func1", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on main
|
* Create a break point on main
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location=breaks.createLocation(null, "main", 0);
|
location = breaks.createLocation(null, "main", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
/**********************************************************************
|
* Try to create a break point on a function name that does not exist We
|
||||||
* Try to create a break point on a function name that does not exist
|
* expect that this will cause the setLocationBreakpoint to throw a
|
||||||
* We expect that this will cause the setLocationBreakpoint to throw
|
* CDIException
|
||||||
* a CDIException
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location=breaks.createLocation(null, "badname", 0);
|
location = breaks.createLocation(null, "badname", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
try {
|
try {
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
caught=true;
|
caught = true;
|
||||||
}
|
}
|
||||||
assertTrue(caught);
|
assertTrue(caught);
|
||||||
|
|
||||||
breaks.deleteAllBreakpoints();
|
breaks.deleteAllBreakpoints();
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on a generic function and see if it will
|
* Create a break point on a generic function and see if it will get hit
|
||||||
* get hit and stop program execution.
|
* and stop program execution.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location=breaks.createLocation(null, "func1", 0);
|
location = breaks.createLocation(null, "func1", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
targets=session.getTargets();
|
targets = session.getTargets();
|
||||||
/* We better only have one target connected to this session or something
|
/*
|
||||||
|
* We better only have one target connected to this session or something
|
||||||
* is not right...
|
* is not right...
|
||||||
*/
|
*/
|
||||||
assertTrue(targets.length==1);
|
assertTrue(targets.length == 1);
|
||||||
/* Resume the target, this should cause it to run till it hits the
|
/*
|
||||||
|
* Resume the target, this should cause it to run till it hits the
|
||||||
* breakpoint
|
* breakpoint
|
||||||
*/
|
*/
|
||||||
targets[0].resume();
|
targets[0].resume();
|
||||||
|
@ -229,121 +232,120 @@ public class BreakpointTests extends TestCase {
|
||||||
* suspended. It sould hit the breakponint almost immediatly so we
|
* suspended. It sould hit the breakponint almost immediatly so we
|
||||||
* should only sleep for max 100 ms
|
* should only sleep for max 100 ms
|
||||||
*/
|
*/
|
||||||
for (int x=0;x<100;x++) {
|
for (int x = 0; x < 100; x++) {
|
||||||
if (targets[0].isTerminated() || targets[0].isSuspended())
|
if (targets[0].isTerminated() || targets[0].isSuspended())
|
||||||
break;
|
break;
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
assertTrue(targets[0].isSuspended());
|
assertTrue(targets[0].isSuspended());
|
||||||
location=targets[0].getCurrentThread().getStackFrames()[0].getLocation();
|
location = targets[0].getCurrentThread().getStackFrames()[0].getLocation();
|
||||||
assertTrue(location.getLineNumber()==6);
|
assertTrue(location.getLineNumber() == 6);
|
||||||
assertTrue(location.getFunction().equals("func1"));
|
assertTrue(location.getFunction().equals("func1"));
|
||||||
assertTrue(location.getFile().equals("main.c"));
|
assertTrue(location.getFile().equals("main.c"));
|
||||||
|
|
||||||
/* clean up the session */
|
/* clean up the session */
|
||||||
targets[0].terminate();
|
targets[0].terminate();
|
||||||
int x=0;
|
int x = 0;
|
||||||
while ((!targets[0].isTerminated()) && (x<30)) {
|
while ((!targets[0].isTerminated()) && (x < 30)) {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
if (!targets[0].isTerminated())
|
if (!targets[0].isTerminated())
|
||||||
targets[0].terminate();
|
targets[0].terminate();
|
||||||
session.terminate();
|
session.terminate();
|
||||||
session=null;
|
session = null;
|
||||||
targets=null;
|
targets = null;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***************************************************************************
|
||||||
* A couple tests to make sure setting breakpoints on line numbers works as
|
* A couple tests to make sure setting breakpoints on line numbers works as
|
||||||
* expected.
|
* expected.
|
||||||
*/
|
*/
|
||||||
public void testLineBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException {
|
public void testLineBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException {
|
||||||
ICDIBreakpointManager breaks;
|
ICDIBreakpointManager breaks;
|
||||||
ICDILocation location;
|
ICDILocation location;
|
||||||
boolean caught=false;
|
boolean caught = false;
|
||||||
session=CDebugHelper.createSession("main", testProject);
|
session = CDebugHelper.createSession("main", testProject);
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
breaks=session.getBreakpointManager();
|
breaks = session.getBreakpointManager();
|
||||||
assertNotNull(breaks);
|
assertNotNull(breaks);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point in a generic function
|
* Create a break point in a generic function
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
location=breaks.createLocation("main.c", null, 7);
|
location = breaks.createLocation("main.c", null, 7);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
/**********************************************************************
|
|
||||||
* Create a break point in main
|
* Create a break point in main
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
location=breaks.createLocation("main.c", null, 18);
|
location = breaks.createLocation("main.c", null, 18);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
/**********************************************************************
|
* Try to create a break point on a line that does not exist We expect
|
||||||
* Try to create a break point on a line that does not exist
|
* that this will cause the setLocationBreakpoint to throw a
|
||||||
* We expect that this will cause the setLocationBreakpoint to throw
|
* CDIException
|
||||||
* a CDIException
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location=breaks.createLocation("main.c", null, 30);
|
location = breaks.createLocation("main.c", null, 30);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
try {
|
try {
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
caught=true;
|
caught = true;
|
||||||
}
|
}
|
||||||
assertTrue(caught);
|
assertTrue(caught);
|
||||||
|
|
||||||
caught=false;
|
caught = false;
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Try to create a break point on a line that does not have code on it
|
* Try to create a break point on a line that does not have code on it
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location=breaks.createLocation("main.c", null, 11);
|
location = breaks.createLocation("main.c", null, 11);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point in a generic function without passing the source
|
* Create a break point in a generic function without passing the source
|
||||||
* file name. At the time of writing this would just silently fail, so
|
* file name. At the time of writing this would just silently fail, so
|
||||||
* to make sure it works, we will do it once with a valid line number
|
* to make sure it works, we will do it once with a valid line number
|
||||||
* and once with an invalid line number, and the first should always
|
* and once with an invalid line number, and the first should always
|
||||||
* succeed and the second should always throw an exception.
|
* succeed and the second should always throw an exception.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
location=breaks.createLocation(null, null, 7);
|
location = breaks.createLocation(null, null, 7);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
caught=false;
|
caught = false;
|
||||||
location=breaks.createLocation(null, null, 30);
|
location = breaks.createLocation(null, null, 30);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
try {
|
try {
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
caught=true;
|
caught = true;
|
||||||
}
|
}
|
||||||
assertTrue("Ignoring line numbers with no file specified?", caught);
|
assertTrue("Ignoring line numbers with no file specified?", caught);
|
||||||
|
|
||||||
breaks.deleteAllBreakpoints();
|
breaks.deleteAllBreakpoints();
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on a line number and see if it will
|
* Create a break point on a line number and see if it will get hit and
|
||||||
* get hit and stop program execution.
|
* stop program execution.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
location=breaks.createLocation(null, null, 7);
|
location = breaks.createLocation(null, null, 7);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
targets=session.getTargets();
|
targets = session.getTargets();
|
||||||
/* We better only have one target connected to this session or something
|
/*
|
||||||
|
* We better only have one target connected to this session or something
|
||||||
* is not right...
|
* is not right...
|
||||||
*/
|
*/
|
||||||
assertTrue(targets.length==1);
|
assertTrue(targets.length == 1);
|
||||||
/* Resume the target, this should cause it to run till it hits the
|
/*
|
||||||
|
* Resume the target, this should cause it to run till it hits the
|
||||||
* breakpoint
|
* breakpoint
|
||||||
*/
|
*/
|
||||||
targets[0].resume();
|
targets[0].resume();
|
||||||
|
@ -352,25 +354,26 @@ public class BreakpointTests extends TestCase {
|
||||||
* suspended. It sould hit the breakponint almost immediatly so we
|
* suspended. It sould hit the breakponint almost immediatly so we
|
||||||
* should only sleep for max 100 ms
|
* should only sleep for max 100 ms
|
||||||
*/
|
*/
|
||||||
for (int x=0;x<100;x++) {
|
for (int x = 0; x < 100; x++) {
|
||||||
if (targets[0].isSuspended() || targets[0].isTerminated())
|
if (targets[0].isSuspended() || targets[0].isTerminated())
|
||||||
break;
|
break;
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
assertTrue("Suspended: " + targets[0].isSuspended() + " Termiunated: " + targets[0].isTerminated(), targets[0].isSuspended());
|
assertTrue("Suspended: " + targets[0].isSuspended() + " Termiunated: " + targets[0].isTerminated(), targets[0]
|
||||||
location=targets[0].getCurrentThread().getStackFrames()[0].getLocation();
|
.isSuspended());
|
||||||
assertTrue(location.getLineNumber()==7);
|
location = targets[0].getCurrentThread().getStackFrames()[0].getLocation();
|
||||||
|
assertTrue(location.getLineNumber() == 7);
|
||||||
assertTrue(location.getFunction().equals("func1"));
|
assertTrue(location.getFunction().equals("func1"));
|
||||||
assertTrue(location.getFile().equals("main.c"));
|
assertTrue(location.getFile().equals("main.c"));
|
||||||
|
|
||||||
|
|
||||||
/* clean up the session */
|
/* clean up the session */
|
||||||
session.terminate();
|
session.terminate();
|
||||||
session=null;
|
session = null;
|
||||||
targets=null;
|
targets = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
/***
|
|
||||||
|
/***************************************************************************
|
||||||
* A couple tests to make sure getting breakpoints works as expected
|
* A couple tests to make sure getting breakpoints works as expected
|
||||||
*/
|
*/
|
||||||
public void testGetBreak() throws CoreException, MIException, IOException, CDIException {
|
public void testGetBreak() throws CoreException, MIException, IOException, CDIException {
|
||||||
|
@ -378,69 +381,69 @@ public class BreakpointTests extends TestCase {
|
||||||
ICDILocation location;
|
ICDILocation location;
|
||||||
ICDIBreakpoint[] breakpoints;
|
ICDIBreakpoint[] breakpoints;
|
||||||
ICDILocationBreakpoint curbreak;
|
ICDILocationBreakpoint curbreak;
|
||||||
session=CDebugHelper.createSession("main", testProject);
|
session = CDebugHelper.createSession("main", testProject);
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
breaks=session.getBreakpointManager();
|
breaks = session.getBreakpointManager();
|
||||||
assertNotNull(breaks);
|
assertNotNull(breaks);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Make sure initially we don't have any breakpoints
|
* Make sure initially we don't have any breakpoints
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertNotNull(breakpoints);
|
assertNotNull(breakpoints);
|
||||||
assertTrue(breakpoints.length==0);
|
assertTrue(breakpoints.length == 0);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Make sure if we create a simple breakpoint, that we can get it back
|
* Make sure if we create a simple breakpoint, that we can get it back
|
||||||
* from the system
|
* from the system
|
||||||
*********************************************************************/
|
**********************************************************************/
|
||||||
/* Create a break point on a generic function */
|
/* Create a break point on a generic function */
|
||||||
location=breaks.createLocation("main.c", "func1", 0);
|
location = breaks.createLocation("main.c", "func1", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
|
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertNotNull(breakpoints);
|
assertNotNull(breakpoints);
|
||||||
assertTrue(breakpoints.length==1);
|
assertTrue(breakpoints.length == 1);
|
||||||
if (breakpoints[0] instanceof ICDILocationBreakpoint) {
|
if (breakpoints[0] instanceof ICDILocationBreakpoint) {
|
||||||
curbreak=(ICDILocationBreakpoint) breakpoints[0];
|
curbreak = (ICDILocationBreakpoint) breakpoints[0];
|
||||||
} else
|
} else
|
||||||
curbreak=null;
|
curbreak = null;
|
||||||
assertNotNull(curbreak);
|
assertNotNull(curbreak);
|
||||||
|
|
||||||
assertTrue(curbreak.getLocation().equals(location));
|
assertTrue(curbreak.getLocation().equals(location));
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Make sure if we create multiple break points that we can still
|
* Make sure if we create multiple break points that we can still get
|
||||||
* get them all back from the system,
|
* them all back from the system,
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/* Create another break point on main */
|
/* Create another break point on main */
|
||||||
location=breaks.createLocation("main.c", "main", 0);
|
location = breaks.createLocation("main.c", "main", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, null, null);
|
breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
|
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertNotNull(breakpoints);
|
assertNotNull(breakpoints);
|
||||||
assertTrue(breakpoints.length==2);
|
assertTrue(breakpoints.length == 2);
|
||||||
if (breakpoints[1] instanceof ICDILocationBreakpoint) {
|
if (breakpoints[1] instanceof ICDILocationBreakpoint) {
|
||||||
curbreak=(ICDILocationBreakpoint) breakpoints[1];
|
curbreak = (ICDILocationBreakpoint) breakpoints[1];
|
||||||
} else
|
} else
|
||||||
curbreak=null;
|
curbreak = null;
|
||||||
assertNotNull(curbreak);
|
assertNotNull(curbreak);
|
||||||
/* Make sure the location still looks like we expect it to..
|
/*
|
||||||
. */
|
* Make sure the location still looks like we expect it to.. .
|
||||||
|
*/
|
||||||
assertTrue(curbreak.getLocation().equals(location));
|
assertTrue(curbreak.getLocation().equals(location));
|
||||||
|
|
||||||
breaks.deleteAllBreakpoints();
|
breaks.deleteAllBreakpoints();
|
||||||
|
|
||||||
|
|
||||||
/* clean up the session */
|
/* clean up the session */
|
||||||
session.terminate();
|
session.terminate();
|
||||||
session=null;
|
session = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***************************************************************************
|
||||||
* A couple tests to make sure deleting breakpoints works as expected
|
* A couple tests to make sure deleting breakpoints works as expected
|
||||||
*/
|
*/
|
||||||
public void testDelBreak() throws CoreException, MIException, IOException, CDIException {
|
public void testDelBreak() throws CoreException, MIException, IOException, CDIException {
|
||||||
|
@ -449,36 +452,36 @@ public class BreakpointTests extends TestCase {
|
||||||
ICDIBreakpoint[] breakpoints, savedbreakpoints;
|
ICDIBreakpoint[] breakpoints, savedbreakpoints;
|
||||||
ICDILocationBreakpoint curbreak;
|
ICDILocationBreakpoint curbreak;
|
||||||
|
|
||||||
session=CDebugHelper.createSession("main", testProject);
|
session = CDebugHelper.createSession("main", testProject);
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
breaks=session.getBreakpointManager();
|
breaks = session.getBreakpointManager();
|
||||||
assertNotNull(breaks);
|
assertNotNull(breaks);
|
||||||
|
|
||||||
/* Make sure initially we don't have any breakpoints */
|
/* Make sure initially we don't have any breakpoints */
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertNotNull(breakpoints);
|
assertNotNull(breakpoints);
|
||||||
assertTrue(breakpoints.length==0);
|
assertTrue(breakpoints.length == 0);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
* Test to make sure if we create a new breakpoint, we can delete
|
* Test to make sure if we create a new breakpoint, we can delete it by
|
||||||
* it by passing a refrence to it to deleteBreakpoint()
|
* passing a refrence to it to deleteBreakpoint()
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
/* Create a break point on a generic function */
|
/* Create a break point on a generic function */
|
||||||
location=breaks.createLocation("main.c", "func1", 0);
|
location = breaks.createLocation("main.c", "func1", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
curbreak=breaks.setLocationBreakpoint(0, location, null, null);
|
curbreak = breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
breaks.deleteBreakpoint(curbreak);
|
breaks.deleteBreakpoint(curbreak);
|
||||||
pause();
|
pause();
|
||||||
/**
|
/**
|
||||||
* we should not have any breakpoints left.
|
* we should not have any breakpoints left.
|
||||||
*/
|
*/
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertTrue(breakpoints.length==0);
|
assertTrue(breakpoints.length == 0);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
* Test to make sure if we create multiple new breakpoint, we can delete
|
* Test to make sure if we create multiple new breakpoint, we can delete
|
||||||
* one of them by passing a refrence to it to deleteBreakpoint()
|
* one of them by passing a refrence to it to deleteBreakpoint()
|
||||||
|
@ -486,118 +489,117 @@ public class BreakpointTests extends TestCase {
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
/* Create a break point on a generic function */
|
/* Create a break point on a generic function */
|
||||||
location=breaks.createLocation("main.c", "func1", 0);
|
location = breaks.createLocation("main.c", "func1", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
curbreak=breaks.setLocationBreakpoint(0, location, null, null);
|
curbreak = breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
savedLocation=curbreak.getLocation();
|
savedLocation = curbreak.getLocation();
|
||||||
|
|
||||||
location=breaks.createLocation("main.c", "main", 0);
|
location = breaks.createLocation("main.c", "main", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
curbreak=breaks.setLocationBreakpoint(0, location, null, null);
|
curbreak = breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
breaks.deleteBreakpoint(curbreak);
|
breaks.deleteBreakpoint(curbreak);
|
||||||
pause();
|
pause();
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
/***
|
/***********************************************************************
|
||||||
* Make sure there is only 1 breakpoint left, and it's the one we expect
|
* Make sure there is only 1 breakpoint left, and it's the one we expect
|
||||||
*/
|
*/
|
||||||
assertTrue(breakpoints.length==1);
|
assertTrue(breakpoints.length == 1);
|
||||||
curbreak=(ICDILocationBreakpoint) breakpoints[0];
|
curbreak = (ICDILocationBreakpoint) breakpoints[0];
|
||||||
assertNotNull(curbreak);
|
assertNotNull(curbreak);
|
||||||
assertTrue(curbreak.getLocation().equals(savedLocation));
|
assertTrue(curbreak.getLocation().equals(savedLocation));
|
||||||
/***
|
/***********************************************************************
|
||||||
* Then delete the other breakpoint.
|
* Then delete the other breakpoint.
|
||||||
*/
|
*/
|
||||||
breaks.deleteBreakpoint(curbreak);
|
breaks.deleteBreakpoint(curbreak);
|
||||||
pause();
|
pause();
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertTrue(breakpoints.length==0);
|
assertTrue(breakpoints.length == 0);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Make sure deleteBreakpoints works when given 1 breakpoint to delete
|
* Make sure deleteBreakpoints works when given 1 breakpoint to delete
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
savedbreakpoints= new ICDIBreakpoint[1];
|
savedbreakpoints = new ICDIBreakpoint[1];
|
||||||
for (int x=0;x<10;x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
location=breaks.createLocation("main.c", null, x+1);
|
location = breaks.createLocation("main.c", null, x + 1);
|
||||||
savedbreakpoints[0]=breaks.setLocationBreakpoint(0, location, null, null);
|
savedbreakpoints[0] = breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
assertNotNull(savedbreakpoints[0]);
|
assertNotNull(savedbreakpoints[0]);
|
||||||
}
|
}
|
||||||
breaks.deleteBreakpoints(savedbreakpoints);
|
breaks.deleteBreakpoints(savedbreakpoints);
|
||||||
pause();
|
pause();
|
||||||
/* We should now have 9 breakpoints left. */
|
/* We should now have 9 breakpoints left. */
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertTrue(breakpoints.length==9);
|
assertTrue(breakpoints.length == 9);
|
||||||
/* Make sure we have the correct 9 breakpoints left */
|
/* Make sure we have the correct 9 breakpoints left */
|
||||||
for (int x=0;x<breakpoints.length;x++) {
|
for (int x = 0; x < breakpoints.length; x++) {
|
||||||
curbreak=(ICDILocationBreakpoint)breakpoints[x];
|
curbreak = (ICDILocationBreakpoint) breakpoints[x];
|
||||||
assertTrue(curbreak.getLocation().getLineNumber()==x+1);
|
assertTrue(curbreak.getLocation().getLineNumber() == x + 1);
|
||||||
}
|
}
|
||||||
breaks.deleteAllBreakpoints();
|
breaks.deleteAllBreakpoints();
|
||||||
pause();
|
pause();
|
||||||
assertTrue(breaks.getBreakpoints().length==0);
|
assertTrue(breaks.getBreakpoints().length == 0);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Make sure deleteBreakpoints works when given more then 1 but less
|
* Make sure deleteBreakpoints works when given more then 1 but less
|
||||||
* then all breakpoints to delete
|
* then all breakpoints to delete
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
savedbreakpoints= new ICDIBreakpoint[4];
|
savedbreakpoints = new ICDIBreakpoint[4];
|
||||||
for (int x=0;x<10;x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
location=breaks.createLocation("main.c", null, x+1);
|
location = breaks.createLocation("main.c", null, x + 1);
|
||||||
savedbreakpoints[x%4]=breaks.setLocationBreakpoint(0, location, null, null);
|
savedbreakpoints[x % 4] = breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
assertNotNull(savedbreakpoints[x%4]);
|
assertNotNull(savedbreakpoints[x % 4]);
|
||||||
}
|
}
|
||||||
breaks.deleteBreakpoints(savedbreakpoints);
|
breaks.deleteBreakpoints(savedbreakpoints);
|
||||||
pause();
|
pause();
|
||||||
|
|
||||||
/* We should now have 6 breakpoints left. */
|
/* We should now have 6 breakpoints left. */
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertTrue(breakpoints.length==6);
|
assertTrue(breakpoints.length == 6);
|
||||||
/* Make sure we have the correct 6 breakpoints left */
|
/* Make sure we have the correct 6 breakpoints left */
|
||||||
for (int x=0;x<breakpoints.length;x++) {
|
for (int x = 0; x < breakpoints.length; x++) {
|
||||||
curbreak=(ICDILocationBreakpoint)breakpoints[x];
|
curbreak = (ICDILocationBreakpoint) breakpoints[x];
|
||||||
assertTrue(curbreak.getLocation().getLineNumber()==x+1);
|
assertTrue(curbreak.getLocation().getLineNumber() == x + 1);
|
||||||
}
|
}
|
||||||
breaks.deleteAllBreakpoints();
|
breaks.deleteAllBreakpoints();
|
||||||
pause();
|
pause();
|
||||||
assertTrue(breaks.getBreakpoints().length==0);
|
assertTrue(breaks.getBreakpoints().length == 0);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Make sure deleteBreakpoints works when given all the breakpoints
|
* Make sure deleteBreakpoints works when given all the breakpoints
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
savedbreakpoints= new ICDIBreakpoint[10];
|
savedbreakpoints = new ICDIBreakpoint[10];
|
||||||
for (int x=0;x<10;x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
location=breaks.createLocation("main.c", null, x+1);
|
location = breaks.createLocation("main.c", null, x + 1);
|
||||||
savedbreakpoints[x]=breaks.setLocationBreakpoint(0, location, null, null);
|
savedbreakpoints[x] = breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
assertNotNull(savedbreakpoints[x]);
|
assertNotNull(savedbreakpoints[x]);
|
||||||
}
|
}
|
||||||
breaks.deleteBreakpoints(savedbreakpoints);
|
breaks.deleteBreakpoints(savedbreakpoints);
|
||||||
pause();
|
pause();
|
||||||
/* We should now have 0 breakpoints left. */
|
/* We should now have 0 breakpoints left. */
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertTrue(breakpoints.length==0);
|
assertTrue(breakpoints.length == 0);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Make sure deleteAllBreakpoints works
|
* Make sure deleteAllBreakpoints works
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
for (int x=0;x<10;x++) {
|
for (int x = 0; x < 10; x++) {
|
||||||
location=breaks.createLocation("main.c", null, x+1);
|
location = breaks.createLocation("main.c", null, x + 1);
|
||||||
curbreak=breaks.setLocationBreakpoint(0, location, null, null);
|
curbreak = breaks.setLocationBreakpoint(0, location, null, null);
|
||||||
assertNotNull(curbreak);
|
assertNotNull(curbreak);
|
||||||
}
|
}
|
||||||
breaks.deleteAllBreakpoints();
|
breaks.deleteAllBreakpoints();
|
||||||
pause();
|
pause();
|
||||||
/* We should now have 0 breakpoints left. */
|
/* We should now have 0 breakpoints left. */
|
||||||
breakpoints=breaks.getBreakpoints();
|
breakpoints = breaks.getBreakpoints();
|
||||||
assertTrue(breakpoints.length==0);
|
assertTrue(breakpoints.length == 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* clean up the session */
|
/* clean up the session */
|
||||||
session.terminate();
|
session.terminate();
|
||||||
session=null;
|
session = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
/***
|
|
||||||
|
/***************************************************************************
|
||||||
* A couple tests to make sure setting breakpoints with conditions seems to
|
* A couple tests to make sure setting breakpoints with conditions seems to
|
||||||
* work as expected.
|
* work as expected.
|
||||||
*/
|
*/
|
||||||
|
@ -605,59 +607,61 @@ public class BreakpointTests extends TestCase {
|
||||||
ICDIBreakpointManager breaks;
|
ICDIBreakpointManager breaks;
|
||||||
ICDILocation location;
|
ICDILocation location;
|
||||||
ICDICondition cond;
|
ICDICondition cond;
|
||||||
boolean caught=false;
|
boolean caught = false;
|
||||||
session=CDebugHelper.createSession("main", testProject);
|
session = CDebugHelper.createSession("main", testProject);
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
breaks=session.getBreakpointManager();
|
breaks = session.getBreakpointManager();
|
||||||
assertNotNull(breaks);
|
assertNotNull(breaks);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on a generic function with an empty condition
|
* Create a break point on a generic function with an empty condition
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
cond=breaks.createCondition(0, "");
|
cond = breaks.createCondition(0, "");
|
||||||
location=breaks.createLocation(null, "func1", 0);
|
location = breaks.createLocation(null, "func1", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, cond, null);
|
breaks.setLocationBreakpoint(0, location, cond, null);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on a generic function with an valid condition
|
* Create a break point on a generic function with an valid condition
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
cond=breaks.createCondition(0, "x<10");
|
cond = breaks.createCondition(0, "x<10");
|
||||||
location=breaks.createLocation(null, "func1", 0);
|
location = breaks.createLocation(null, "func1", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
breaks.setLocationBreakpoint(0, location, cond, null);
|
breaks.setLocationBreakpoint(0, location, cond, null);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on a generic function with an invalid condition
|
* Create a break point on a generic function with an invalid condition
|
||||||
* We expect to get a CDIException when we try to set the breakpoint.
|
* We expect to get a CDIException when we try to set the breakpoint.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
cond=breaks.createCondition(0, "nonexist<10");
|
cond = breaks.createCondition(0, "nonexist<10");
|
||||||
location=breaks.createLocation(null, "func1", 0);
|
location = breaks.createLocation(null, "func1", 0);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
try {
|
try {
|
||||||
breaks.setLocationBreakpoint(0, location, cond, null);
|
breaks.setLocationBreakpoint(0, location, cond, null);
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
caught=true;
|
caught = true;
|
||||||
}
|
}
|
||||||
assertTrue(caught);
|
assertTrue(caught);
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Create a break point on a line number with a condition and make sure
|
* Create a break point on a line number with a condition and make sure
|
||||||
* it does not suspend execution of the application until the condition
|
* it does not suspend execution of the application until the condition
|
||||||
* is true
|
* is true
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
breaks.deleteAllBreakpoints();
|
breaks.deleteAllBreakpoints();
|
||||||
location=breaks.createLocation(null, null, 23);
|
location = breaks.createLocation(null, null, 23);
|
||||||
assertNotNull(location);
|
assertNotNull(location);
|
||||||
cond=breaks.createCondition(0, "a>10");
|
cond = breaks.createCondition(0, "a>10");
|
||||||
|
|
||||||
breaks.setLocationBreakpoint(0, location, cond, null);
|
breaks.setLocationBreakpoint(0, location, cond, null);
|
||||||
targets=session.getTargets();
|
targets = session.getTargets();
|
||||||
/* We better only have one target connected to this session or something
|
/*
|
||||||
|
* We better only have one target connected to this session or something
|
||||||
* is not right...
|
* is not right...
|
||||||
*/
|
*/
|
||||||
assertTrue(targets.length==1);
|
assertTrue(targets.length == 1);
|
||||||
/* Resume the target, this should cause it to run till it hits the
|
/*
|
||||||
|
* Resume the target, this should cause it to run till it hits the
|
||||||
* breakpoint
|
* breakpoint
|
||||||
*/
|
*/
|
||||||
targets[0].resume();
|
targets[0].resume();
|
||||||
|
@ -666,27 +670,27 @@ public class BreakpointTests extends TestCase {
|
||||||
* suspended. It sould hit the breakponint almost immediatly so we
|
* suspended. It sould hit the breakponint almost immediatly so we
|
||||||
* should only sleep for max 100 ms
|
* should only sleep for max 100 ms
|
||||||
*/
|
*/
|
||||||
for (int x=0;x<100;x++) {
|
for (int x = 0; x < 100; x++) {
|
||||||
if (targets[0].isSuspended() || targets[0].isTerminated())
|
if (targets[0].isSuspended() || targets[0].isTerminated())
|
||||||
break;
|
break;
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
assertTrue("Suspended: " + targets[0].isSuspended() + " Termiunated: " + targets[0].isTerminated(), targets[0].isSuspended());
|
assertTrue("Suspended: " + targets[0].isSuspended() + " Termiunated: " + targets[0].isTerminated(), targets[0]
|
||||||
location=targets[0].getCurrentThread().getStackFrames()[0].getLocation();
|
.isSuspended());
|
||||||
assertTrue(location.getLineNumber()==23);
|
location = targets[0].getCurrentThread().getStackFrames()[0].getLocation();
|
||||||
|
assertTrue(location.getLineNumber() == 23);
|
||||||
assertTrue(location.getFunction().equals("main"));
|
assertTrue(location.getFunction().equals("main"));
|
||||||
assertTrue(location.getFile().equals("main.c"));
|
assertTrue(location.getFile().equals("main.c"));
|
||||||
/* Get the value of a and and make sure it is 11 */
|
/* Get the value of a and and make sure it is 11 */
|
||||||
assertTrue(targets[0].evaluateExpressionToString("a"),
|
assertTrue(targets[0].evaluateExpressionToString("a"), targets[0].evaluateExpressionToString("a").equals("11"));
|
||||||
targets[0].evaluateExpressionToString("a").equals("11"));
|
|
||||||
|
|
||||||
|
|
||||||
/* clean up the session */
|
/* clean up the session */
|
||||||
session.terminate();
|
session.terminate();
|
||||||
session=null;
|
session = null;
|
||||||
targets=null;
|
targets = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pause() {
|
void pause() {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
@ -78,9 +79,8 @@ public class DebugTests extends TestCase {
|
||||||
/***
|
/***
|
||||||
* Create a new project and import the test source.
|
* Create a new project and import the test source.
|
||||||
*/
|
*/
|
||||||
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.debug.ui.tests").find(new Path("/")).getFile();
|
IPath importFile = new Path("resources/debugTest.zip");
|
||||||
pluginRoot=pluginRoot+"resources/debugTest.zip";
|
testProject=CProjectHelper.createCProjectWithImport("filetest", importFile);
|
||||||
testProject=CProjectHelper.createCProjectWithImport("filetest", pluginRoot);
|
|
||||||
if (testProject==null)
|
if (testProject==null)
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
/* Build the test project.. */
|
/* Build the test project.. */
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
@ -79,9 +80,8 @@ public class LocationTests extends TestCase {
|
||||||
/***
|
/***
|
||||||
* Create a new project and import the test source.
|
* Create a new project and import the test source.
|
||||||
*/
|
*/
|
||||||
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.debug.ui.tests").find(new Path("/")).getFile();
|
IPath importFile = new Path("resources/debugTest.zip");
|
||||||
pluginRoot=pluginRoot+"resources/debugTest.zip";
|
testProject=CProjectHelper.createCProjectWithImport("filetest", importFile);
|
||||||
testProject=CProjectHelper.createCProjectWithImport("filetest", pluginRoot);
|
|
||||||
if (testProject==null)
|
if (testProject==null)
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
/* Build the test project.. */
|
/* Build the test project.. */
|
||||||
|
|
Binary file not shown.
|
@ -1,5 +1,6 @@
|
||||||
package org.eclipse.cdt.debug.testplugin;
|
package org.eclipse.cdt.debug.testplugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
@ -35,7 +36,7 @@ public class CProjectHelper {
|
||||||
/**
|
/**
|
||||||
* Creates a ICProject.
|
* Creates a ICProject.
|
||||||
*/
|
*/
|
||||||
public static ICProject createCProjectWithImport(String projectName, String zipFile) throws CoreException, InvocationTargetException, IOException {
|
public static ICProject createCProjectWithImport(String projectName, IPath zipFile) throws CoreException, InvocationTargetException, IOException {
|
||||||
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
|
||||||
IProject project= root.getProject(projectName);
|
IProject project= root.getProject(projectName);
|
||||||
if (!project.exists()) {
|
if (!project.exists()) {
|
||||||
|
@ -47,7 +48,8 @@ public class CProjectHelper {
|
||||||
if (!project.isOpen()) {
|
if (!project.isOpen()) {
|
||||||
project.open(null);
|
project.open(null);
|
||||||
}
|
}
|
||||||
importFilesFromZip(new ZipFile(zipFile),project.getFullPath(),null);
|
File zip = CTestPlugin.getDefault().getFileInPlugin(zipFile);
|
||||||
|
importFilesFromZip(new ZipFile(zip),project.getFullPath(),null);
|
||||||
|
|
||||||
if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
|
if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||||
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
|
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
|
||||||
|
|
Loading…
Add table
Reference in a new issue