From 6ed3ce5fce594a9a8e0435e2ff2eaceb806f6960 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 5 Aug 2015 21:24:05 +0200 Subject: [PATCH] MIRegistersTest fixes - Fix getModelDataForRegisterDataValueInDifferentNumberFormats failure Nothing seems to set the register we use to do the test to a particular value. The value happened to be 0. This broke the octal test, because it assumes that the result starts with a 0, but has characters after that 0. This is not true when the result is 0. The fix is to set the register to a know value beforehand (0x1234). - Fix compareRegisterForMultipleExecutionContexts for slow targets by adding missing massageTimeout. Change-Id: I681acdeb08f8e3c2fdaf8dc9cf60801584da4423 Signed-off-by: Simon Marchi --- .../tests/dsf/gdb/tests/MIRegistersTest.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRegistersTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRegistersTest.java index 5c08836fe5d..3244d23d136 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRegistersTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRegistersTest.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -337,22 +339,25 @@ public class MIRegistersTest extends BaseTestCase { MIStoppedEvent stoppedEvent = getInitialStoppedEvent(); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + // Make sure register #0 contains a known value. + writeRegister(frameDmc, 0, "0x1234", IFormattedValues.HEX_FORMAT); + String val = getModelDataForRegisterDataValue(frameDmc, IFormattedValues.NATURAL_FORMAT, 0); - Long.parseLong(val); + assertThat(Long.parseLong(val), equalTo(0x1234L)); val = getModelDataForRegisterDataValue(frameDmc, IFormattedValues.HEX_FORMAT, 0); assertTrue("Register Value is not in HEX_FORMAT: " + val, val.startsWith("0x")); - Long.parseLong(val.substring(2), 16); + assertThat(Long.parseLong(val.substring(2), 16), equalTo(0x1234L)); val = getModelDataForRegisterDataValue(frameDmc, IFormattedValues.BINARY_FORMAT, 0); - Long.parseLong(val, 2); + assertThat(Long.parseLong(val, 2), equalTo(0x1234L)); val = getModelDataForRegisterDataValue(frameDmc, IFormattedValues.DECIMAL_FORMAT, 0); - Long.parseLong(val); + assertThat(Long.parseLong(val), equalTo(0x1234L)); val = getModelDataForRegisterDataValue(frameDmc, IFormattedValues.OCTAL_FORMAT, 0); assertTrue("Register Value is not in OCTAL_FORMAT: " + val, val.startsWith("0")); - Long.parseLong(val.substring(1), 8); + assertThat(Long.parseLong(val.substring(1), 8), equalTo(0x1234L)); } @Test @@ -372,7 +377,7 @@ public class MIRegistersTest extends BaseTestCase { fRegService.getExecutor().submit(queryExecutionContexts); - IExecutionDMContext[] ctxts = queryExecutionContexts.get(500, TimeUnit.MILLISECONDS); + IExecutionDMContext[] ctxts = queryExecutionContexts.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); assertNotNull(ctxts); assertTrue(ctxts.length > 1);