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 <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-12-15 12:20:33 +01:00 committed by David Leach
commit 0c0ad3d332

View file

@ -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.