tests: settings: add functional test for ZMS

Add the functional test for the new backend of ZMS

Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
This commit is contained in:
Riadh Ghaddab 2025-03-24 14:12:44 +01:00 committed by Benjamin Cabé
parent a903b4b0d1
commit dffdec18c2
5 changed files with 53 additions and 1 deletions

View File

@ -16,7 +16,7 @@
#include <zephyr/logging/log.h>
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 <zephyr/storage/flash_map.h>
#if DT_HAS_CHOSEN(zephyr_settings_partition)
#define TEST_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition))

View File

@ -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)

View File

@ -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

View File

@ -0,0 +1,25 @@
/* Copyright (c) 2024 BayLibre SAS
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
#include <errno.h>
#include <zephyr/settings/settings.h>
#include <zephyr/fs/zms.h>
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);

View File

@ -0,0 +1,9 @@
tests:
settings.functional.zms:
platform_allow:
- qemu_x86
- native_sim
- native_sim/native/64
tags:
- settings
- zms