From 3732bbfa12a00881dd5f81eb40bba42f2c0779c6 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Tue, 6 Sep 2022 12:18:34 +0200 Subject: [PATCH] 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 --- tests/lib/devicetree/api/src/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/lib/devicetree/api/src/main.c b/tests/lib/devicetree/api/src/main.c index bcf7f55e34..de08c35e2c 100644 --- a/tests/lib/devicetree/api/src/main.c +++ b/tests/lib/devicetree/api/src/main.c @@ -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)