]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: add test for ofnode_for_each_compatible_node()
authorMichael Walle <michael@walle.cc>
Fri, 15 Oct 2021 13:15:18 +0000 (15:15 +0200)
committerPriyanka Jain <priyanka.jain@nxp.com>
Tue, 9 Nov 2021 11:48:23 +0000 (17:18 +0530)
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>
test/dm/ofnode.c

index 49efabe871c03daa8760bc1965be3db441236776..cea0746bb3b152ae0e842b7eb629cc5bffd94666 100644 (file)
@@ -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);