[PATCH 13/71] dm: test: Correct ordering of DM setup

Simon Glass sjg at chromium.org
Wed Dec 7 09:50:39 CET 2022


We must call dm_scan_other() after devices from the device tree have been
created, since that function behaves differently if there is no bootstd
device.

Adjust the logic to achieve this.

Also fix the bootflow_system() test which was relying on this broken
behaviour.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 test/boot/bootflow.c | 11 +++++++----
 test/test-main.c     | 11 ++++++++---
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index e1e07082105..aac14d30673 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -15,6 +15,7 @@
 #ifdef CONFIG_SANDBOX
 #include <asm/test.h>
 #endif
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <test/suites.h>
 #include <test/ut.h>
@@ -327,12 +328,14 @@ BOOTSTD_TEST(bootflow_iter, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
 /* Check using the system bootdev */
 static int bootflow_system(struct unit_test_state *uts)
 {
-	struct udevice *dev;
+	struct udevice *bootstd, *dev;
 
 	if (!IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR))
 		return -EAGAIN;
-	ut_assertok(uclass_get_device_by_name(UCLASS_BOOTMETH, "efi_mgr",
-					      &dev));
+	ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
+	ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_efi_mgr),
+				"efi_mgr", 0, ofnode_null(), &dev));
+	ut_assertok(device_probe(dev));
 	sandbox_set_fake_efi_mgr_dev(dev, true);
 
 	/* We should get a single 'bootmgr' method right at the end */
@@ -342,7 +345,7 @@ static int bootflow_system(struct unit_test_state *uts)
 	ut_assert_skip_to_line(
 		"  0  efi_mgr      ready   (none)       0  <NULL>                    <NULL>");
 	ut_assert_skip_to_line("No more bootdevs");
-	ut_assert_skip_to_line("(5 bootflows, 5 valid)");
+	ut_assert_skip_to_line("(2 bootflows, 2 valid)");
 	ut_assert_console_end();
 
 	return 0;
diff --git a/test/test-main.c b/test/test-main.c
index 9ab090b7b33..72aa3a0aa8f 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -296,10 +296,8 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test)
 
 	uts->start = mallinfo();
 
-	if (test->flags & UT_TESTF_SCAN_PDATA) {
+	if (test->flags & UT_TESTF_SCAN_PDATA)
 		ut_assertok(dm_scan_plat(false));
-		ut_assertok(dm_scan_other(false));
-	}
 
 	if (test->flags & UT_TESTF_PROBE_TEST)
 		ut_assertok(do_autoprobe(uts));
@@ -308,6 +306,13 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test)
 	    (test->flags & UT_TESTF_SCAN_FDT))
 		ut_assertok(dm_extended_scan(false));
 
+	/*
+	 * Do this after FDT scan since dm_scan_other() in bootstd-uclass.c
+	 * checks for the existence of bootstd
+	 */
+	if (test->flags & UT_TESTF_SCAN_PDATA)
+		ut_assertok(dm_scan_other(false));
+
 	if (IS_ENABLED(CONFIG_SANDBOX) && (test->flags & UT_TESTF_OTHER_FDT)) {
 		/* make sure the other FDT is available */
 		ut_assertok(test_load_other_fdt(uts));
-- 
2.39.0.rc0.267.gcb52ba06e7-goog



More information about the U-Boot-Custodians mailing list