tests: devicetree: add tests for DT_CHILD/DT_INST_CHILD

Add some coverage for the DT_CHILD/DT_INST_CHILD macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-09-06 12:18:34 +02:00 committed by Marti Bolivar
parent 7a54318d35
commit 3732bbfa12

View file

@ -1655,6 +1655,22 @@ ZTEST(devicetree_api, test_parent)
TEST_SPI_BUS_0), "");
}
#undef DT_DRV_COMPAT
#define DT_DRV_COMPAT vnd_child_bindings
ZTEST(devicetree_api, test_children)
{
zassert_equal(DT_PROP(DT_CHILD(DT_NODELABEL(test_children), child_a),
val), 0, "");
zassert_equal(DT_PROP(DT_CHILD(DT_NODELABEL(test_children), child_b),
val), 1, "");
zassert_equal(DT_PROP(DT_CHILD(DT_NODELABEL(test_children), child_c),
val), 2, "");
zassert_equal(DT_PROP(DT_INST_CHILD(0, child_a), val), 0, "");
zassert_equal(DT_PROP(DT_INST_CHILD(0, child_b), val), 1, "");
zassert_equal(DT_PROP(DT_INST_CHILD(0, child_c), val), 2, "");
}
#undef DT_DRV_COMPAT
#define DT_DRV_COMPAT vnd_child_bindings
ZTEST(devicetree_api, test_child_nodes_list)