diff options
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui.tests/core/org')
10 files changed, 0 insertions, 1508 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/.cvsignore b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/.cvsignore deleted file mode 100644 index e69de29bb2d..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/.cvsignore +++ /dev/null diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/AbstractDebugTest.java b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/AbstractDebugTest.java deleted file mode 100644 index d2117d8784b..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/AbstractDebugTest.java +++ /dev/null @@ -1,240 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.tests; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import junit.extensions.TestSetup; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation; -import org.eclipse.cdt.debug.core.cdi.ICDILocation; -import org.eclipse.cdt.debug.core.cdi.ICDILocator; -import org.eclipse.cdt.debug.core.cdi.ICDISession; -import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import org.eclipse.cdt.debug.core.model.ICBreakpointType; -import org.eclipse.cdt.debug.mi.core.MIException; -import org.eclipse.cdt.debug.testplugin.CDebugHelper; -import org.eclipse.cdt.debug.testplugin.CProjectHelper; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; - -public abstract class AbstractDebugTest extends TestCase { - IWorkspace workspace; - IWorkspaceRoot root; - NullProgressMonitor monitor; - static ICProject testProject = null; - static ICDISession session = null; - static ICDITarget targets[] = null; - ICDITarget currentTarget; - static boolean oneTimeSetupDone = false; - - @Override - protected void setUp() throws Exception { - super.setUp(); - if (oneTimeSetupDone == false) { - oneTimeSetUp(); // this can happened when run junit failed test from UI, without invoking suite() - oneTimeSetupDone = false; // re-set it back so tarDownOnes will run - } - /*********************************************************************** - * The tests assume that they have a working workspace and workspace - * root object to use to create projects/files in, so we need to get - * them setup first. - */ - workspace = ResourcesPlugin.getWorkspace(); - root = workspace.getRoot(); - monitor = new NullProgressMonitor(); - if (workspace == null) - fail("Workspace was not setup"); //$NON-NLS-1$ - if (root == null) - fail("Workspace root was not setup"); //$NON-NLS-1$ - } - - void createDebugSession() throws IOException, MIException, CModelException { - session = CDebugHelper.createSession(getProjectBinary(), testProject); - assertNotNull(session); - targets = session.getTargets(); - assertNotNull(targets); - assertTrue(targets.length > 0); - currentTarget = targets[0]; - } - - /** - * Sets up the test fixture. - * - * Called before every test case method. - * - * Example code test the packages in the project - * "com.qnx.tools.ide.cdt.core" - */ - protected void oneTimeSetUp() throws CoreException, InvocationTargetException, IOException { - ResourcesPlugin.getWorkspace().getDescription().setAutoBuilding(false); - /*********************************************************************** - * Create a new project and import the test source. - */ - Path imputFile = new Path(getProjectZip()); - testProject = CProjectHelper.createCProjectWithImport(getProjectName(), imputFile); - if (testProject == null) - fail("Unable to create project"); //$NON-NLS-1$ - /* Build the test project.. */ - - testProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null); - oneTimeSetupDone = true; - } - - protected String getProjectName() { - return "filetest"; - } - - protected String getProjectZip() { - return "resources/debugTest.zip"; - } - - protected String getProjectBinary() { - return "main"; - } - - - public static Display getDisplay() { - return PlatformUI.getWorkbench().getDisplay(); - } - /** - * Dispatch ui events for at least msec - milliseconds - * - * @param msec - - * milliseconds delay - */ - public static void uimsleep(int msec) { - long cur = System.currentTimeMillis(); - long pass = 0; - Display display = getDisplay(); - while (pass < msec) { - if (!display.readAndDispatch()) - display.sleep(); - pass = System.currentTimeMillis() - cur; - } - } - /** - * Tears down the test fixture. - * - * Called after every test case method. - */ - protected void oneTimeTearDown() throws CoreException { - if (targets != null) { - try { - targets[0].terminate(); - } catch (CDIException e) { - } - } - if (session != null) { - try { - session.terminate(); - } catch (CDIException e) { - } - } - CProjectHelper.delete(testProject); - if (oneTimeSetupDone == false) { - oneTimeTearDown(); // this can happened when run junit failed test from UI, without invoking suite() - } - - } - - static class DebugTestWrapper extends TestSetup { - private AbstractDebugTest newInstance; - - public DebugTestWrapper(Class clazz) { - super(new TestSuite(clazz)); - /*********************************************************************** - * 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 is - * needed because the creation of the source and target projects takes a - * long time and we really only need to do it once. We could do the - * setup in the constructor, but we need to be able to remove everything - * when we are done. - */ - try { - newInstance = (AbstractDebugTest) clazz.newInstance(); - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - } - - @Override - protected void setUp() throws FileNotFoundException, IOException, InterruptedException, - InvocationTargetException, CoreException { - newInstance.oneTimeSetUp(); - } - - @Override - protected void tearDown() throws FileNotFoundException, IOException, CoreException { - newInstance.oneTimeTearDown(); - } - } - - void pause() { - uimsleep(200); - } - - public ICDILocator getCurrentLocator() throws CDIException { - return getCurrentFrame().getLocator(); - } - - public ICDIStackFrame getCurrentFrame() throws CDIException { - return currentTarget.getCurrentThread().getStackFrames()[0]; - } - - void waitSuspend(ICDITarget currentTarget) { - int loop; - loop = 0; - while ((currentTarget.isSuspended() == false) && (currentTarget.isTerminated() == false) && (loop < 20)) { - uimsleep(500); - loop++; - } - assertFalse("Target should be suspended, but it is terminated " + currentTarget.isTerminated(), currentTarget - .isTerminated()); - assertTrue("Target should be suspended but it is not", currentTarget.isSuspended()); - - } - - public void resumeCurrentTarget() throws CDIException{ - currentTarget.resume(false); - } - - void setBreakOnMain() throws CDIException { - ICDILocation location = null; - location = currentTarget.createFunctionLocation("", "main"); //$NON-NLS-1$ - currentTarget.setFunctionBreakpoint(ICBreakpointType.TEMPORARY, (ICDIFunctionLocation) location, null, false); - } - - @Override - protected void tearDown() throws Exception { - /* clean up the session */ - if (session == null) { - session.terminate(); - session = null; - } - super.tearDown(); - } -} diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/AllDebugTests.java b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/AllDebugTests.java deleted file mode 100644 index b6e11c85928..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/AllDebugTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.tests; - -import junit.framework.Test; -import junit.framework.TestSuite; - - -/** - * - * AllDedbugTests.java - * This is the main entry point for running this suite of JUnit tests - * for all tests within the package "org.eclipse.cdt.debug.core" - * - * @author Judy N. Green - * @since Jul 19, 2002 - */ -public class AllDebugTests extends TestSuite { - - public static Test suite() { - TestSuite suite = new AllDebugTests(); - - // Just add more test cases here as you create them for - // each class being tested - - suite.addTest(DebugTests.suite()); - suite.addTest(BreakpointTests.suite()); - suite.addTest(LocationTests.suite()); - suite.addTest(EventBreakpointTests.suite()); - return suite; - } -} // End of AllDebugTests.java - diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/BreakpointTests.java b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/BreakpointTests.java deleted file mode 100644 index d7acdc6bded..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/BreakpointTests.java +++ /dev/null @@ -1,616 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.tests; - -import java.io.IOException; -import java.math.BigInteger; - -import junit.framework.Test; - -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation; -import org.eclipse.cdt.debug.core.cdi.ICDICondition; -import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation; -import org.eclipse.cdt.debug.core.cdi.ICDILineLocation; -import org.eclipse.cdt.debug.core.cdi.ICDILocator; -import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import org.eclipse.cdt.debug.mi.core.MIException; -import org.eclipse.core.runtime.CoreException; - -/** - * @author Peter Graves - * - * This file contains a set of generic tests for the CDI break point interfaces. - * It will currenly use the mi implementation. - * - */ -public class BreakpointTests extends AbstractDebugTest { - - - public static Test suite() { - return new DebugTestWrapper(BreakpointTests.class) {}; - } - @Override - protected void setUp() throws Exception { - super.setUp(); - createDebugSession(); - assertNotNull(currentTarget); - currentTarget.deleteAllBreakpoints(); - pause(); - } - @Override - protected void tearDown() throws Exception { - /* clean up the session */ - targets[0].terminate(); - int x = 0; - while ((!targets[0].isTerminated()) && (x < 30)) { - Thread.sleep(100); - } - if (!targets[0].isTerminated()) - targets[0].terminate(); - super.tearDown(); - } - - - /*************************************************************************** - * A couple tests to make sure setting breakpoints on functions works as - * expected. - */ - public void testFunctionBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException { - - ICDITarget cdiTarget = currentTarget; - ICDIFunctionLocation location; - boolean caught = false; - - - /*********************************************************************** - * Create a break point on a generic function - **********************************************************************/ - - location = cdiTarget.createFunctionLocation(null, "func1"); //$NON-NLS-1$ - assertNotNull(location); - cdiTarget.setFunctionBreakpoint(0, location, null, false); - - /*********************************************************************** - * Create a break point on main - **********************************************************************/ - - location = cdiTarget.createFunctionLocation(null, "main"); //$NON-NLS-1$ - assertNotNull(location); - cdiTarget.setFunctionBreakpoint(0, location, null, false); - - /*********************************************************************** - * Try to create a break point on a function name that does not exist We - * expect that this will cause the setLocationBreakpoint to throw a - * CDIException - **********************************************************************/ - - location = cdiTarget.createFunctionLocation(null, "badname"); //$NON-NLS-1$ - assertNotNull(location); - try { - cdiTarget.setFunctionBreakpoint(0, location, null, false); - } catch (CDIException e) { - caught = true; - } - assertTrue(caught); - - cdiTarget.deleteAllBreakpoints(); - - /*********************************************************************** - * Create a break point on a generic function and see if it will get hit - * and stop program execution. - **********************************************************************/ - - location = cdiTarget.createFunctionLocation(null, "func1"); //$NON-NLS-1$ - assertNotNull(location); - cdiTarget.setFunctionBreakpoint(0, location, null, false); - targets = session.getTargets(); - /* - * We better only have one target connected to this session or something - * is not right... - */ - assertTrue(targets.length == 1); - /* - * Resume the target, this should cause it to run till it hits the - * breakpoint - */ - resumeCurrentTarget(); - /** - * Give the process up to 10 seconds to become either terminated or - * suspended. It sould hit the breakponint almost immediatly so we - * should only sleep for max 100 ms - */ - waitSuspend(cdiTarget); - ICDILocator locator = getCurrentLocator(); - assertTrue(locator.getLineNumber() == 6); - assertTrue(locator.getFunction().equals("func1")); //$NON-NLS-1$ - assertTrue(locator.getFile().endsWith("main.c")); //$NON-NLS-1$ - } - - /*************************************************************************** - * A couple tests to make sure setting breakpoints on line numbers works as - * expected. - */ - public void testLineBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException { - ICDITarget cdiTarget = currentTarget; - ICDILineLocation location; - boolean caught = false; - - - /*********************************************************************** - * Create a break point in a generic function - **********************************************************************/ - location = cdiTarget.createLineLocation("main.c", 7); - assertNotNull(location); - cdiTarget.setLineBreakpoint(0, location, null, false); - - /*********************************************************************** - * Create a break point in main - **********************************************************************/ - location = cdiTarget.createLineLocation("main.c", 18); - assertNotNull(location); - cdiTarget.setLineBreakpoint(0, location, null, false); - - /*********************************************************************** - * Try to create a break point on a line that does not exist We expect - * that this will cause the setLocationBreakpoint to throw a - * CDIException - **********************************************************************/ - - location = cdiTarget.createLineLocation("main.c", 30); - assertNotNull(location); - try { - cdiTarget.setLineBreakpoint(0, location, null, false); - } catch (CDIException e) { - caught = true; - } - assertTrue(caught); - - caught = false; - /*********************************************************************** - * Try to create a break point on a line that does not have code on it - **********************************************************************/ - - location = cdiTarget.createLineLocation("main.c", 11); - assertNotNull(location); - cdiTarget.setLineBreakpoint(0, location, null, false); - - /*********************************************************************** - * 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 - * 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 - * succeed and the second should always throw an exception. - **********************************************************************/ - location = cdiTarget.createLineLocation(null, 7); - assertNotNull(location); - cdiTarget.setLineBreakpoint(0, location, null, false); - caught = false; - location = cdiTarget.createLineLocation(null, 30); - assertNotNull(location); - try { - cdiTarget.setLineBreakpoint(0, location, null, false); - } catch (CDIException e) { - caught = true; - } - assertTrue("Ignoring line numbers with no file specified?", caught); - - cdiTarget.deleteAllBreakpoints(); - - /*********************************************************************** - * Create a break point on a line number and see if it will get hit and - * stop program execution. - **********************************************************************/ - - location = cdiTarget.createLineLocation(null, 7); - assertNotNull(location); - cdiTarget.setLineBreakpoint(0, location, null, false); - targets = session.getTargets(); - /* - * We better only have one target connected to this session or something - * is not right... - */ - assertTrue(targets.length == 1); - /* - * Resume the target, this should cause it to run till it hits the - * breakpoint - */ - targets[0].resume(); - /** - * Give the process up to 10 seconds to become either terminated or - * suspended. It sould hit the breakponint almost immediatly so we - * should only sleep for max 100 ms - */ - for (int x = 0; x < 100; x++) { - if (targets[0].isSuspended() || targets[0].isTerminated()) - break; - Thread.sleep(100); - } - assertTrue("Suspended: " + targets[0].isSuspended() + " Termiunated: " + targets[0].isTerminated(), targets[0] - .isSuspended()); - ICDILocator locator = getCurrentLocator(); - assertTrue(locator.getLineNumber() == 7); - assertTrue(locator.getFunction().equals("func1")); - assertTrue(locator.getFile().endsWith("main.c")); - - } - - /*************************************************************************** - * A couple tests to make sure getting breakpoints works as expected - */ - public void testGetBreak() throws CoreException, MIException, IOException, CDIException { - ICDITarget cdiTarget = currentTarget; - ICDIFunctionLocation location; - ICDIBreakpoint[] breakpoints; - ICDILocationBreakpoint curbreak; - - - /*********************************************************************** - * Make sure initially we don't have any breakpoints - **********************************************************************/ - breakpoints = cdiTarget.getBreakpoints(); - assertNotNull(breakpoints); - assertTrue(breakpoints.length == 0); - - /*********************************************************************** - * Make sure if we create a simple breakpoint, that we can get it back - * from the system - **********************************************************************/ - /* Create a break point on a generic function */ - location = cdiTarget.createFunctionLocation("main.c", "func1"); - assertNotNull(location); - cdiTarget.setFunctionBreakpoint(0, location, null, false); - - breakpoints = cdiTarget.getBreakpoints(); - assertNotNull(breakpoints); - assertTrue(breakpoints.length == 1); - if (breakpoints[0] instanceof ICDILocationBreakpoint) { - curbreak = (ICDILocationBreakpoint) breakpoints[0]; - } else - curbreak = null; - assertNotNull(curbreak); - - //assertTrue(curbreak.getLocator().equals(location)); - { - ICDILocator locator = curbreak.getLocator(); - String file = locator.getFile(); - String function = locator.getFunction(); - assertTrue("main.c".equals(file)); - assertTrue("func1".equals(function)); - } - - /*********************************************************************** - * Make sure if we create multiple break points that we can still get - * them all back from the system, - **********************************************************************/ - /* Create another break point on main */ - location = cdiTarget.createFunctionLocation("main.c", "main"); - assertNotNull(location); - cdiTarget.setFunctionBreakpoint(0, location, null, false); - - breakpoints = cdiTarget.getBreakpoints(); - assertNotNull(breakpoints); - assertTrue(breakpoints.length == 2); - if (breakpoints[1] instanceof ICDILocationBreakpoint) { - curbreak = (ICDILocationBreakpoint) breakpoints[1]; - } else - curbreak = null; - assertNotNull(curbreak); - /* - * Make sure the location still looks like we expect it to.. . - */ - //assertTrue(curbreak.getLocation().equals(location)); - { - ICDILocator locator = curbreak.getLocator(); - String file = locator.getFile(); - String function = locator.getFunction(); - assertTrue("main.c".equals(file)); - assertTrue("main".equals(function)); - } - - cdiTarget.deleteAllBreakpoints(); - - - } - - /*************************************************************************** - * A couple tests to make sure deleting breakpoints works as expected - */ - public void testDelBreak() throws CoreException, MIException, IOException, CDIException { - ICDITarget cdiTarget = currentTarget; - ICDIFunctionLocation location; - ICDILocator savedLocation; - ICDIBreakpoint[] breakpoints, savedbreakpoints; - ICDILocationBreakpoint curbreak; - - /* Make sure initially we don't have any breakpoints */ - breakpoints = cdiTarget.getBreakpoints(); - assertNotNull(breakpoints); - assertTrue(breakpoints.length == 0); - - /*********************************************************************** - * - * Test to make sure if we create a new breakpoint, we can delete it by - * passing a refrence to it to deleteBreakpoint() - * - **********************************************************************/ - - /* Create a break point on a generic function */ - location = cdiTarget.createFunctionLocation("main.c", "func1"); - assertNotNull(location); - curbreak = cdiTarget.setFunctionBreakpoint(0, location, null, false); - cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } ); - pause(); - /** - * we should not have any breakpoints left. - */ - breakpoints = cdiTarget.getBreakpoints(); - assertTrue(breakpoints.length == 0); - - /*********************************************************************** - * - * Test to make sure if we create multiple new breakpoint, we can delete - * one of them by passing a refrence to it to deleteBreakpoint() - * - **********************************************************************/ - - /* Create a break point on a generic function */ - location = cdiTarget.createFunctionLocation("main.c", "func1"); - assertNotNull(location); - curbreak = cdiTarget.setFunctionBreakpoint(0, location, null, false); - savedLocation = curbreak.getLocator(); - - location = cdiTarget.createFunctionLocation("main.c", "main"); - assertNotNull(location); - curbreak = cdiTarget.setFunctionBreakpoint(0, location, null, false); - cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } ); - pause(); - breakpoints = cdiTarget.getBreakpoints(); - /*********************************************************************** - * Make sure there is only 1 breakpoint left, and it's the one we expect - */ - assertTrue(breakpoints.length == 1); - curbreak = (ICDILocationBreakpoint) breakpoints[0]; - assertNotNull(curbreak); - assertTrue(curbreak.getLocator().equals(savedLocation)); - /*********************************************************************** - * Then delete the other breakpoint. - */ - cdiTarget.deleteBreakpoints( new ICDIBreakpoint[] { curbreak } ); - pause(); - breakpoints = cdiTarget.getBreakpoints(); - assertTrue(breakpoints.length == 0); - - /*********************************************************************** - * Make sure deleteBreakpoints works when given 1 breakpoint to delete - **********************************************************************/ - savedbreakpoints = new ICDIBreakpoint[1]; - int lineStart = 6; - int maxBreakpoints = 5; - for (int x = 0; x < maxBreakpoints; x++) { - ICDILineLocation lineLocation = cdiTarget.createLineLocation("main.c", x + lineStart); - ICDILocationBreakpoint bp = cdiTarget.setLineBreakpoint(0, lineLocation, null, false); - assertNotNull(bp); - assertEquals(x + lineStart, (bp.getLocator().getLineNumber())); - savedbreakpoints[0] = bp; - } - cdiTarget.deleteBreakpoints(savedbreakpoints); - pause(); - /* We should now have N-1 breakpoints left. */ - breakpoints = cdiTarget.getBreakpoints(); - assertTrue(breakpoints.length == maxBreakpoints-1); - /* Make sure we have the correct N-1 breakpoints left, we deleted one at line N */ - for (int x = 0; x < breakpoints.length; x++) { - curbreak = (ICDILocationBreakpoint) breakpoints[x]; - assertNotEquals(((ICDILocationBreakpoint)savedbreakpoints[0]).getLocator().getLineNumber(), curbreak.getLocator().getLineNumber()); - } - cdiTarget.deleteAllBreakpoints(); - pause(); - assertTrue(cdiTarget.getBreakpoints().length == 0); - - /*********************************************************************** - * Make sure deleteBreakpoints works when given more then 1 but less - * then all breakpoints to delete - **********************************************************************/ - savedbreakpoints = new ICDIBreakpoint[2]; - for (int x = 0; x < maxBreakpoints; x++) { - ICDILineLocation lineLocation = cdiTarget.createLineLocation("main.c", x + lineStart); - savedbreakpoints[x % 2] = cdiTarget.setLineBreakpoint(0, lineLocation, null, false); - assertNotNull(savedbreakpoints[x % 2]); - } - cdiTarget.deleteBreakpoints(savedbreakpoints); - pause(); - - /* We should now have maxBreakpoints-2 breakpoints left. */ - breakpoints = cdiTarget.getBreakpoints(); - assertEquals(maxBreakpoints-2, breakpoints.length ); - /* Make sure we have the correct 6 breakpoints left */ - for (int x = 0; x < breakpoints.length; x++) { - curbreak = (ICDILocationBreakpoint) breakpoints[x]; - assertEquals(x+lineStart, curbreak.getLocator().getLineNumber()); - } - cdiTarget.deleteAllBreakpoints(); - pause(); - assertTrue(cdiTarget.getBreakpoints().length == 0); - - /*********************************************************************** - * Make sure deleteBreakpoints works when given all the breakpoints - **********************************************************************/ - savedbreakpoints = new ICDIBreakpoint[maxBreakpoints]; - for (int x = 0; x < maxBreakpoints; x++) { - ICDILineLocation lineLocation = cdiTarget.createLineLocation("main.c", x + lineStart); - savedbreakpoints[x] = cdiTarget.setLineBreakpoint(0, lineLocation, null, false); - assertNotNull(savedbreakpoints[x]); - } - cdiTarget.deleteBreakpoints(savedbreakpoints); - pause(); - /* We should now have 0 breakpoints left. */ - breakpoints = cdiTarget.getBreakpoints(); - assertTrue(breakpoints.length == 0); - - /*********************************************************************** - * Make sure deleteAllBreakpoints works - **********************************************************************/ - - for (int x = 0; x < maxBreakpoints; x++) { - ICDILineLocation lineLocation = cdiTarget.createLineLocation("main.c", x + lineStart); - curbreak = cdiTarget.setLineBreakpoint(0, lineLocation, null, false); - assertNotNull(curbreak); - } - cdiTarget.deleteAllBreakpoints(); - pause(); - /* We should now have 0 breakpoints left. */ - breakpoints = cdiTarget.getBreakpoints(); - assertTrue(breakpoints.length == 0); - - } - - private void assertNotEquals(int notExpected, int actual) { - if (notExpected==actual) - fail("not expected:<"+actual+">"); - - } - /*************************************************************************** - * A couple tests to make sure setting breakpoints with conditions seems to - * work as expected. - */ - public void testCondBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException { - boolean caught = false; - ICDITarget cdiTarget = currentTarget; - ICDICondition cond; - - /*********************************************************************** - * 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 - * is true - **********************************************************************/ - cdiTarget.deleteAllBreakpoints(); - pause(); - ICDILineLocation lineLocation = cdiTarget.createLineLocation(null, 23); - assertNotNull(lineLocation); - cond = cdiTarget.createCondition(0, "a>10"); - cdiTarget.setLineBreakpoint(0, lineLocation, cond, false); - pause(); - resumeCurrentTarget(); - /** - * Give the process up to 10 seconds to become either terminated or - * suspended. It sould hit the breakponint almost immediatly so we - * should only sleep for max 100 ms - */ - waitSuspend(cdiTarget); - ICDIStackFrame frame = getCurrentFrame(); - ICDILocator locator = getCurrentLocator(); - assertTrue(locator.getLineNumber() == 23); - assertTrue(locator.getFunction().equals("main")); - assertTrue(locator.getFile().endsWith("main.c")); - /* Get the value of a and and make sure it is 11 */ - assertTrue(targets[0].evaluateExpressionToString(frame, "a"), targets[0].evaluateExpressionToString(frame, "a").equals("11")); - - } - public void testCondBreak2() throws CoreException, MIException, IOException, CDIException, InterruptedException { - - ICDITarget cdiTarget = currentTarget; - - /*********************************************************************** - * Create a break point on a generic function with an empty condition - **********************************************************************/ - ICDICondition cond = cdiTarget.createCondition(0, ""); - ICDIFunctionLocation location = cdiTarget.createFunctionLocation(null, "func1"); - assertNotNull(location); - cdiTarget.setFunctionBreakpoint(0, location, cond, false); - - /*********************************************************************** - * Create a break point on a generic function with an valid condition - **********************************************************************/ - cond = cdiTarget.createCondition(0, "x<10"); - ICDILineLocation location2 = cdiTarget.createLineLocation("main.c", 9); - assertNotNull(location); - cdiTarget.setLineBreakpoint(0, location2, cond, false); - } - - public void testCondBreakError() { - ICDITarget cdiTarget = currentTarget; - ICDICondition cond; - ICDIFunctionLocation location; - /*********************************************************************** - * 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. - **********************************************************************/ - boolean caught = false; - cond = cdiTarget.createCondition(0, "nonexist<10"); - location = cdiTarget.createFunctionLocation(null, "func1"); - assertNotNull(location); - try { - cdiTarget.setFunctionBreakpoint(0, location, cond, false); - } catch (CDIException e) { - caught = true; - } - assertTrue("Setting wrong condition should fail",caught); - } - - public void testHitCond() throws CoreException, MIException, IOException, CDIException, InterruptedException { - setBreakOnMain(); - testCondBreak2(); - resumeCurrentTarget(); - waitSuspend(currentTarget); - } - public void xfail_testHitCondWithError() throws CoreException, MIException, IOException, CDIException, InterruptedException { - // this currently fails sometimes - after set bad breakpoint it does not hit any - // only reproducible when setting invalid condition breakpoint, reason unknown - setBreakOnMain(); - testCondBreak2(); - testCondBreakError(); - pause(); - /* We should now have 3 breakpoints left. */ - ICDIBreakpoint[] breakpoints = currentTarget.getBreakpoints(); - assertTrue(breakpoints.length == 3); - resumeCurrentTarget(); - waitSuspend(currentTarget); - } - /*************************************************************************** - * A test to make sure setting address breakpoints works as - * expected. - */ - public void testAddressBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException { - - - ICDIAddressLocation location; - boolean caught = false; - - setBreakOnMain(); - currentTarget.resume(false); - waitSuspend(currentTarget); - currentTarget.stepOver(1); - pause(); - BigInteger address = getCurrentLocator().getAddress(); - /*********************************************************************** - * Create a break point on first instruction - **********************************************************************/ - - location = currentTarget.createAddressLocation(address); - assertNotNull(location); - currentTarget.setAddressBreakpoint(0, location, null, false); - - // restart - currentTarget.restart(); - pause(); - waitSuspend(currentTarget); - - ICDILocator locator = getCurrentLocator(); - assertTrue(locator.getLineNumber() == 18); - assertTrue(locator.getFunction().equals("main")); //$NON-NLS-1$ - assertTrue(locator.getFile().endsWith("main.c")); //$NON-NLS-1$ - } - -}
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/DebugTests.java b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/DebugTests.java deleted file mode 100644 index 793bcdf43ae..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/DebugTests.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.tests; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation; -import org.eclipse.cdt.debug.core.cdi.ICDISession; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import org.eclipse.cdt.debug.mi.core.MIException; -import org.eclipse.cdt.debug.testplugin.CDebugHelper; -import org.eclipse.cdt.debug.testplugin.CProjectHelper; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; - -/** - * @author Peter Graves - * - * This file contains a set of generic tests for the debug stuff. It currenly - * uses the mi debugger. - * - */ -public class DebugTests extends TestCase { - IWorkspace workspace; - IWorkspaceRoot root; - ICProject testProject; - NullProgressMonitor monitor; - ICDISession session; - - - /** - * Constructor for DebugTests - * @param name - */ - public DebugTests(String name) { - super(name); - /*** - * The assume that they have a working workspace - * and workspace root object to use to create projects/files in, - * so we need to get them setup first. - */ - workspace= ResourcesPlugin.getWorkspace(); - root= workspace.getRoot(); - monitor = new NullProgressMonitor(); - if (workspace==null) - fail("Workspace was not setup"); - if (root==null) - fail("Workspace root was not setup"); - - } - - /** - * Sets up the test fixture. - * - * Called before every test case method. - * - * Example code test the packages in the project - * "com.qnx.tools.ide.cdt.core" - */ - @Override - protected void setUp() throws CoreException, InvocationTargetException, IOException { - ResourcesPlugin.getWorkspace().getDescription().setAutoBuilding(false); - /*** - * Create a new project and import the test source. - */ - IPath importFile = new Path("resources/debugTest.zip"); - testProject=CProjectHelper.createCProjectWithImport("filetest", importFile); - if (testProject==null) - fail("Unable to create project"); - /* Build the test project.. */ - - testProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null); - - } - - /** - * Tears down the test fixture. - * - * Called after every test case method. - */ - @Override - protected void tearDown() throws CoreException, CDIException { - if (session!=null) { - session.terminate(); - session=null; - } - CProjectHelper.delete(testProject); - } - - public static TestSuite suite() { - return new TestSuite(DebugTests.class); - } - - public static void main (String[] args){ - junit.textui.TestRunner.run(suite()); - } - - - /*** - * Can we setup a debug? - * This is sort of a catch all sanity tests to make sure we can create a debug - * session with a break point and start it without having any exceptions thrown. - * It's not ment to be a real proper test. - */ - public void testDebug() throws CoreException, MIException, IOException, CDIException { - ICDITarget cdiTarget; - ICDIFunctionLocation location; - - session=CDebugHelper.createSession("main",testProject); - assertNotNull(session); - ICDITarget[] targets = session.getTargets(); - assertNotNull(targets); - assertTrue(targets.length > 0); - cdiTarget = targets[0]; - assertNotNull(cdiTarget); - location=cdiTarget.createFunctionLocation(null, "func1"); - assertNotNull(location); - cdiTarget.setFunctionBreakpoint(0, location, null, false); - cdiTarget.resume(); - session.terminate(); - session=null; - - } - - -} diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/EventBreakpointTests.java b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/EventBreakpointTests.java deleted file mode 100644 index 1c6120b4ee1..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/EventBreakpointTests.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.tests; - -import java.io.IOException; - -import junit.framework.Test; - -import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDILocator; -import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement3; -import org.eclipse.cdt.debug.core.cdi.model.ICDIEventBreakpoint; -import org.eclipse.cdt.debug.core.model.ICBreakpointType; -import org.eclipse.cdt.debug.mi.core.MIException; -import org.eclipse.cdt.gdb.eventbkpts.IEventBreakpointConstants; - -public class EventBreakpointTests extends AbstractDebugTest { - public static Test suite() { - return new DebugTestWrapper(EventBreakpointTests.class){}; - } - - @Override - protected String getProjectName() { - return "catchpoints"; - } - - @Override - protected String getProjectZip() { - return "resources/debugCxxTest.zip"; - } - - @Override - protected String getProjectBinary() { - return "catchpoints.exe"; - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - createDebugSession(); - assertNotNull(currentTarget); - currentTarget.deleteAllBreakpoints(); - pause(); - } - - - public void testCatch() throws CModelException, IOException, MIException, CDIException { - eventbreakpoints(IEventBreakpointConstants.EVENT_TYPE_CATCH, ""); - } - - public void testThrow() throws CModelException, IOException, MIException, CDIException { - eventbreakpoints(IEventBreakpointConstants.EVENT_TYPE_THROW, ""); - } - - private void eventbreakpoints(String type, String arg) throws CModelException, IOException, MIException, CDIException { - ICDIBreakpoint[] breakpoints; - ICDIEventBreakpoint curbreak; - - setBreakOnMain(); - currentTarget.restart(); - waitSuspend(currentTarget); - ICDILocator locator = getCurrentLocator(); - assertEquals("Debug should be stopped in function 'main' but it is stopped in: " + locator.getFunction(), - "main", locator.getFunction()); - - currentTarget.deleteAllBreakpoints(); - pause(); - assertTrue(currentTarget instanceof ICDIBreakpointManagement3); - ((ICDIBreakpointManagement3) currentTarget).setEventBreakpoint(type, arg, ICBreakpointType.REGULAR, null, false, true); - pause(); - breakpoints = currentTarget.getBreakpoints(); - assertNotNull(breakpoints); - assertEquals(1, breakpoints.length); - if (breakpoints[0] instanceof ICDIEventBreakpoint) { - curbreak = (ICDIEventBreakpoint) breakpoints[0]; - } else - curbreak = null; - assertNotNull("Found breakpoint is not an event breakpoint",curbreak); - currentTarget.resume(false); - waitSuspend(currentTarget); - // it is stopped we are fine, it did hit breakpoint - } - -} diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/LocationTests.java b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/LocationTests.java deleted file mode 100644 index 5eb3fa0d70c..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/LocationTests.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.tests; - -import java.io.IOException; - -import junit.framework.Test; - -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation; -import org.eclipse.cdt.debug.core.cdi.ICDILineLocation; -import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import org.eclipse.cdt.debug.mi.core.MIException; -import org.eclipse.core.runtime.CoreException; - -/** - * @author Peter Graves - * - * This file contains a set of generic tests for the CDI Location interfaces. - * It will currenly use the mi implementation. - * - */ -public class LocationTests extends AbstractDebugTest { - public static Test suite() { - return new DebugTestWrapper(LocationTests.class){}; - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - createDebugSession(); - assertNotNull(currentTarget); - currentTarget.deleteAllBreakpoints(); - pause(); - } - - /*** - * A couple tests to make sure comparing Locations works as expected. - */ - public void testIsEquals() throws CoreException, MIException, IOException, CDIException { - ICDITarget cdiTarget = currentTarget; - ICDILineLocation lineLocation, lineLocation2; - ICDIFunctionLocation functionLocation, functionLocation2; - ICDIBreakpoint[] breakpoints; - ICDILocationBreakpoint curbreak; - - - /********************************************************************** - * Simple test.. this should work. - **********************************************************************/ - functionLocation=cdiTarget.createFunctionLocation("main.c", "func1"); - functionLocation2=cdiTarget.createFunctionLocation("main.c", "func1"); - assertTrue(functionLocation.equals(functionLocation2)); - /********************************************************************** - * Simple test.. this should work. - **********************************************************************/ - lineLocation=cdiTarget.createLineLocation("main.c", 10); - lineLocation2=cdiTarget.createLineLocation("main.c", 10); - assertTrue(lineLocation.equals(lineLocation2)); - - /********************************************************************** - * make sure that the location returned from getLocation on the - * ICDILocationBreakpoint.getLocation that is returned from - * setLocationBreakpoint is the same as the breakpoint returned from - * BreakpointManager.getBreakpoints.getLocation() - **********************************************************************/ - functionLocation=cdiTarget.createFunctionLocation("main.c", "func1"); - assertNotNull(functionLocation); - functionLocation2=cdiTarget.setFunctionBreakpoint(0, functionLocation, null, false).getLocator(); - - breakpoints=cdiTarget.getBreakpoints(); - assertNotNull(breakpoints); - assertTrue(breakpoints.length==1); - if (breakpoints[0] instanceof ICDILocationBreakpoint) { - curbreak=(ICDILocationBreakpoint) breakpoints[0]; - } else - curbreak=null; - assertNotNull(curbreak); - - assertTrue(curbreak.getLocator().equals(functionLocation2)); - cdiTarget.deleteAllBreakpoints(); - pause(); - /* Create a break point on a generic function with a file name that - * gdb will change to the relitive path of the source file. This - * should work, but at the time of writing (Sept 25, 2002) does not. - */ - functionLocation=cdiTarget.createFunctionLocation("main.c", "func1"); - assertNotNull(functionLocation); - cdiTarget.setFunctionBreakpoint(0, functionLocation, null, false); - - breakpoints=cdiTarget.getBreakpoints(); - assertNotNull(breakpoints); - assertTrue(breakpoints.length==1); - if (breakpoints[0] instanceof ICDILocationBreakpoint) { - curbreak=(ICDILocationBreakpoint) breakpoints[0]; - } else - curbreak=null; - assertNotNull(curbreak); - - assertTrue("PR:23879",curbreak.getLocator().equals(functionLocation)); - - } - - -} diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/MapEntrySourceContainerTests.java b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/MapEntrySourceContainerTests.java deleted file mode 100644 index 10144aa170d..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/MapEntrySourceContainerTests.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.tests; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer; -import org.eclipse.core.runtime.IPath; - -@SuppressWarnings("restriction") -public class MapEntrySourceContainerTests extends TestCase { - - public static Test suite() { - return new TestSuite(MapEntrySourceContainerTests.class); - } - - public MapEntrySourceContainerTests(String name) { - super(name); - } - - public void testUNCPath() { - String uncPath = "//server/path/on/server"; - IPath path = MapEntrySourceContainer.createPath(uncPath); - assertEquals(uncPath, path.toString()); - - uncPath = "\\\\server\\path\\on\\server"; - path = MapEntrySourceContainer.createPath(uncPath); - assertEquals(uncPath, path.toOSString()); - } -} diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/ProjectWithSpaceTests.java b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/ProjectWithSpaceTests.java deleted file mode 100644 index 8db0d548a51..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/ProjectWithSpaceTests.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2010 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.tests; - -import java.io.IOException; - -import junit.framework.Test; - -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDILineLocation; -import org.eclipse.cdt.debug.core.cdi.ICDILocator; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import org.eclipse.cdt.debug.mi.core.MIException; -import org.eclipse.core.runtime.CoreException; - -/** - * Create a project with space and do sanity test for debugger - */ -public class ProjectWithSpaceTests extends AbstractDebugTest { - public static Test suite() { - return new DebugTestWrapper(ProjectWithSpaceTests.class) { - }; - } - - @Override - protected String getProjectName() { - return "with space"; - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - createDebugSession(); - assertNotNull(currentTarget); - currentTarget.deleteAllBreakpoints(); - pause(); - } - - @Override - protected void tearDown() throws Exception { - /* clean up the session */ - targets[0].terminate(); - int x = 0; - while ((!targets[0].isTerminated()) && (x < 30)) { - Thread.sleep(100); - } - if (!targets[0].isTerminated()) - targets[0].terminate(); - super.tearDown(); - } - - /** - * Basic sanity test - */ - public void testLineBreak() throws CoreException, MIException, IOException, CDIException, InterruptedException { - ICDITarget cdiTarget = currentTarget; - ICDILineLocation location; - boolean caught = false; - /*********************************************************************** - * Create a break point in a generic function - **********************************************************************/ - location = cdiTarget.createLineLocation("main.c", 7); - assertNotNull(location); - cdiTarget.setLineBreakpoint(0, location, null, false); - - targets = session.getTargets(); - /* - * We better only have one target connected to this session or something - * is not right... - */ - assertTrue(targets.length == 1); - /* - * Resume the target, this should cause it to run till it hits the - * breakpoint - */ - ICDITarget target = targets[0]; - target.resume(false); - /** - * Give the process up to 10 seconds to become either terminated or - * suspended. It sould hit the breakponint almost immediatly so we - * should only sleep for max 100 ms - */ - for (int x = 0; x < 100; x++) { - if (target.isSuspended() || target.isTerminated()) - break; - Thread.sleep(100); - } - assertTrue("Suspended: " + target.isSuspended() + " Terminated: " + target.isTerminated(), - target.isSuspended()); - ICDILocator locator = getCurrentLocator(); - assertTrue(locator.getLineNumber() == 7); - assertTrue(locator.getFunction().equals("func1")); - assertTrue(locator.getFile().endsWith("main.c")); - } -}
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/TargetTests.java b/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/TargetTests.java deleted file mode 100644 index a18ecb7731e..00000000000 --- a/debug/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/TargetTests.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.tests; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.eclipse.cdt.debug.testplugin.*; -import org.eclipse.cdt.core.model.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.cdt.debug.mi.core.*; -import org.eclipse.cdt.debug.core.cdi.*; - -/** - * @author Peter Graves - * - * This file contains a set of generic tests for the CDI Target interfaces. - * It will currenly use the mi implementation. - * - */ -public class TargetTests extends TestCase { - IWorkspace workspace; - IWorkspaceRoot root; - ICProject testProject; - NullProgressMonitor monitor; - - - /** - * Constructor for TargetTests - * @param name - */ - public TargetTests(String name) { - super(name); - /*** - * The assume that they have a working workspace - * and workspace root object to use to create projects/files in, - * so we need to get them setup first. - */ - workspace= ResourcesPlugin.getWorkspace(); - root= workspace.getRoot(); - monitor = new NullProgressMonitor(); - if (workspace==null) - fail("Workspace was not setup"); - if (root==null) - fail("Workspace root was not setup"); - - } - - /** - * Sets up the test fixture. - * - * Called before every test case method. - * - * Example code test the packages in the project - * "com.qnx.tools.ide.cdt.core" - */ - @Override - protected void setUp() throws CoreException,FileNotFoundException { - - /*** - * Setup the various files, paths and projects that are needed by the - * tests - */ - testProject=CProjectHelper.createCProject("filetest"); - if (testProject==null) - fail("Unable to create project"); - } - - /** - * Tears down the test fixture. - * - * Called after every test case method. - */ - @Override - protected void tearDown() throws CoreException { - CProjectHelper.delete(testProject); - } - - public static TestSuite suite() { - return new TestSuite(TargetTests.class); - } - - public static void main (String[] args){ - junit.textui.TestRunner.run(suite()); - } - - - /*** - * A couple tests to make sure various evaluations work as expected - */ - public void testEvaluate() throws CoreException, MIException, IOException, CDIException, InterruptedException { - - /*** - * Tests to come - */ - - } - - -} |