1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

debug tests: MIMemoryTest: Use assertEquals instead of assertTrue when

possible

Change-Id: If9fc8f3f0f1f2070b7bc4ea6dc23778001dc0092
Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
This commit is contained in:
Simon Marchi 2015-01-24 01:19:08 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent d41b69136d
commit a96fcd5a37

View file

@ -367,7 +367,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.readMemory(dmc, fBaseAddress, offset, word_size, count); SyncUtil.readMemory(dmc, fBaseAddress, offset, word_size, count);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -393,11 +393,11 @@ public class MIMemoryTest extends BaseTestCase {
MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count); MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count);
// Ensure that we receive a block of invalid memory bytes // Ensure that we receive a block of invalid memory bytes
assertTrue("Wrong value: expected '0, 32', received '" + buffer[0].getValue() + ", " + buffer[0].getFlags() + "'", assertEquals("Wrong value", (byte) 0, buffer[0].getValue());
(buffer[0].getValue() == (byte) 0) && (buffer[0].getFlags() == (byte) 32)); assertEquals("Wrong flags", (byte) 32, buffer[0].getFlags());
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -426,7 +426,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, 0, count); SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, 0, count);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -457,7 +457,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count); SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -484,8 +484,7 @@ public class MIMemoryTest extends BaseTestCase {
for (int i = 0; i < BLOCK_SIZE; i++) { for (int i = 0; i < BLOCK_SIZE; i++) {
IAddress address = fBaseAddress.add(i); IAddress address = fBaseAddress.add(i);
MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, address, offset, word_size, count); MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, address, offset, word_size, count);
assertTrue("Wrong value read at offset " + i + ": expected '" + 0 + "', received '" + buffer[0].getValue() + "'", assertEquals("Wrong value read at offset " + i, (byte) 0, buffer[0].getValue());
(buffer[0].getValue() == (byte) 0));
} }
// Run to the point where the variable is initialized // Run to the point where the variable is initialized
@ -497,12 +496,11 @@ public class MIMemoryTest extends BaseTestCase {
for (int i = 0; i < BLOCK_SIZE; i++) { for (int i = 0; i < BLOCK_SIZE; i++) {
IAddress address = fBaseAddress.add(i); IAddress address = fBaseAddress.add(i);
MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, address, offset, word_size, count); MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, address, offset, word_size, count);
assertTrue("Wrong value read at offset " + i + ": expected '" + i + "', received '" + buffer[0].getValue() + "'", assertEquals("Wrong value read at offset " + i, (byte) i, buffer[0].getValue());
(buffer[0].getValue() == (byte) i));
} }
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -526,8 +524,8 @@ public class MIMemoryTest extends BaseTestCase {
// Verify that all bytes are '0' // Verify that all bytes are '0'
for (int offset = 0; offset < BLOCK_SIZE; offset++) { for (int offset = 0; offset < BLOCK_SIZE; offset++) {
MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count); MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count);
assertTrue("Wrong value read at offset " + offset + ": expected '" + 0 + "', received '" + buffer[0].getValue() + "'", assertEquals("Wrong value read at offset " + offset, (byte) 0, buffer[0].getValue());
(buffer[0].getValue() == (byte) 0));
} }
// Run to the point where the array is set // Run to the point where the array is set
@ -538,12 +536,11 @@ public class MIMemoryTest extends BaseTestCase {
// Verify that all bytes are set // Verify that all bytes are set
for (int offset = 0; offset < BLOCK_SIZE; offset++) { for (int offset = 0; offset < BLOCK_SIZE; offset++) {
MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count); MemoryByte[] buffer = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count);
assertTrue("Wrong value read at offset " + offset + ": expected '" + offset + "', received '" + buffer[0].getValue() + "'", assertEquals("Wrong value read at offset " + offset, (byte) offset, buffer[0].getValue());
(buffer[0].getValue() == (byte) offset));
} }
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -570,8 +567,8 @@ public class MIMemoryTest extends BaseTestCase {
// Verify that all bytes are '0' // Verify that all bytes are '0'
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
assertTrue("Wrong value read at offset " + i + ": expected '" + 0 + "', received '" + buffer[i].getValue() + "'", assertEquals("Wrong value read at offset " + i, (byte) 0, buffer[i].getValue());
(buffer[i].getValue() == (byte) 0));
} }
// Run to the point where the variable is initialized // Run to the point where the variable is initialized
@ -584,12 +581,12 @@ public class MIMemoryTest extends BaseTestCase {
// Verify that all bytes are '0' // Verify that all bytes are '0'
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
assertTrue("Wrong value read at offset " + i + ": expected '" + i + "', received '" + buffer[i].getValue() + "'", assertEquals("Wrong value read at offset " + i, (byte) i, buffer[i].getValue());
(buffer[i].getValue() == (byte) i));
} }
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -624,7 +621,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.writeMemory(null, fBaseAddress, offset, word_size, count, buffer); SyncUtil.writeMemory(null, fBaseAddress, offset, word_size, count, buffer);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -656,7 +653,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, buffer); SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, buffer);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -687,7 +684,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, 0, count, buffer); SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, 0, count, buffer);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -719,7 +716,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, buffer); SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, buffer);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -751,7 +748,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, buffer); SyncUtil.writeMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, buffer);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -780,8 +777,8 @@ public class MIMemoryTest extends BaseTestCase {
// [1] Ensure that the memory byte = 0 // [1] Ensure that the memory byte = 0
MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, i, word_size, 1); MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, i, word_size, 1);
assertTrue("Wrong value read at offset " + i + ": expected '" + 0 + "', received '" + block[0].getValue() + "'", assertEquals("Wrong value read at offset " + i, (byte) 0, block[0].getValue());
(block[0].getValue() == (byte) 0));
// [2] Write a byte value (count - i - 1) // [2] Write a byte value (count - i - 1)
IAddress address = fBaseAddress.add(i); IAddress address = fBaseAddress.add(i);
@ -793,21 +790,17 @@ public class MIMemoryTest extends BaseTestCase {
// [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...) // (I hardly believe there are no synchronization problems here...)
// TODO FOR REVIEW: This assert fails // TODO FOR REVIEW: This assert fails
//assertTrue("MemoryChangedEvent problem at offset " + i + ": expected " + (i + 1) + " events, received " + getEventCount(), //assertEquals("Incorrect count of MemoryChangedEvent at offset " + i, i + 1, getEventCount());
// getEventCount() == (i + 1));
//assertTrue("MemoryChangedEvent problem at offset " + i, fMemoryAddressesChanged[i]); //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, word_size, 1); block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, i, word_size, 1);
assertTrue("Wrong value read at offset " + i + ": expected '" + expected + "', received '" + block[0].getValue() + "'", assertEquals("Wrong value read at offset " + i, expected, block[0].getValue());
(block[0].getValue() == expected));
} }
// Ensure the MemoryChangedEvent events were received // Ensure the MemoryChangedEvent events were received
assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " events, received " + getEventCount(), assertEquals("Incorrect count of MemoryChangedEvent", BLOCK_SIZE, getEventCount());
getEventCount() == BLOCK_SIZE); assertEquals("Incorrect count of events for distinct addresses", BLOCK_SIZE, getAddressCount());
assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " distinct addresses, received " + getAddressCount(),
getEventCount() == BLOCK_SIZE);
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -833,8 +826,7 @@ public class MIMemoryTest extends BaseTestCase {
// [1] Ensure that the memory byte = 0 // [1] Ensure that the memory byte = 0
MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, 1); MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, 1);
assertTrue("Wrong value read at offset " + offset + ": expected '" + 0 + "', received '" + block[0].getValue() + "'", assertEquals("Wrong value read at offset " + offset, (byte) 0, block[0].getValue());
(block[0].getValue() == (byte) 0));
// [2] Write a byte value (count - offset - 1) // [2] Write a byte value (count - offset - 1)
fWait.waitReset(); fWait.waitReset();
@ -844,21 +836,17 @@ public class MIMemoryTest extends BaseTestCase {
// [3] Verify that the correct MemoryChangedEvent was sent // [3] Verify that the correct MemoryChangedEvent was sent
// TODO FOR REVIEW: this fails // TODO FOR REVIEW: this fails
//assertTrue("MemoryChangedEvent problem at offset " + offset + ": expected " + (offset + 1) + " events, received " + getEventCount(), //assertEquals("Incorrect count of MemoryChangedEvent at offset " + offset, offset + 1, getEventCount());
// getEventCount() == (offset + 1));
//assertTrue("MemoryChangedEvent problem at offset " + offset, fMemoryAddressesChanged[offset]); //assertTrue("MemoryChangedEvent problem at offset " + offset, fMemoryAddressesChanged[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, word_size, 1); block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, 1);
assertTrue("Wrong value read at offset " + offset + ": expected '" + expected + "', received '" + block[0].getValue() + "'", assertEquals("Wrong value read at offset " + offset, expected, block[0].getValue());
(block[0].getValue() == expected));
} }
// Ensure the MemoryChangedEvent events were received // Ensure the MemoryChangedEvent events were received
assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " events, received " + getEventCount(), assertEquals("Incorrect count of MemoryChangedEvent", BLOCK_SIZE, getEventCount());
getEventCount() == BLOCK_SIZE); assertEquals("Incorrect count of events for distinct addresses", BLOCK_SIZE, getAddressCount());
assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " distinct addresses, received " + getAddressCount(),
getAddressCount() == BLOCK_SIZE);
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -883,8 +871,7 @@ public class MIMemoryTest extends BaseTestCase {
// Make sure that the memory block is zeroed // Make sure that the memory block is zeroed
MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count); MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
assertTrue("Wrong value read at offset " + i + ": expected '" + 0 + "', received '" + block[i].getValue() + "'", assertEquals("Wrong value read at offset " + i, (byte) 0, block[i].getValue());
(block[i].getValue() == (byte) 0));
} }
// Write an initialized memory block // Write an initialized memory block
@ -897,15 +884,12 @@ public class MIMemoryTest extends BaseTestCase {
// Make sure that the memory block is initialized // Make sure that the memory block is initialized
block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count); block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
assertTrue("Wrong value read at offset " + i + ": expected '" + 0 + "', received '" + block[i].getValue() + "'", assertEquals("Wrong value read at offset " + i, (byte) i, block[i].getValue());
(block[i].getValue() == (byte) i));
} }
// Ensure the MemoryChangedEvent events were received // Ensure the MemoryChangedEvent events were received
assertTrue("MemoryChangedEvent problem: expected " + 1 + " event, received " + getEventCount(), assertEquals("Incorrect count of MemoryChangedEvent", 1, getEventCount());
getEventCount() == 1); assertEquals("Incorrect count of events for distinct addresses", BLOCK_SIZE, getAddressCount());
assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " distinct addresses, received " + getAddressCount(),
getAddressCount() == BLOCK_SIZE);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -940,7 +924,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.fillMemory(null, fBaseAddress, offset, word_size, count, pattern); SyncUtil.fillMemory(null, fBaseAddress, offset, word_size, count, pattern);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("Incorrect count of MemoryChangedEvent", 0, getEventCount());
} }
} }
@ -978,7 +962,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, pattern); SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, pattern);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -1009,7 +993,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, 0, count, pattern); SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, 0, count, pattern);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -1041,7 +1025,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, pattern); SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, pattern);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -1073,7 +1057,7 @@ public class MIMemoryTest extends BaseTestCase {
SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, pattern); SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, pattern);
} finally { } finally {
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertTrue("MemoryChangedEvent problem: expected " + 0 + ", received " + getEventCount(), getEventCount() == 0); assertEquals("MemoryChangedEvent problem: expected 0 events", 0, getEventCount());
} }
} }
@ -1102,8 +1086,7 @@ public class MIMemoryTest extends BaseTestCase {
// Ensure that the memory is zeroed // Ensure that the memory is zeroed
MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count * length); MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count * length);
for (int i = 0; i < (count * length); i++) for (int i = 0; i < (count * length); i++)
assertTrue("Wrong value read at offset " + i + ": expected '" + 0 + "', received '" + block[i].getValue() + "'", assertEquals("Wrong value read at offset " + i, (byte) 0, block[i].getValue());
(block[i].getValue() == (byte) 0));
for (int i = 0; i < BLOCK_SIZE; i += length) { for (int i = 0; i < BLOCK_SIZE; i += length) {
IAddress address = fBaseAddress.add(i); IAddress address = fBaseAddress.add(i);
@ -1115,15 +1098,12 @@ public class MIMemoryTest extends BaseTestCase {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
for (int j = 0; j < length; j++) { for (int j = 0; j < length; j++) {
int index = i * length + j; int index = i * length + j;
assertTrue("Wrong value read at offset " + index + ": expected '" + j + "', received '" + block[index].getValue() + "'", assertEquals("Wrong value read at offset " + index, (byte) j, block[index].getValue());
(block[index].getValue() == (byte) j));
} }
// Ensure the MemoryChangedEvent events were received // Ensure the MemoryChangedEvent events were received
assertTrue("MemoryChangedEvent problem: expected " + (BLOCK_SIZE / length) + " events, received " + getEventCount(), assertEquals("Incorrect count of MemoryChangedEvent", BLOCK_SIZE / length, getEventCount());
getEventCount() == (BLOCK_SIZE / length)); assertEquals("Incorrect count of events for distinct addresses", BLOCK_SIZE, getAddressCount());
assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " distinct addresses, received " + getAddressCount(),
getAddressCount() == BLOCK_SIZE);
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -1151,8 +1131,7 @@ public class MIMemoryTest extends BaseTestCase {
// Ensure that the memory is zeroed // Ensure that the memory is zeroed
MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count * length); MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count * length);
for (int i = 0; i < (count * length); i++) for (int i = 0; i < (count * length); i++)
assertTrue("Wrong value read at offset " + i + ": expected '" + 0 + "', received '" + block[i].getValue() + "'", assertEquals("Wrong value read at offset " + i, 0, block[i].getValue());
(block[i].getValue() == (byte) 0));
for (int i = 0; i < (BLOCK_SIZE / length); i++) { for (int i = 0; i < (BLOCK_SIZE / length); i++) {
offset = i * length; offset = i * length;
@ -1164,15 +1143,13 @@ public class MIMemoryTest extends BaseTestCase {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
for (int j = 0; j < length; j++) { for (int j = 0; j < length; j++) {
int index = i * length + j; int index = i * length + j;
assertTrue("Wrong value read at offset " + index + ": expected '" + j + "', received '" + block[index].getValue() + "'", assertEquals("Wrong value read at offset " + index, (byte) j, block[index].getValue());
(block[index].getValue() == (byte) j));
} }
// Ensure the MemoryChangedEvent events were received // Ensure the MemoryChangedEvent events were received
assertTrue("MemoryChangedEvent problem: expected " + (BLOCK_SIZE / length) + " events, received " + getEventCount(), assertEquals("Incorrect count of MemoryChangedEvent", BLOCK_SIZE / length, getEventCount());
getEventCount() == (BLOCK_SIZE / length)); assertEquals("Incorrect count of events for distinct addresses", BLOCK_SIZE, getAddressCount());
assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " distinct addresses, received " + getAddressCount(),
getAddressCount() == BLOCK_SIZE);
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -1200,8 +1177,7 @@ public class MIMemoryTest extends BaseTestCase {
// Ensure that the memory is zeroed // Ensure that the memory is zeroed
MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count * length); MemoryByte[] block = SyncUtil.readMemory(fMemoryDmc, fBaseAddress, offset, word_size, count * length);
for (int i = 0; i < (count * length); i++) for (int i = 0; i < (count * length); i++)
assertTrue("Wrong value read at offset " + i + ": expected '" + 0 + "', received '" + block[i].getValue() + "'", assertEquals("Wrong value read at offset " + i, (byte) 0, block[i].getValue());
(block[i].getValue() == (byte) 0));
// Write the pattern [count] times // Write the pattern [count] times
SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, pattern); SyncUtil.fillMemory(fMemoryDmc, fBaseAddress, offset, word_size, count, pattern);
@ -1211,15 +1187,13 @@ public class MIMemoryTest extends BaseTestCase {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
for (int j = 0; j < length; j++) { for (int j = 0; j < length; j++) {
int index = i * length + j; int index = i * length + j;
assertTrue("Wrong value read at offset " + index + ": expected '" + j + "', received '" + block[index].getValue() + "'", assertEquals("Wrong value read at offset " + index, (byte) j, block[index].getValue());
(block[index].getValue() == (byte) j));
} }
// Ensure the MemoryChangedEvent events were received // Ensure the MemoryChangedEvent events were received
assertTrue("MemoryChangedEvent problem: expected " + 1 + " events, received " + getEventCount(), assertEquals("Incorrect count of MemoryChangedEvent", 1, getEventCount());
getEventCount() == 1); assertEquals("Incorrect count of events for distinct addresses", BLOCK_SIZE, getAddressCount());
assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " distinct addresses, received " + getAddressCount(),
getAddressCount() == BLOCK_SIZE);
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -1278,10 +1252,8 @@ public class MIMemoryTest extends BaseTestCase {
// Ensure the MemoryChangedEvent events were received // Ensure the MemoryChangedEvent events were received
// TODO FOR REVIEW: This fails // TODO FOR REVIEW: This fails
//assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " events, received " + getEventCount(), //assertEquals("Incorrect count of MemoryChangedEvent", BLOCK_SIZE, getEventCount());
// getEventCount() == BLOCK_SIZE); //assertEquals("Incorrect count of events for distinct addresses", BLOCK_SIZE, getAddressCount());
//assertTrue("MemoryChangedEvent problem: expected " + BLOCK_SIZE + " distinct addresses, received " + getAddressCount(),
// getAddressCount() == BLOCK_SIZE);
// Verify asynchronously that all bytes are set // Verify asynchronously that all bytes are set
fWait.waitReset(); fWait.waitReset();
@ -1306,8 +1278,7 @@ public class MIMemoryTest extends BaseTestCase {
// Verify that all bytes are correctly set // Verify that all bytes are correctly set
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
assertEquals("Wrong value read at offset " + i, assertEquals("Wrong value read at offset " + i, (byte) (offset + i), buffer[i].getValue());
(byte) (offset + i), buffer[i].getValue());
} }
} }
@ -1359,7 +1330,6 @@ public class MIMemoryTest extends BaseTestCase {
memoryCacheReadHelper(0, BLOCK_SIZE, word_size); memoryCacheReadHelper(0, BLOCK_SIZE, word_size);
// Ensure no MemoryChangedEvent event was received // Ensure no MemoryChangedEvent event was received
assertEquals("MemoryChangedEvent problem: expected 0 events received.", assertEquals("Incorrect count of MemoryChangedEvent", 0, getEventCount());
0, getEventCount());
} }
} }