All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm: test: Add a test for dm_test_dev_read_addr_ptr()
@ 2020-05-28 14:20 Simon Glass
  0 siblings, 0 replies; only message in thread
From: Simon Glass @ 2020-05-28 14:20 UTC (permalink / raw)
  To: u-boot

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@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

diff --git a/test/dm/Makefile b/test/dm/Makefile
index 6c18fd04ce..ad2d3547f5 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -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
diff --git a/test/dm/read.c b/test/dm/read.c
new file mode 100644
index 0000000000..38b128b144
--- /dev/null
+++ b/test/dm/read.c
@@ -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);
-- 
2.27.0.rc0.183.gde8f92d652-goog

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-28 14:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 14:20 [PATCH] dm: test: Add a test for dm_test_dev_read_addr_ptr() Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.