@@ -184,6 +184,44 @@ ZTEST(flash_map, test_fixed_partition_node_macros)
184184#endif
185185}
186186
187+ ZTEST (flash_map , test_fixed_subpartition_node_macros )
188+ {
189+ /* DTS node macros, for accessing fixed partitions, are only available
190+ * for DTS based partitions; custom flash map may define partition outside
191+ * of DTS definition, making the NODE macros fail to evaluate.
192+ */
193+ #if defined(CONFIG_TEST_FLASH_MAP_NODE_MACROS )
194+ /* Test that both partitions and subpartitions exist */
195+ zassert_true (FIXED_PARTITION_EXISTS (disabled_a ));
196+ zassert_true (FIXED_PARTITION_EXISTS (disabled_a_a ));
197+ zassert_true (FIXED_PARTITION_EXISTS (disabled_a_b ));
198+
199+ /* Test that the subpartition offset is relative to the parent */
200+ zassert_equal (FIXED_PARTITION_OFFSET (disabled_b ),
201+ FIXED_PARTITION_OFFSET (disabled_b_a ));
202+ zassert_equal (FIXED_PARTITION_OFFSET (disabled_b ) + 0x100 ,
203+ FIXED_PARTITION_OFFSET (disabled_b_b ));
204+ zassert_equal (FIXED_PARTITION_NODE_OFFSET (DT_NODELABEL (disabled_b )),
205+ FIXED_PARTITION_NODE_OFFSET (DT_NODELABEL (disabled_b_a )));
206+ zassert_equal (
207+ FIXED_PARTITION_NODE_OFFSET (DT_NODELABEL (disabled_b )) + 0x100 ,
208+ FIXED_PARTITION_NODE_OFFSET (DT_NODELABEL (disabled_b_b )));
209+
210+ /* Test that the subpartition address is relative to the parent */
211+ zassert_equal (FIXED_PARTITION_ADDRESS (disabled_b ),
212+ FIXED_PARTITION_ADDRESS (disabled_b_a ));
213+ zassert_equal (FIXED_PARTITION_ADDRESS (disabled_b ) + 0x100 ,
214+ FIXED_PARTITION_ADDRESS (disabled_b_b ));
215+ zassert_equal (FIXED_PARTITION_NODE_ADDRESS (DT_NODELABEL (disabled_b )),
216+ FIXED_PARTITION_NODE_ADDRESS (DT_NODELABEL (disabled_b_a )));
217+ zassert_equal (
218+ FIXED_PARTITION_NODE_ADDRESS (DT_NODELABEL (disabled_b )) + 0x100 ,
219+ FIXED_PARTITION_NODE_ADDRESS (DT_NODELABEL (disabled_b_b )));
220+ #else
221+ ztest_test_skip ();
222+ #endif
223+ }
224+
187225ZTEST (flash_map , test_flash_area_erase_and_flatten )
188226{
189227 int i ;
0 commit comments