mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 01:05:38 +02:00
Bug 397715 - Update JUnit tests to verify value of change memory and
expression. Change-Id: I75a9dc166ae3287973d8b32e20cc121ea842cd27 Reviewed-on: https://git.eclipse.org/r/9964 Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
parent
3b431d7bcf
commit
f0b7098f00
2 changed files with 71 additions and 6 deletions
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.IFormattedDataDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.IFormattedDataDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
|
||||||
|
@ -432,6 +433,26 @@ public class SyncUtil {
|
||||||
return fSession.getExecutor().submit(callable).get();
|
return fSession.getExecutor().submit(callable).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getExpressionValue(final IExpressionDMContext exprDmc, final String format)
|
||||||
|
throws Throwable {
|
||||||
|
Query<String> query = new Query<String>() {
|
||||||
|
@Override
|
||||||
|
protected void execute(final DataRequestMonitor<String> rm) {
|
||||||
|
FormattedValueDMContext valueDmc = fExpressions.getFormattedValueContext(exprDmc, format);
|
||||||
|
fExpressions.getFormattedExpressionValue(valueDmc,
|
||||||
|
new ImmediateDataRequestMonitor<FormattedValueDMData>(rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
rm.done(getData().getFormattedValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fSession.getExecutor().execute(query);
|
||||||
|
return query.get();
|
||||||
|
}
|
||||||
|
|
||||||
public static FormattedValueDMContext getFormattedValue(
|
public static FormattedValueDMContext getFormattedValue(
|
||||||
final IFormattedValues service, final IFormattedDataDMContext dmc, final String formatId) throws Throwable
|
final IFormattedValues service, final IFormattedDataDMContext dmc, final String formatId) throws Throwable
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.dsf.datamodel.IDMEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IMemory;
|
import org.eclipse.cdt.dsf.debug.service.IMemory;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
|
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
|
||||||
|
@ -147,14 +148,24 @@ public class GDBConsoleSynchronizingTest_7_6 extends BaseTestCase {
|
||||||
IExpressionDMAddress data = query.get();
|
IExpressionDMAddress data = query.get();
|
||||||
|
|
||||||
IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(frameDmc, IMemoryDMContext.class);
|
IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(frameDmc, IMemoryDMContext.class);
|
||||||
readMemory(memoryDmc, data.getAddress(), data.getSize());
|
readMemory(memoryDmc, data.getAddress(), 1);
|
||||||
|
|
||||||
fEventsReceived.clear();
|
fEventsReceived.clear();
|
||||||
queueConsoleCommand("set variable i=100");
|
|
||||||
|
final String newValue = "100";
|
||||||
|
queueConsoleCommand("set variable i=" + newValue);
|
||||||
|
|
||||||
IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class);
|
IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class);
|
||||||
assertEquals(1, memoryEvent.getAddresses().length);
|
assertEquals(1, memoryEvent.getAddresses().length);
|
||||||
assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]);
|
assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]);
|
||||||
|
|
||||||
|
// Now verify the memory service knows the new memory value
|
||||||
|
MemoryByte[] memory = readMemory(memoryDmc, data.getAddress(), 1);
|
||||||
|
assertEquals(newValue, Byte.toString(memory[0].getValue()));
|
||||||
|
|
||||||
|
// Now verify the expressions service knows the new value
|
||||||
|
String exprValue = SyncUtil.getExpressionValue(exprDmc, IFormattedValues.DECIMAL_FORMAT);
|
||||||
|
assertEquals(newValue, exprValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,11 +192,22 @@ public class GDBConsoleSynchronizingTest_7_6 extends BaseTestCase {
|
||||||
IExpressionDMAddress data = query.get();
|
IExpressionDMAddress data = query.get();
|
||||||
|
|
||||||
fEventsReceived.clear();
|
fEventsReceived.clear();
|
||||||
queueConsoleCommand("set variable i=100");
|
|
||||||
|
final String newValue = "100";
|
||||||
|
queueConsoleCommand("set variable i=" + newValue);
|
||||||
|
|
||||||
IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class);
|
IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class);
|
||||||
assertEquals(1, memoryEvent.getAddresses().length);
|
assertEquals(1, memoryEvent.getAddresses().length);
|
||||||
assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]);
|
assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]);
|
||||||
|
|
||||||
|
// Now verify the memory service knows the new memory value
|
||||||
|
IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(frameDmc, IMemoryDMContext.class);
|
||||||
|
MemoryByte[] memory = readMemory(memoryDmc, data.getAddress(), 1);
|
||||||
|
assertEquals(newValue, Byte.toString(memory[0].getValue()));
|
||||||
|
|
||||||
|
// Now verify the expressions service knows the new value
|
||||||
|
String exprValue = SyncUtil.getExpressionValue(exprDmc, IFormattedValues.DECIMAL_FORMAT);
|
||||||
|
assertEquals(newValue, exprValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,11 +234,22 @@ public class GDBConsoleSynchronizingTest_7_6 extends BaseTestCase {
|
||||||
IExpressionDMAddress data = query.get();
|
IExpressionDMAddress data = query.get();
|
||||||
|
|
||||||
fEventsReceived.clear();
|
fEventsReceived.clear();
|
||||||
queueConsoleCommand("print i=100");
|
|
||||||
|
final String newValue = "100";
|
||||||
|
queueConsoleCommand("print i=" + newValue);
|
||||||
|
|
||||||
IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class);
|
IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class);
|
||||||
assertEquals(1, memoryEvent.getAddresses().length);
|
assertEquals(1, memoryEvent.getAddresses().length);
|
||||||
assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]);
|
assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]);
|
||||||
|
|
||||||
|
// Now verify the memory service knows the new memory value
|
||||||
|
IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(frameDmc, IMemoryDMContext.class);
|
||||||
|
MemoryByte[] memory = readMemory(memoryDmc, data.getAddress(), 1);
|
||||||
|
assertEquals(newValue, Byte.toString(memory[0].getValue()));
|
||||||
|
|
||||||
|
// Now verify the expressions service knows the new value
|
||||||
|
String exprValue = SyncUtil.getExpressionValue(exprDmc, IFormattedValues.DECIMAL_FORMAT);
|
||||||
|
assertEquals(newValue, exprValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -242,11 +275,22 @@ public class GDBConsoleSynchronizingTest_7_6 extends BaseTestCase {
|
||||||
IExpressionDMAddress data = query.get();
|
IExpressionDMAddress data = query.get();
|
||||||
|
|
||||||
fEventsReceived.clear();
|
fEventsReceived.clear();
|
||||||
queueConsoleCommand("set {int}&i=100");
|
|
||||||
|
final String newValue = "100";
|
||||||
|
queueConsoleCommand("set {int}&i=" + newValue);
|
||||||
|
|
||||||
IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class);
|
IMemoryChangedEvent memoryEvent = waitForEvent(IMemoryChangedEvent.class);
|
||||||
assertEquals(1, memoryEvent.getAddresses().length);
|
assertEquals(1, memoryEvent.getAddresses().length);
|
||||||
assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]);
|
assertEquals(data.getAddress(), memoryEvent.getAddresses()[0]);
|
||||||
|
|
||||||
|
// Now verify the memory service knows the new memory value
|
||||||
|
IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(frameDmc, IMemoryDMContext.class);
|
||||||
|
MemoryByte[] memory = readMemory(memoryDmc, data.getAddress(), 1);
|
||||||
|
assertEquals(newValue, Byte.toString(memory[0].getValue()));
|
||||||
|
|
||||||
|
// Now verify the expressions service knows the new value
|
||||||
|
String exprValue = SyncUtil.getExpressionValue(exprDmc, IFormattedValues.DECIMAL_FORMAT);
|
||||||
|
assertEquals(newValue, exprValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Reference in a new issue