Skip to content

Commit 99279c0

Browse files
de-nordiccarlescufi
authored andcommitted
tests/fs/nvs: Fix test to pick flash controller from area
The test has been accessing flash area parameters by flash area label, but flash controller by chosen 'zephyr,flash-controller', instead of picking device that the area is really on. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 8027072 commit 99279c0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/subsys/fs/nvs/src/main.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@
2626
#include <zephyr/fs/nvs.h>
2727
#include "nvs_priv.h"
2828

29-
#define TEST_FLASH_AREA_STORAGE_OFFSET FLASH_AREA_OFFSET(storage)
29+
#define TEST_NVS_FLASH_AREA storage
30+
#define TEST_NVS_FLASH_OFFSET FLASH_AREA_OFFSET(TEST_NVS_FLASH_AREA)
31+
#define TEST_NVS_FLASH_DEV_NODE \
32+
DT_MTD_FROM_FIXED_PARTITION(DT_NODE_BY_FIXED_PARTITION_LABEL(TEST_NVS_FLASH_AREA))
3033
#define TEST_DATA_ID 1
3134
#define TEST_SECTOR_COUNT 5U
3235

33-
static const struct device *flash_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller));
36+
static const struct device *flash_dev = DEVICE_DT_GET(TEST_NVS_FLASH_DEV_NODE);
3437
static struct nvs_fs fs;
3538
struct stats_hdr *sim_stats;
3639
struct stats_hdr *sim_thresholds;
@@ -65,10 +68,10 @@ void test_nvs_mount(void)
6568
const struct flash_area *fa;
6669
struct flash_pages_info info;
6770

68-
err = flash_area_open(FLASH_AREA_ID(storage), &fa);
71+
err = flash_area_open(FLASH_AREA_ID(TEST_NVS_FLASH_AREA), &fa);
6972
zassert_true(err == 0, "flash_area_open() fail: %d", err);
7073

71-
fs.offset = TEST_FLASH_AREA_STORAGE_OFFSET;
74+
fs.offset = TEST_NVS_FLASH_OFFSET;
7275
err = flash_get_page_info_by_offs(flash_area_get_device(fa), fs.offset,
7376
&info);
7477
zassert_true(err == 0, "Unable to get page info: %d", err);

0 commit comments

Comments
 (0)