mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Tests for dprintf GDB functionality
Bug 400628 was originally completed without any new tests. To make it easier to test that Bug 580873 works, this commit adds in some missing tests.
This commit is contained in:
parent
34381cd253
commit
161b57f9ed
2 changed files with 28 additions and 2 deletions
|
@ -25,7 +25,7 @@ void zeroBlocks(int abc)
|
|||
void setBlocks()
|
||||
{
|
||||
for (int i = 0; i < ARRAY_SIZE; i++) { // LINE_NUMBER_3
|
||||
charBlock[i] = (char) i;
|
||||
charBlock[i] = (char) i; // LINE_LOOP_1
|
||||
integerBlock[i] = i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,8 @@ import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
|
|||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IBreakpointManager;
|
||||
import org.eclipse.debug.core.model.IBreakpoint;
|
||||
import org.eclipse.debug.core.model.IProcess;
|
||||
import org.eclipse.debug.core.model.IStreamMonitor;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Ignore;
|
||||
|
@ -141,7 +143,7 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase {
|
|||
|
||||
// Target application 'special' locations
|
||||
private static final String[] LINE_TAGS = new String[] { "LINE_NUMBER_1", "LINE_NUMBER_2", "LINE_NUMBER_3",
|
||||
"LINE_NUMBER_4", "LINE_NUMBER_5", "LINE_NUMBER_6", };
|
||||
"LINE_NUMBER_4", "LINE_NUMBER_5", "LINE_NUMBER_6", "LINE_LOOP_1" };
|
||||
|
||||
private int LINE_NUMBER_1;
|
||||
private int LINE_NUMBER_2;
|
||||
|
@ -149,6 +151,7 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase {
|
|||
private int LINE_NUMBER_4;
|
||||
private int LINE_NUMBER_5;
|
||||
private int LINE_NUMBER_6;
|
||||
private int LINE_LOOP_1;
|
||||
|
||||
protected final String FUNCTION = "zeroBlocks";
|
||||
protected final String SIGNED_FUNCTION = "zeroBlocks(int)";
|
||||
|
@ -216,6 +219,7 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase {
|
|||
LINE_NUMBER_4 = getLineForTag("LINE_NUMBER_4");
|
||||
LINE_NUMBER_5 = getLineForTag("LINE_NUMBER_5");
|
||||
LINE_NUMBER_6 = getLineForTag("LINE_NUMBER_6");
|
||||
LINE_LOOP_1 = getLineForTag("LINE_LOOP_1");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3312,4 +3316,26 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase {
|
|||
assertTrue("BreakpointService problem: breakpoint mismatch (not pending)", breakpoint1.isPending());
|
||||
clearEventCounters();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertDprintfBreakpoint() throws Throwable {
|
||||
Map<String, Object> printfBreakpoint = new HashMap<>();
|
||||
printfBreakpoint.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.DYNAMICPRINTF);
|
||||
printfBreakpoint.put(MIBreakpoints.FILE_NAME, SOURCE_NAME);
|
||||
printfBreakpoint.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_1);
|
||||
printfBreakpoint.put(MIBreakpoints.PRINTF_STRING, "\"format %d\\n\", i");
|
||||
|
||||
IBreakpointDMContext printfRef = insertBreakpoint(fBreakpointsDmc, printfBreakpoint);
|
||||
waitForBreakpointEvent(1);
|
||||
insertBreakpoint(fBreakpointsDmc, Map.of(BREAKPOINT_TYPE_TAG, BREAKPOINT_TAG, FILE_NAME_TAG, SOURCE_NAME,
|
||||
LINE_NUMBER_TAG, LINE_NUMBER_5));
|
||||
SyncUtil.resumeUntilStopped(5000);
|
||||
IProcess[] processes = getGDBLaunch().getProcesses();
|
||||
IStreamMonitor outputStreamMonitor = processes[1].getStreamsProxy().getOutputStreamMonitor();
|
||||
String[] contents = outputStreamMonitor.getContents().split("\n");
|
||||
for (int i = 0; i < 256; i++) {
|
||||
assertEquals("format " + i, contents[i].trim());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue