]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: Add test case for devfdt_get_addr_ptr
authorOvidiu Panait <ovidiu.panait@windriver.com>
Mon, 3 Aug 2020 19:17:36 +0000 (22:17 +0300)
committerSimon Glass <sjg@chromium.org>
Sat, 22 Aug 2020 14:51:43 +0000 (08:51 -0600)
Add flat tree test case to cover devfdt_get_addr_ptr function.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/dm/test-fdt.c

index ac8ce99f5120909b162c445436db412b6b2fd131..04802deb7fcfaafb7fad3359042cfd40a2e8aa23 100644 (file)
@@ -619,6 +619,24 @@ static int dm_test_fdt_translation(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_fdt_translation, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
+static int dm_test_fdt_get_addr_ptr_flat(struct unit_test_state *uts)
+{
+       struct udevice *gpio, *dev;
+       void *ptr;
+
+       /* Test for missing reg property */
+       ut_assertok(uclass_first_device_err(UCLASS_GPIO, &gpio));
+       ut_assertnull(devfdt_get_addr_ptr(gpio));
+
+       ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev));
+       ptr = devfdt_get_addr_ptr(dev);
+       ut_asserteq_ptr((void *)0x8000, ptr);
+
+       return 0;
+}
+DM_TEST(dm_test_fdt_get_addr_ptr_flat,
+       UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
+
 static int dm_test_fdt_remap_addr_flat(struct unit_test_state *uts)
 {
        struct udevice *dev;