test: dm: add test item for ofnode_get_child_count()

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>
This commit is contained in:
Chunfeng Yun 2020-05-02 11:35:10 +02:00 committed by Marek Vasut
parent 89b84b85e9
commit bf6ad91629
2 changed files with 39 additions and 0 deletions

View File

@ -218,6 +218,24 @@
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";
};

View 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);