[U-Boot] [PATCH 7/8] test: dm: core: Add a test case for driver marked with DM_FLAG_PRE_RELOC flag

Bin Meng bmeng.cn at gmail.com
Sat Oct 6 16:30:23 UTC 2018


Now that we fixed the pre-relocation driver binding for driver marked
with DM_FLAG_PRE_RELOC flag, add a test case to cover that scenario.

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

 arch/sandbox/dts/test.dts |  4 ++++
 test/dm/bus.c             |  2 +-
 test/dm/test-fdt.c        | 29 ++++++++++++++++++++++++++---
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 491f889..f12410f 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -146,6 +146,10 @@
 		compatible = "denx,u-boot-fdt-test";
 	};
 
+	h-test {
+		compatible = "denx,u-boot-fdt-test1";
+	};
+
 	clocks {
 		clk_fixed: clk-fixed {
 			compatible = "fixed-clock";
diff --git a/test/dm/bus.c b/test/dm/bus.c
index e9a4028..c41bcf7 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -104,7 +104,7 @@ UCLASS_DRIVER(testbus) = {
 /* Test that we can probe for children */
 static int dm_test_bus_children(struct unit_test_state *uts)
 {
-	int num_devices = 7;
+	int num_devices = 8;
 	struct udevice *bus;
 	struct uclass *uc;
 
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 79b1f1d..3da384f 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -84,6 +84,25 @@ U_BOOT_DRIVER(testfdt_drv) = {
 	.platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
 };
 
+static const struct udevice_id testfdt1_ids[] = {
+	{
+		.compatible = "denx,u-boot-fdt-test1",
+		.data = DM_TEST_TYPE_FIRST },
+	{ }
+};
+
+U_BOOT_DRIVER(testfdt1_drv) = {
+	.name	= "testfdt1_drv",
+	.of_match	= testfdt1_ids,
+	.id	= UCLASS_TEST_FDT,
+	.ofdata_to_platdata = testfdt_ofdata_to_platdata,
+	.probe	= testfdt_drv_probe,
+	.ops	= &test_ops,
+	.priv_auto_alloc_size = sizeof(struct dm_test_priv),
+	.platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
+	.flags = DM_FLAG_PRE_RELOC,
+};
+
 /* From here is the testfdt uclass code */
 int testfdt_ping(struct udevice *dev, int pingval, int *pingret)
 {
@@ -168,7 +187,7 @@ int dm_check_devices(struct unit_test_state *uts, int num_devices)
 /* Test that FDT-based binding works correctly */
 static int dm_test_fdt(struct unit_test_state *uts)
 {
-	const int num_devices = 7;
+	const int num_devices = 8;
 	struct udevice *dev;
 	struct uclass *uc;
 	int ret;
@@ -208,8 +227,12 @@ static int dm_test_fdt_pre_reloc(struct unit_test_state *uts)
 	ret = uclass_get(UCLASS_TEST_FDT, &uc);
 	ut_assert(!ret);
 
-	/* These is only one pre-reloc device */
-	ut_asserteq(1, list_count_items(&uc->dev_head));
+	/*
+	 * These are 2 pre-reloc devices:
+	 * one with "u-boot,dm-pre-reloc" property (a-test node), and the other
+	 * one whose driver marked with DM_FLAG_PRE_RELOC flag (h-test node).
+	 */
+	ut_asserteq(2, list_count_items(&uc->dev_head));
 
 	return 0;
 }
-- 
2.7.4



More information about the U-Boot mailing list