test: dm: add test item for ofnode_get_child_count()
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Sat, 2 May 2020 09:35:10 +0000 (11:35 +0200)
committerMarek Vasut <marek.vasut+renesas@gmail.com>
Sat, 2 May 2020 10:32:28 +0000 (12:32 +0200)
Add a test item for ofnode_get_child_count()

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Weijie Gao <weijie.gao@mediatek.com>
arch/sandbox/dts/test.dts
test/dm/ofnode.c

index 4bccfbe6e1b1d3fe2ac67df60fd1d167b341f795..9c00e945010289f398a77a945173b928a1f55c5c 100644 (file)
                compatible = "denx,u-boot-fdt-test1";
        };
 
+       i-test {
+               compatible = "mediatek,u-boot-fdt-test";
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               subnode@0 {
+                       reg = <0>;
+               };
+
+               subnode@1 {
+                       reg = <1>;
+               };
+
+               subnode@2 {
+                       reg = <2>;
+               };
+       };
+
        devres-test {
                compatible = "denx,u-boot-devres-test";
        };
index 1c49eaf38bff96f68e55e6ddccc55dd0bad1d725..07d5c7d7a6567b6541193170ec8c2c102c3aaada 100644 (file)
@@ -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);