[PATCH v2 2/2] test: dm: add test item for ofnode_get_addr() and ofnode_get_size()

chenguanqiao chenguanqiao at kuaishou.com
Fri Apr 2 08:28:21 CEST 2021


Add test item for getting address and size functions

Test the following function:
- ofnode_get_addr()
- ofnode_get_size()

Signed-off-by: Chen Guanqiao <chenguanqiao at kuaishou.com>
---
 test/dm/ofnode.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index c539134296..0d958b4900 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -261,3 +261,27 @@ static int dm_test_ofnode_is_enabled(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_ofnode_is_enabled, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_get_reg(struct unit_test_state *uts)
+{
+	ofnode node;
+	fdt_addr_t addr;
+	fdt_size_t size;
+
+	node = ofnode_path("/translation-test at 8000");
+	ut_assert(ofnode_valid(node));
+	addr = ofnode_get_addr(node);
+	size = ofnode_get_size(node);
+	ut_asserteq(0x8000, addr);
+	ut_asserteq(0x4000, size);
+
+	node = ofnode_path("/translation-test at 8000/dev at 1,100");
+	ut_assert(ofnode_valid(node));
+	addr = ofnode_get_addr(node);
+	size = ofnode_get_size(node);
+	ut_asserteq(0x9000, addr);
+	ut_asserteq(0x1000, size);
+
+	return 0;
+}
+DM_TEST(dm_test_ofnode_get_reg, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
-- 
2.25.1



More information about the U-Boot mailing list