[PATCH u-boot-dm + u-boot-spi v2 1/7] dm: core: add test for ofnode_get_addr_size_index()

Marek Behún marek.behun at nic.cz
Tue Feb 9 15:44:46 CET 2021


Add test for ofnode_get_addr_size_index(), which will test OF address
translation.

Signed-off-by: Marek Behún <marek.behun at nic.cz>
Cc: Simon Glass <sjg at chromium.org>
---
 test/dm/ofnode.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index c539134296..0e1eb0d7ea 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -261,3 +261,26 @@ 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_addr_size(struct unit_test_state *uts)
+{
+	fdt_addr_t addr, size;
+	ofnode node;
+
+	node = ofnode_path("/translation-test at 8000/dev at 0,0");
+	ut_assert(ofnode_valid(node));
+
+	addr = ofnode_get_addr_size_index(node, 0, &size);
+	ut_asserteq_64(0x8000, addr);
+	ut_asserteq_64(0x1000, size);
+
+	node = ofnode_path("/translation-test at 8000/dev at 1,100");
+	ut_assert(ofnode_valid(node));
+
+	addr = ofnode_get_addr_size_index(node, 0, &size);
+	ut_asserteq_64(0x9000, addr);
+	ut_asserteq_64(0x1000, size);
+
+	return 0;
+}
+DM_TEST(dm_test_ofnode_get_addr_size, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
-- 
2.26.2



More information about the U-Boot mailing list