@@ -4,6 +4,7 @@
obj-$(CONFIG_UT_DM) += bus.o
obj-$(CONFIG_UT_DM) += nop.o
+obj-$(CONFIG_UT_DM) += read.o
obj-$(CONFIG_UT_DM) += test-driver.o
obj-$(CONFIG_UT_DM) += test-fdt.o
obj-$(CONFIG_UT_DM) += test-main.o
new file mode 100644
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Livetree API
+ *
+ * Copyright 2020 Google LLC
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <mapmem.h>
+#include <syscon.h>
+#include <asm/test.h>
+#include <dm/test.h>
+#include <test/ut.h>
+
+/* Test that dev_read_addr_ptr() works in flattree and livetree */
+static int dm_test_dev_read_addr_ptr(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(dev_read_addr_ptr(gpio));
+
+ ut_assertok(syscon_get_by_driver_data(SYSCON0, &dev));
+ ptr = dev_read_addr_ptr(dev);
+ ut_asserteq(0x10, map_to_sysmem(ptr));
+
+ /* See dm_test_fdt_translation() which has more tests */
+
+ return 0;
+}
+DM_TEST(dm_test_dev_read_addr_ptr, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
Check the behaviour of this function. Hopefully this is start of a complete test suite for the dev_read...() functions. Signed-off-by: Simon Glass <sjg at chromium.org> --- Due to the nature of the test harness, this tests all cases: 1. CONFIG_OF_LIVE and livetree in use (normal sandbox test, gd->of_root is set) 2. CONFIG_OF_LIVE but livetree not yet in use (sandbox with gd->of_root = NULL) 3. !CONFIG_OF_LIVE (in sandbox_flattree) The third one is tested by 'make qcheck' which calls test/run test/dm/Makefile | 1 + test/dm/read.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/dm/read.c