diff options
author | Michael Walle <michael@walle.cc> | 2021-10-15 15:15:18 +0200 |
---|---|---|
committer | Priyanka Jain <priyanka.jain@nxp.com> | 2021-11-09 17:18:23 +0530 |
commit | bce039acf2661b1484aeee3704100b645a3d2198 (patch) | |
tree | 3c206811678058b34d6b11315f48c5fc597af644 /test/dm | |
parent | b8ec9458a35167ab689b3ebfba169f520e1064c4 (diff) | |
download | u-boot-bce039acf2661b1484aeee3704100b645a3d2198.tar.gz |
test: dm: add test for ofnode_for_each_compatible_node()
Check that all matching nodes have the correct compatible and that there
is at least one match.
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
Diffstat (limited to 'test/dm')
-rw-r--r-- | test/dm/ofnode.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 49efabe871c..cea0746bb3b 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -333,3 +333,21 @@ static int dm_test_ofnode_conf(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ofnode_conf, 0); + +static int dm_test_ofnode_for_each_compatible_node(struct unit_test_state *uts) +{ + const char compatible[] = "denx,u-boot-fdt-test"; + bool found = false; + ofnode node; + + ofnode_for_each_compatible_node(node, compatible) { + ut_assert(ofnode_device_is_compatible(node, compatible)); + found = true; + } + + /* There should be at least one matching node */ + ut_assert(found); + + return 0; +} +DM_TEST(dm_test_ofnode_for_each_compatible_node, UT_TESTF_SCAN_FDT); |