Skip to content

Commit b88d259

Browse files
etienne-lmsfabiobaltieri
authored andcommitted
tests: drivers: memc: fix minor inconsistencies in offsets
Correct memc driver test application to allocated only the required size for the tests and print valid information instead of byte offset that was actually a 32bit cell pointer offset. Signed-off-by: Etienne Carriere <[email protected]>
1 parent 2b858a4 commit b88d259

File tree

1 file changed

+8
-5
lines changed
  • tests/drivers/memc/ram/src

1 file changed

+8
-5
lines changed

tests/drivers/memc/ram/src/main.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,27 @@
1515
#define BUF_SIZE_SDRAM 64U
1616
#define BUF_SIZE_SRAM 64U
1717

18-
#define BUF_DEF(label, size) static uint32_t buf_##label[size] \
18+
#define BUF_DEF(label, size) static uint32_t buf_##label[(size) / sizeof(uint32_t)] \
1919
Z_GENERIC_SECTION(LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(label)))
2020

2121
/**
2222
* @brief Helper function to test RAM r/w.
2323
*
2424
* @param mem RAM memory location to be tested.
2525
*/
26-
static void test_ram_rw(uint32_t *mem, size_t size)
26+
static void test_ram_rw(uint32_t *mem, size_t size_byte)
2727
{
28+
size_t size_32b = size_byte / sizeof(uint32_t);
29+
2830
/* fill memory with number range (0, BUF_SIZE - 1) */
29-
for (size_t i = 0U; i < size / sizeof(uint32_t); i++) {
31+
for (size_t i = 0U; i < size_32b; i++) {
3032
mem[i] = i;
3133
}
3234

3335
/* check that memory contains written range */
34-
for (size_t i = 0U; i < size / sizeof(uint32_t); i++) {
35-
zassert_equal(mem[i], i, "Unexpected content on byte %zd", i);
36+
for (size_t i = 0U; i < size_32b; i++) {
37+
zassert_equal(mem[i], i, "Unexpected content @%p: 0x%x != 0x%zx",
38+
mem + i, mem[i], i);
3639
}
3740
}
3841

0 commit comments

Comments
 (0)