diff mbox series

[v2,02/10] test: dm: add test item for ofnode_get_child_count()

Message ID 1584780715-29632-3-git-send-email-chunfeng.yun@mediatek.com
State New
Headers show
Series Add support for MediaTek xHCI host controller | expand

Commit Message

Chunfeng Yun (云春峰) March 21, 2020, 8:51 a.m. UTC
Add a test item for ofnode_get_child_count()

Signed-off-by: Chunfeng Yun <chunfeng.yun at mediatek.com>
---
v2:
    a new patch to test ofnode_get_child_count() suggested by Simon
---
 test/dm/ofnode.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Simon Glass March 23, 2020, 3:16 p.m. UTC | #1
On Sat, 21 Mar 2020 at 02:52, Chunfeng Yun <chunfeng.yun at mediatek.com> wrote:
>
> Add a test item for ofnode_get_child_count()
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun at mediatek.com>
> ---
> v2:
>     a new patch to test ofnode_get_child_count() suggested by Simon
> ---
>  test/dm/ofnode.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)

Reviewed-by: Simon Glass <sjg at chromium.org>
diff mbox series

Patch

diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 1c49eaf38b..07d5c7d7a6 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -113,3 +113,24 @@  static int dm_test_ofnode_read_chosen(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_ofnode_read_chosen, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_get_child_count(struct unit_test_state *uts)
+{
+	ofnode node, child_node;
+	u32 val;
+
+	node = ofnode_path("/i-test");
+	ut_assert(ofnode_valid(node));
+
+	val = ofnode_get_child_count(node);
+	ut_asserteq(3, val);
+
+	child_node = ofnode_first_subnode(node);
+	ut_assert(ofnode_valid(child_node));
+	val = ofnode_get_child_count(child_node);
+	ut_asserteq(0, val);
+
+	return 0;
+}
+DM_TEST(dm_test_ofnode_get_child_count,
+	DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);