Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marchi2017-01-27 22:22:36 -0500
committerMarc Khouzam2017-03-06 10:44:15 -0500
commite14b87a88f4e388c18feeebed7a498b974f5908b (patch)
tree2ea039e081c845c1e9ef8cc8fa105a5c622b0924 /dsf-gdb
parent808df2490bc97661df61739b7e178c285b7cdd4f (diff)
downloadorg.eclipse.cdt-e14b87a88f4e388c18feeebed7a498b974f5908b.tar.gz
org.eclipse.cdt-e14b87a88f4e388c18feeebed7a498b974f5908b.tar.xz
org.eclipse.cdt-e14b87a88f4e388c18feeebed7a498b974f5908b.zip
Use line tags in MIExpressionsTest.testUpdateOfPointer
Running to different points of the test program using line tags is easier and safer than stepping a certain number of times. Since I want to modify this test to add a pointer-behind-typedef test, I thought it would be good to first convert it to line tags. I also took the liberty of giving more meaningful names to the structure fields, even though it doesn't change anything in the test. Change-Id: Ife7e2ae8557789dfc7403df71ba5126ca84b80e0 Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
Diffstat (limited to 'dsf-gdb')
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc23
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java21
2 files changed, 31 insertions, 13 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc
index 7037087b00..aa4ef2089d 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc
@@ -283,18 +283,23 @@ int testConcurrentUpdateOutOfScopeChildThenParent() {
int testUpdateOfPointer() {
struct {
- int a;
- int* b;
- }z;
+ int value;
+ int* ptr;
+ } z;
- int c = 3;
+ int otherValue = 3;
- z.b = &(z.a);
- z.a = 1;
+ z.ptr = &z.value;
+ z.value = 1;
+
+ /* testUpdateOfPointer_1 */
- z.b = &c;
- z.a = 2;
- z.a = 2; // this redundant line is here to ensure 6 steps after running to this func leaves locals visible
+ z.ptr = &otherValue;
+ z.value = 2;
+
+ /* testUpdateOfPointer_2 */
+
+ return 0;
}
int testCanWrite() {
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java
index 64407ed909..8f8691ccfc 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java
@@ -70,6 +70,7 @@ import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class MIExpressionsTest extends BaseParametrizedTestCase {
private static final String EXEC_NAME = "ExpressionTestApp.exe";
+ private static final String SOURCE_NAME = "ExpressionTestApp.cc";
private DsfSession fSession;
@@ -91,10 +92,19 @@ public class MIExpressionsTest extends BaseParametrizedTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EXEC_PATH + EXEC_NAME);
}
+ /* Line tags in the source file. */
+ private static final String[] LINE_TAGS = new String[] {
+ "testUpdateOfPointer_1",
+ "testUpdateOfPointer_2",
+ };
+
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
+ /* Resolve line tags in source file. */
+ resolveLineTagLocations(SOURCE_NAME, LINE_TAGS);
+
fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@Override
@@ -2579,8 +2589,11 @@ public class MIExpressionsTest extends BaseParametrizedTestCase {
*/
@Test
public void testUpdateOfPointer() throws Throwable {
- SyncUtil.runToLocation("testUpdateOfPointer");
- MIStoppedEvent stoppedEvent = SyncUtil.step(3, StepType.STEP_OVER);
+ /* Places we're going to run to. */
+ String tag1 = String.format("%s:%d", SOURCE_NAME, getLineForTag("testUpdateOfPointer_1"));
+ String tag2 = String.format("%s:%d", SOURCE_NAME, getLineForTag("testUpdateOfPointer_2"));
+
+ MIStoppedEvent stoppedEvent = SyncUtil.runToLocation(tag1);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
/* Create expression for the structure. */
@@ -2602,8 +2615,8 @@ public class MIExpressionsTest extends BaseParametrizedTestCase {
String pointeeActualValue = SyncUtil.getExpressionValue(pointeeDmc, IFormattedValues.NATURAL_FORMAT);
assertThat(pointeeActualValue, is("1"));
- /* Now, step to change the values of all the children. */
- SyncUtil.step(2, StepType.STEP_OVER);
+ /* Run to the second tag. */
+ SyncUtil.runToLocation(tag2);
/* Get the value of the integer. */
integerValue = SyncUtil.getExpressionValue(fieldsDmc[0], IFormattedValues.NATURAL_FORMAT);

Back to the top