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 <pieter.degendt@basalte.be>
This commit is contained in:
parent
683f3b7b05
commit
1dc69c0648
6 changed files with 97 additions and 73 deletions
|
@ -1,2 +1,3 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_MEMC=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
84
tests/drivers/memc/ram/src/main.c
Normal file
84
tests/drivers/memc/ram/src/main.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Teslabs Engineering S.L.
|
||||
* Copyright (c) 2022, Basalte bv
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/linker/devicetree_regions.h>
|
||||
#include <zephyr/zephyr.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
/** Buffer size. */
|
||||
#define BUF_SIZE 64U
|
||||
#define BUF_DEF(label) static uint32_t buf_##label[BUF_SIZE] \
|
||||
Z_GENERIC_SECTION(LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(label)))
|
||||
|
||||
/**
|
||||
* @brief Helper function to test RAM r/w.
|
||||
*
|
||||
* @param mem RAM memory location to be tested.
|
||||
*/
|
||||
static void test_ram_rw(uint32_t *mem)
|
||||
{
|
||||
/* fill memory with number range (0, BUF_SIZE - 1) */
|
||||
for (size_t i = 0U; i < BUF_SIZE; i++) {
|
||||
mem[i] = i;
|
||||
}
|
||||
|
||||
/* check that memory contains written range */
|
||||
for (size_t i = 0U; i < BUF_SIZE; i++) {
|
||||
zassert_equal(mem[i], i, "Unexpected content");
|
||||
}
|
||||
}
|
||||
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram1), okay)
|
||||
BUF_DEF(sdram1);
|
||||
#endif
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram2), okay)
|
||||
BUF_DEF(sdram2);
|
||||
#endif
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram1), okay)
|
||||
BUF_DEF(sram1);
|
||||
#endif
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram2), okay)
|
||||
BUF_DEF(sram2);
|
||||
#endif
|
||||
|
||||
ZTEST_SUITE(test_ram, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
ZTEST(test_ram, test_sdram1)
|
||||
{
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram1), okay)
|
||||
test_ram_rw(buf_sdram1);
|
||||
#else
|
||||
ztest_test_skip();
|
||||
#endif
|
||||
}
|
||||
|
||||
ZTEST(test_ram, test_sdram2)
|
||||
{
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram2), okay)
|
||||
test_ram_rw(buf_sdram2);
|
||||
#else
|
||||
ztest_test_skip();
|
||||
#endif
|
||||
}
|
||||
|
||||
ZTEST(test_ram, test_sram1)
|
||||
{
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram1), okay)
|
||||
test_ram_rw(buf_sram1);
|
||||
#else
|
||||
ztest_test_skip();
|
||||
#endif
|
||||
}
|
||||
|
||||
ZTEST(test_ram, test_sram2)
|
||||
{
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram2), okay)
|
||||
test_ram_rw(buf_sram2);
|
||||
#else
|
||||
ztest_test_skip();
|
||||
#endif
|
||||
}
|
12
tests/drivers/memc/ram/testcase.yaml
Normal file
12
tests/drivers/memc/ram/testcase.yaml
Normal file
|
@ -0,0 +1,12 @@
|
|||
tests:
|
||||
drivers.memc.stm32_sdram:
|
||||
tags: drivers memc
|
||||
depends_on: memc
|
||||
filter: dt_compat_enabled("st,stm32-fmc-sdram")
|
||||
drivers.memc.smc_sram:
|
||||
tags: drivers memc
|
||||
depends_on: memc
|
||||
filter: dt_compat_enabled("atmel,sam-smc")
|
||||
platform_allow: sam4s_xplained
|
||||
integration_platforms:
|
||||
- sam4s_xplained
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Teslabs Engineering S.L.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/zephyr.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
/** Buffer size. */
|
||||
#define BUF_SIZE 64U
|
||||
|
||||
/**
|
||||
* @brief Helper function to test SDRAM r/w.
|
||||
*
|
||||
* @param mem SDRAM memory location to be tested.
|
||||
*/
|
||||
static void test_sdram_rw(uint32_t *mem)
|
||||
{
|
||||
/* fill memory with number range (0, BUF_SIZE - 1) */
|
||||
for (size_t i = 0U; i < BUF_SIZE; i++) {
|
||||
mem[i] = i;
|
||||
}
|
||||
|
||||
/* check that memory contains written range */
|
||||
for (size_t i = 0U; i < BUF_SIZE; i++) {
|
||||
zassert_equal(mem[i], i, "Unexpected content");
|
||||
}
|
||||
}
|
||||
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram1), okay)
|
||||
/** Buffer on SDRAM1. */
|
||||
__stm32_sdram1_section uint32_t sdram1[BUF_SIZE];
|
||||
|
||||
static void test_sdram1_rw(void)
|
||||
{
|
||||
test_sdram_rw(sdram1);
|
||||
}
|
||||
#else
|
||||
static void test_sdram1_rw(void)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram2), okay)
|
||||
/** Buffer on SDRAM2. */
|
||||
__stm32_sdram2_section uint32_t sdram2[BUF_SIZE];
|
||||
|
||||
static void test_sdram2_rw(void)
|
||||
{
|
||||
test_sdram_rw(sdram2);
|
||||
}
|
||||
|
||||
#else
|
||||
static void test_sdram2_rw(void)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(stm32_sdram,
|
||||
ztest_unit_test(test_sdram1_rw),
|
||||
ztest_unit_test(test_sdram2_rw));
|
||||
ztest_run_test_suite(stm32_sdram);
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
tests:
|
||||
drivers.memc.stm32_sdram:
|
||||
tags: drivers memc
|
||||
depends_on: memc
|
||||
filter: dt_compat_enabled("st,stm32-fmc-sdram")
|
Loading…
Add table
Add a link
Reference in a new issue