[PATCH v2 2/9] test: dm: add test for ofnode_for_each_compatible_node()

2021-10-15 Thread Michael Walle
Check that all matching nodes have the correct compatible and that there
is at least one match.

Signed-off-by: Michael Walle 
---
 test/dm/ofnode.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 49efabe871..cea0746bb3 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);
-- 
2.30.2



Re: [PATCH v2 2/9] test: dm: add test for ofnode_for_each_compatible_node()

2021-10-24 Thread Simon Glass
On Fri, 15 Oct 2021 at 07:15, Michael Walle  wrote:
>
> Check that all matching nodes have the correct compatible and that there
> is at least one match.
>
> Signed-off-by: Michael Walle 
> ---
>  test/dm/ofnode.c | 18 ++
>  1 file changed, 18 insertions(+)
>

Reviewed-by: Simon Glass