diff mbox series

[17/20] test: dm: Add a test case for simple-bus <ranges>

Message ID 20210302153451.19440-18-bmeng.cn@gmail.com
State Superseded
Delegated to: Priyanka Jain
Headers show
Series ppc: qemu: Add eTSEC support | expand

Commit Message

Bin Meng March 2, 2021, 3:34 p.m. UTC
This adds a test case to verify reading <ranges> of a simple-bus is
working as expected.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 test/dm/Makefile     |  1 +
 test/dm/simple-bus.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 test/dm/simple-bus.c

Comments

Simon Glass March 5, 2021, 4:08 a.m. UTC | #1
On Tue, 2 Mar 2021 at 10:36, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> This adds a test case to verify reading <ranges> of a simple-bus is
> working as expected.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  test/dm/Makefile     |  1 +
>  test/dm/simple-bus.c | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+)
>  create mode 100644 test/dm/simple-bus.c

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/test/dm/Makefile b/test/dm/Makefile
index 6275ec56ea..1e92625105 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -89,6 +89,7 @@  obj-$(CONFIG_DM_MDIO) += mdio.o
 obj-$(CONFIG_DM_MDIO_MUX) += mdio_mux.o
 obj-$(CONFIG_DM_RNG) += rng.o
 obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o
+obj-$(CONFIG_SIMPLE_BUS) += simple-bus.o
 obj-$(CONFIG_SIMPLE_PM_BUS) += simple-pm-bus.o
 obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o
 obj-$(CONFIG_SCMI_FIRMWARE) += scmi.o
diff --git a/test/dm/simple-bus.c b/test/dm/simple-bus.c
new file mode 100644
index 0000000000..3530b47fac
--- /dev/null
+++ b/test/dm/simple-bus.c
@@ -0,0 +1,33 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021, Bin Meng <bmeng.cn@gmail.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <dm/simple_bus.h>
+#include <dm/uclass-internal.h>
+#include <test/ut.h>
+
+static int dm_test_simple_bus(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	struct simple_bus_plat *plat;
+
+	/* locate the dummy device @ translation-test node */
+	ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev));
+	ut_asserteq_str("dev@0,0", dev->name);
+
+	/* locate the parent node which is a simple-bus */
+	ut_assertnonnull(dev = dev_get_parent(dev));
+	ut_asserteq_str("translation-test@8000", dev->name);
+
+	ut_assertnonnull(plat = dev_get_uclass_plat(dev));
+	ut_asserteq(0, plat->base);
+	ut_asserteq(0x8000, plat->target);
+	ut_asserteq(0x1000, plat->size);
+
+	return 0;
+}
+DM_TEST(dm_test_simple_bus, UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);