Skip to content

Commit dffdec1

Browse files
rghaddabkartben
authored andcommitted
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>
1 parent a903b4b commit dffdec1

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

tests/subsys/settings/functional/src/settings_basic_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <zephyr/logging/log.h>
1717
LOG_MODULE_REGISTER(settings_basic_test);
1818

19-
#if defined(CONFIG_SETTINGS_FCB) || defined(CONFIG_SETTINGS_NVS)
19+
#if defined(CONFIG_SETTINGS_FCB) || defined(CONFIG_SETTINGS_NVS) || defined(CONFIG_SETTINGS_ZMS)
2020
#include <zephyr/storage/flash_map.h>
2121
#if DT_HAS_CHOSEN(zephyr_settings_partition)
2222
#define TEST_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(functional_zms)
6+
7+
# The code is in the library common to several tests.
8+
target_sources(app PRIVATE settings_test_zms.c)
9+
10+
add_subdirectory(../src func_test_bindir)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CONFIG_ZTEST=y
2+
CONFIG_FLASH=y
3+
CONFIG_FLASH_MAP=y
4+
CONFIG_ZMS=y
5+
6+
CONFIG_SETTINGS=y
7+
CONFIG_SETTINGS_RUNTIME=y
8+
CONFIG_SETTINGS_ZMS=y
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* Copyright (c) 2024 BayLibre SAS
2+
*
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/kernel.h>
7+
#include <zephyr/ztest.h>
8+
#include <errno.h>
9+
#include <zephyr/settings/settings.h>
10+
#include <zephyr/fs/zms.h>
11+
12+
ZTEST(settings_functional, test_setting_storage_get)
13+
{
14+
int rc;
15+
void *storage;
16+
uint32_t data = 0xdeadbeefu;
17+
18+
rc = settings_storage_get(&storage);
19+
zassert_equal(0, rc, "Can't fetch storage reference (err=%d)", rc);
20+
zassert_not_null(storage, "Null reference.");
21+
22+
rc = zms_write((struct zms_fs *)storage, 512, &data, sizeof(data));
23+
zassert_true(rc >= 0, "Can't write ZMS entry (err=%d).", rc);
24+
}
25+
ZTEST_SUITE(settings_functional, NULL, NULL, NULL, NULL, NULL);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests:
2+
settings.functional.zms:
3+
platform_allow:
4+
- qemu_x86
5+
- native_sim
6+
- native_sim/native/64
7+
tags:
8+
- settings
9+
- zms

0 commit comments

Comments
 (0)