Skip to content

Commit 53c79c6

Browse files
de-nordickartben
authored andcommitted
tests/flash_map: Allow custom maps to opt out from some scenarios
The commit modifies the Flash Map test, providing Kconfigs that allow to opt out from testing disabled partitions and testing DTS node access. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 13d8ca5 commit 53c79c6

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
mainmenu "Flash Map test configuration"
8+
9+
config TEST_FLASH_MAP_DISABLED_PARTITIONS
10+
bool "Test support for disabled partitions"
11+
default y if !FLASH_MAP_CUSTOM
12+
help
13+
Test flash_area_open for returning -ENOENT for disabled partitions.
14+
Note that custom flash maps may not support disabled partitions
15+
and therefore not even generated id for them. In such case it would
16+
not be possible to provide disabled partition id to flash_area_open,
17+
making this test impossible to run.
18+
19+
config TEST_FLASH_MAP_NODE_MACROS
20+
bool "Test DTS macros for accessing partition info via DTS node"
21+
default y if !FLASH_MAP_CUSTOM
22+
help
23+
Custom flash map may be defined outside of DTS definition, therefore
24+
not have a DTS nodes for partitions.
25+
26+
menu "Zephyr"
27+
source "Kconfig.zephyr"
28+
endmenu

tests/subsys/storage/flash_map/src/main.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ struct flash_sector fs_sectors[2048];
2525

2626
ZTEST(flash_map, test_flash_area_disabled_device)
2727
{
28+
/* The test checks if Flash Map will report partition
29+
* non-existend if it is disabled, but it also assumes that
30+
* disabled parition will have an ID generated.
31+
* Custom partition maps may not be generating entries for
32+
* disabled partitions nor identifiers, which makes the
33+
* test fail with custom partition manager, for no real reason.
34+
*/
35+
#if defined(CONFIG_TEST_FLASH_MAP_DISABLED_PARTITIONS)
2836
const struct flash_area *fa;
2937
int rc;
3038

@@ -38,6 +46,9 @@ ZTEST(flash_map, test_flash_area_disabled_device)
3846
* because this macro will fail, at compile time, if node does not
3947
* exist or is disabled.
4048
*/
49+
#else
50+
ztest_test_skip();
51+
#endif
4152
}
4253

4354
ZTEST(flash_map, test_flash_area_device_is_ready)
@@ -144,6 +155,11 @@ ZTEST(flash_map, test_flash_area_erased_val)
144155

145156
ZTEST(flash_map, test_fixed_partition_node_macros)
146157
{
158+
/* DTS node macros, for accessing fixed partitions, are only available
159+
* for DTS based partitions; custom flash map may define partition outside
160+
* of DTS definition, making the NODE macros fail to evaluate.
161+
*/
162+
#if defined(CONFIG_TEST_FLASH_MAP_NODE_MACROS)
147163
/* Test against changes in API */
148164
zassert_equal(FIXED_PARTITION_NODE_OFFSET(SLOT1_PARTITION_NODE),
149165
DT_REG_ADDR(SLOT1_PARTITION_NODE));
@@ -155,6 +171,9 @@ ZTEST(flash_map, test_fixed_partition_node_macros)
155171
/* Taking by node and taking by label should give same device */
156172
zassert_equal(FIXED_PARTITION_BY_NODE(DT_NODELABEL(SLOT1_PARTITION)),
157173
FIXED_PARTITION(SLOT1_PARTITION));
174+
#else
175+
ztest_test_skip();
176+
#endif
158177
}
159178

160179
ZTEST(flash_map, test_flash_area_erase_and_flatten)

0 commit comments

Comments
 (0)