From 0c0ad3d332d1d7c6c277fdf444ae03de73f6662f Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 15 Dec 2021 12:20:33 +0100 Subject: [PATCH] tests: lib: devicetree: api: test DT_INST_PARENT Check that DT_INST_PARENT behavior is correct. Re-uses existing overlay definitions (child of TEST_SPI_BUS_0) to test the behavior. Signed-off-by: Gerard Marull-Paretas --- tests/lib/devicetree/api/src/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/lib/devicetree/api/src/main.c b/tests/lib/devicetree/api/src/main.c index 7cab6115dcf..b1f4086f734 100644 --- a/tests/lib/devicetree/api/src/main.c +++ b/tests/lib/devicetree/api/src/main.c @@ -1639,11 +1639,20 @@ static void test_clocks(void) 25000000, ""); } +#undef DT_DRV_COMPAT +#define DT_DRV_COMPAT vnd_spi_device static void test_parent(void) { /* The label of a child node's parent is the label of the parent. */ zassert_true(!strcmp(DT_LABEL(DT_PARENT(TEST_SPI_DEV_0)), DT_LABEL(TEST_SPI_BUS_0)), ""); + + /* + * The parent's label for the first instance of vnd,spi-device, + * child of TEST_SPI, is the same as TEST_SPI. + */ + zassert_true(!strcmp(DT_LABEL(DT_INST_PARENT(0)), + DT_LABEL(TEST_SPI)), ""); /* * We should be able to use DT_PARENT() even with nodes, like /test, * that have no matching compatible.