]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: add test item for ofnode_get_addr() and ofnode_get_size()
authorChen Guanqiao <chenguanqiao@kuaishou.com>
Mon, 12 Apr 2021 06:51:12 +0000 (14:51 +0800)
committerSimon Glass <sjg@chromium.org>
Thu, 29 Apr 2021 10:23:39 +0000 (03:23 -0700)
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@kuaishou.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/dm/ofnode.c

index c53913429624a4af7ef92ed177bfcf2af5715d0e..e0b525eeb185eb819948e2f2ac1ff9529c9a79c4 100644 (file)
@@ -261,3 +261,34 @@ 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@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@8000/dev@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);
+
+       node = ofnode_path("/emul-mux-controller");
+       ut_assert(ofnode_valid(node));
+       addr = ofnode_get_addr(node);
+       size = ofnode_get_size(node);
+       ut_asserteq(FDT_ADDR_T_NONE, addr);
+       ut_asserteq(FDT_SIZE_T_NONE, size);
+
+       return 0;
+}
+DM_TEST(dm_test_ofnode_get_reg, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);