Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 015f692fd4bcdf7f1cb9e5195a8aad286f4bcd87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*******************************************************************************
 * Copyright (c) 2000, 2005 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));
   
   }
       

}

Back to the top