File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
tests/subsys/storage/flash_map/src Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -419,6 +419,16 @@ uint8_t flash_area_erased_val(const struct flash_area *fa);
419419 * @return Pointer to flash_area type object representing partition
420420 */
421421#define FIXED_PARTITION (label ) FIXED_PARTITION_1(DT_NODELABEL(label))
422+
423+ /**
424+ * Get pointer to flash_area object by partition node in DTS
425+ *
426+ * @param node DTS node of a partition
427+ *
428+ * @return Pointer to flash_area type object representing partition
429+ */
430+ #define FIXED_PARTITION_BY_NODE (node ) FIXED_PARTITION_1(node)
431+
422432#define FIXED_PARTITION_1 (node ) FIXED_PARTITION_0(DT_DEP_ORD(node))
423433#define FIXED_PARTITION_0 (ord ) \
424434 ((const struct flash_area *)&DT_CAT(global_fixed_partition_ORD_, ord))
Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ ZTEST(flash_map, test_flash_area_disabled_device)
3030 zassert_equal (rc , - ENOENT , "Open did not fail" );
3131 rc = flash_area_open (FIXED_PARTITION_ID (disabled_b ), & fa );
3232 zassert_equal (rc , - ENOENT , "Open did not fail" );
33+
34+ /* Note lack of tests for FIXED_PARTITION(...) instantiation,
35+ * because this macro will fail, at compile time, if node does not
36+ * exist or is disabled.
37+ */
3338}
3439
3540ZTEST (flash_map , test_flash_area_device_is_ready )
@@ -143,6 +148,10 @@ ZTEST(flash_map, test_fixed_partition_node_macros)
143148 DT_REG_SIZE (SLOT1_PARTITION_NODE ));
144149 zassert_equal (FIXED_PARTITION_NODE_DEVICE (SLOT1_PARTITION_NODE ),
145150 DEVICE_DT_GET (DT_MTD_FROM_FIXED_PARTITION (SLOT1_PARTITION_NODE )));
151+
152+ /* Taking by node and taking by label should give same device */
153+ zassert_equal (FIXED_PARTITION_BY_NODE (DT_NODELABEL (SLOT1_PARTITION )),
154+ FIXED_PARTITION (SLOT1_PARTITION ));
146155}
147156
148157ZTEST (flash_map , test_flash_area_erase_and_flatten )
You can’t perform that action at this time.
0 commit comments