1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 00:35:49 +02:00

[dsf-gdb] Put back event assert in

MIMemoryTest.writeCharVarying{Address,Offset}

When we switched SyncUtil.readMemory to use queries, it exposed a race
condition with the asserts that check for the number of event received.
Basically, nothing guarantees that when the assert is evaluated the
event had the time to arrive.

We now use a ServiceEventWaitor to wait until the event arrives (with a
timeout, of course).

At the same time, rename word_size to wordSize.

Change-Id: I6f4b51e22f46625e20bbbdbac91cf70cfd864e5e
Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
This commit is contained in:
Simon Marchi 2015-02-19 13:56:32 -05:00 committed by Marc Khouzam
parent 7328220fe6
commit 7402cd3123

View file

@ -9,6 +9,7 @@
* Ericsson AB - Initial Implementation * Ericsson AB - Initial Implementation
* Alvaro Sanchez-Leon (Ericsson AB) - [Memory] Support 16 bit addressable size (Bug 426730) * Alvaro Sanchez-Leon (Ericsson AB) - [Memory] Support 16 bit addressable size (Bug 426730)
* Alvaro Sanchez-Leon (Ericsson AB) - [Memory] Make tests run with different values of addressable size (Bug 460241) * Alvaro Sanchez-Leon (Ericsson AB) - [Memory] Make tests run with different values of addressable size (Bug 460241)
* Simon Marchi (Ericsson)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests; package org.eclipse.cdt.tests.dsf.gdb.tests;
@ -45,6 +46,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.AsyncCompletionWaitor;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.MemoryByteBuffer; import org.eclipse.cdt.tests.dsf.gdb.framework.MemoryByteBuffer;
import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.cdt.utils.Addr64; import org.eclipse.cdt.utils.Addr64;
@ -795,6 +797,9 @@ public class MIMemoryTest extends BaseTestCase {
fBaseAddress = evaluateExpression(frameDmc, "&charBlock"); fBaseAddress = evaluateExpression(frameDmc, "&charBlock");
ServiceEventWaitor<IMemoryChangedEvent> eventWaitor = new ServiceEventWaitor<>(
fSession, IMemoryChangedEvent.class);
// Perform the test // Perform the test
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@ -811,10 +816,9 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.writeMemory(fMemoryDmc, address, offset, fWordSize, 1, buffer); SyncUtil.writeMemory(fMemoryDmc, address, offset, fWordSize, 1, buffer);
// [3] Verify that the correct MemoryChangedEvent was sent // [3] Verify that the correct MemoryChangedEvent was sent
// (I hardly believe there are no synchronization problems here...) IMemoryChangedEvent event = eventWaitor.waitForEvent(TestsPlugin.massageTimeout(1000));
// TODO FOR REVIEW: This assert fails assertThat(event.getAddresses().length, is(1));
//assertEquals("Incorrect count of MemoryChangedEvent at offset " + i, i + 1, getEventCount()); assertThat(event.getAddresses()[0], is(address));
//assertTrue("MemoryChangedEvent problem at offset " + i, fMemoryAddressesChanged[i]);
// [4] Verify that the memory byte was written correctly // [4] Verify that the memory byte was written correctly
block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, i, fWordSize, 1); block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, i, fWordSize, 1);
@ -842,6 +846,9 @@ public class MIMemoryTest extends BaseTestCase {
byte[] buffer; byte[] buffer;
fBaseAddress = evaluateExpression(frameDmc, "&charBlock"); fBaseAddress = evaluateExpression(frameDmc, "&charBlock");
ServiceEventWaitor<IMemoryChangedEvent> eventWaitor = new ServiceEventWaitor<>(
fSession, IMemoryChangedEvent.class);
// Perform the test // Perform the test
for (int offset = 0; offset < count; offset++) { for (int offset = 0; offset < count; offset++) {
@ -857,9 +864,9 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, fWordSize, 1, buffer); SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, fWordSize, 1, buffer);
// [3] Verify that the correct MemoryChangedEvent was sent // [3] Verify that the correct MemoryChangedEvent was sent
// TODO FOR REVIEW: this fails IMemoryChangedEvent event = eventWaitor.waitForEvent(TestsPlugin.massageTimeout(1000));
//assertEquals("Incorrect count of MemoryChangedEvent at offset " + offset, offset + 1, getEventCount()); assertThat(event.getAddresses().length, is(1));
//assertTrue("MemoryChangedEvent problem at offset " + offset, fMemoryAddressesChanged[offset]); assertThat(event.getAddresses()[0], is(fBaseAddress.add(offset)));
// [4] Verify that the memory byte was written correctly // [4] Verify that the memory byte was written correctly
block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, fWordSize, 1); block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, fWordSize, 1);