From dffdec18c2b353a91e5c9fefdb6eed302b2d44e7 Mon Sep 17 00:00:00 2001 From: Riadh Ghaddab Date: Mon, 24 Mar 2025 14:12:44 +0100 Subject: [PATCH] tests: settings: add functional test for ZMS Add the functional test for the new backend of ZMS Signed-off-by: Riadh Ghaddab --- .../functional/src/settings_basic_test.c | 2 +- .../settings/functional/zms/CMakeLists.txt | 10 ++++++++ tests/subsys/settings/functional/zms/prj.conf | 8 ++++++ .../functional/zms/settings_test_zms.c | 25 +++++++++++++++++++ .../settings/functional/zms/testcase.yaml | 9 +++++++ 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/subsys/settings/functional/zms/CMakeLists.txt create mode 100644 tests/subsys/settings/functional/zms/prj.conf create mode 100644 tests/subsys/settings/functional/zms/settings_test_zms.c create mode 100644 tests/subsys/settings/functional/zms/testcase.yaml diff --git a/tests/subsys/settings/functional/src/settings_basic_test.c b/tests/subsys/settings/functional/src/settings_basic_test.c index 2766e7ea97d..1d8349941b9 100644 --- a/tests/subsys/settings/functional/src/settings_basic_test.c +++ b/tests/subsys/settings/functional/src/settings_basic_test.c @@ -16,7 +16,7 @@ #include LOG_MODULE_REGISTER(settings_basic_test); -#if defined(CONFIG_SETTINGS_FCB) || defined(CONFIG_SETTINGS_NVS) +#if defined(CONFIG_SETTINGS_FCB) || defined(CONFIG_SETTINGS_NVS) || defined(CONFIG_SETTINGS_ZMS) #include #if DT_HAS_CHOSEN(zephyr_settings_partition) #define TEST_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) diff --git a/tests/subsys/settings/functional/zms/CMakeLists.txt b/tests/subsys/settings/functional/zms/CMakeLists.txt new file mode 100644 index 00000000000..e29cd6c417e --- /dev/null +++ b/tests/subsys/settings/functional/zms/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(functional_zms) + +# The code is in the library common to several tests. +target_sources(app PRIVATE settings_test_zms.c) + +add_subdirectory(../src func_test_bindir) diff --git a/tests/subsys/settings/functional/zms/prj.conf b/tests/subsys/settings/functional/zms/prj.conf new file mode 100644 index 00000000000..3de961c7c72 --- /dev/null +++ b/tests/subsys/settings/functional/zms/prj.conf @@ -0,0 +1,8 @@ +CONFIG_ZTEST=y +CONFIG_FLASH=y +CONFIG_FLASH_MAP=y +CONFIG_ZMS=y + +CONFIG_SETTINGS=y +CONFIG_SETTINGS_RUNTIME=y +CONFIG_SETTINGS_ZMS=y diff --git a/tests/subsys/settings/functional/zms/settings_test_zms.c b/tests/subsys/settings/functional/zms/settings_test_zms.c new file mode 100644 index 00000000000..f73bbdffa87 --- /dev/null +++ b/tests/subsys/settings/functional/zms/settings_test_zms.c @@ -0,0 +1,25 @@ +/* Copyright (c) 2024 BayLibre SAS + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include + +ZTEST(settings_functional, test_setting_storage_get) +{ + int rc; + void *storage; + uint32_t data = 0xdeadbeefu; + + rc = settings_storage_get(&storage); + zassert_equal(0, rc, "Can't fetch storage reference (err=%d)", rc); + zassert_not_null(storage, "Null reference."); + + rc = zms_write((struct zms_fs *)storage, 512, &data, sizeof(data)); + zassert_true(rc >= 0, "Can't write ZMS entry (err=%d).", rc); +} +ZTEST_SUITE(settings_functional, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/subsys/settings/functional/zms/testcase.yaml b/tests/subsys/settings/functional/zms/testcase.yaml new file mode 100644 index 00000000000..8b7fcdf576f --- /dev/null +++ b/tests/subsys/settings/functional/zms/testcase.yaml @@ -0,0 +1,9 @@ +tests: + settings.functional.zms: + platform_allow: + - qemu_x86 + - native_sim + - native_sim/native/64 + tags: + - settings + - zms