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);
419
419
* @return Pointer to flash_area type object representing partition
420
420
*/
421
421
#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
+
422
432
#define FIXED_PARTITION_1 (node ) FIXED_PARTITION_0(DT_DEP_ORD(node))
423
433
#define FIXED_PARTITION_0 (ord ) \
424
434
((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)
30
30
zassert_equal (rc , - ENOENT , "Open did not fail" );
31
31
rc = flash_area_open (FIXED_PARTITION_ID (disabled_b ), & fa );
32
32
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
+ */
33
38
}
34
39
35
40
ZTEST (flash_map , test_flash_area_device_is_ready )
@@ -143,6 +148,10 @@ ZTEST(flash_map, test_fixed_partition_node_macros)
143
148
DT_REG_SIZE (SLOT1_PARTITION_NODE ));
144
149
zassert_equal (FIXED_PARTITION_NODE_DEVICE (SLOT1_PARTITION_NODE ),
145
150
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 ));
146
155
}
147
156
148
157
ZTEST (flash_map , test_flash_area_erase_and_flatten )
You can’t perform that action at this time.
0 commit comments