Skip to content

Commit 1dc69c0

Browse files
pdgendtcarlescufi
authored andcommitted
tests: drivers: memc: Rework S(D)RAM test with ztest
* Reworked the stm32 SDRAM test to be more generic * Added SRAM entries * Moved to new ztest API Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 683f3b7 commit 1dc69c0

File tree

6 files changed

+97
-73
lines changed

6 files changed

+97
-73
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
CONFIG_ZTEST=y
22
CONFIG_MEMC=y
3+
CONFIG_ZTEST_NEW_API=y

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

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (c) 2020, Teslabs Engineering S.L.
3+
* Copyright (c) 2022, Basalte bv
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#include <zephyr/linker/devicetree_regions.h>
9+
#include <zephyr/zephyr.h>
10+
#include <zephyr/ztest.h>
11+
12+
/** Buffer size. */
13+
#define BUF_SIZE 64U
14+
#define BUF_DEF(label) static uint32_t buf_##label[BUF_SIZE] \
15+
Z_GENERIC_SECTION(LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(label)))
16+
17+
/**
18+
* @brief Helper function to test RAM r/w.
19+
*
20+
* @param mem RAM memory location to be tested.
21+
*/
22+
static void test_ram_rw(uint32_t *mem)
23+
{
24+
/* fill memory with number range (0, BUF_SIZE - 1) */
25+
for (size_t i = 0U; i < BUF_SIZE; i++) {
26+
mem[i] = i;
27+
}
28+
29+
/* check that memory contains written range */
30+
for (size_t i = 0U; i < BUF_SIZE; i++) {
31+
zassert_equal(mem[i], i, "Unexpected content");
32+
}
33+
}
34+
35+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram1), okay)
36+
BUF_DEF(sdram1);
37+
#endif
38+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram2), okay)
39+
BUF_DEF(sdram2);
40+
#endif
41+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram1), okay)
42+
BUF_DEF(sram1);
43+
#endif
44+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram2), okay)
45+
BUF_DEF(sram2);
46+
#endif
47+
48+
ZTEST_SUITE(test_ram, NULL, NULL, NULL, NULL, NULL);
49+
50+
ZTEST(test_ram, test_sdram1)
51+
{
52+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram1), okay)
53+
test_ram_rw(buf_sdram1);
54+
#else
55+
ztest_test_skip();
56+
#endif
57+
}
58+
59+
ZTEST(test_ram, test_sdram2)
60+
{
61+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram2), okay)
62+
test_ram_rw(buf_sdram2);
63+
#else
64+
ztest_test_skip();
65+
#endif
66+
}
67+
68+
ZTEST(test_ram, test_sram1)
69+
{
70+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram1), okay)
71+
test_ram_rw(buf_sram1);
72+
#else
73+
ztest_test_skip();
74+
#endif
75+
}
76+
77+
ZTEST(test_ram, test_sram2)
78+
{
79+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram2), okay)
80+
test_ram_rw(buf_sram2);
81+
#else
82+
ztest_test_skip();
83+
#endif
84+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
tests:
2+
drivers.memc.stm32_sdram:
3+
tags: drivers memc
4+
depends_on: memc
5+
filter: dt_compat_enabled("st,stm32-fmc-sdram")
6+
drivers.memc.smc_sram:
7+
tags: drivers memc
8+
depends_on: memc
9+
filter: dt_compat_enabled("atmel,sam-smc")
10+
platform_allow: sam4s_xplained
11+
integration_platforms:
12+
- sam4s_xplained

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

Lines changed: 0 additions & 68 deletions
This file was deleted.

tests/drivers/memc/stm32_sdram/testcase.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)