Skip to contentSkip to conversation

test: boot: Set DM|SCAN_FDT flags for bootmeth_{cros,android}

PATCH In review Mattijs Korpershoek 2 participants 2 messages Nov 22, 2024 – Nov 23, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 test: boot: Set DM|SCAN_FDT flags for bootmeth_{cros,android}

We make fewer calls to dm_test_restore() since
commit fbdac8155c89 ("test: Expand implementation of ut_list_has_dm_tests()")

Because of this some valid test combinations are now broken:

$ ./test/py/test.py --bd sandbox --build -k test_ut
$ ./test/py/test.py --bd sandbox --build -k "bootflow_android or bootflow_cros"

Shows:

Expected ' 2 cros ready mmc 4 mmc5.bootdev.part_4 ',
got ' 2 cros ready mmc 2 mmc5.bootdev.part_2 '

Here prep_mmc_bootdev() is called twice and it will bind bootmeth_cros twice.

Since bootmeth_cros is bound twice, 'bootflow scan' will find 2x the expected bootflows.

Before
commit fbdac8155c89 ("test: Expand implementation of ut_list_has_dm_tests()") this did not happen because a cleanup was called each time.

Add UTF_DM and UTF_SCAN_FDT flags to both tests to make sure that the bootmeths are unbound after the test finishes.

Fixes fbdac8155c89 ("test: Expand implementation of ut_list_has_dm_tests()")

---
Initially, this was found when merging some Android bootflow patches from [1].

However, this can be reproduced on 'next' as well.

Here is the test output that's broken (we have 4 cros bootmethods instead of 2)

=> ut bootstd bootflow_cros
Test: bootflow_cros: bootflow.c
Showing all bootflows

Seq  Method       State   Uclass    Part  Name                      Filename
---  -----------  ------  --------  ----  ------------------------ ----------------
0  extlinux     ready   mmc          1  mmc1.bootdev.part_1 /extlinux/extlinux.conf
1  cros         ready   mmc          2  mmc5.bootdev.part_2
2  cros         ready   mmc          2  mmc5.bootdev.part_2
3  cros         ready   mmc          4  mmc5.bootdev.part_4
4  cros         ready   mmc          4  mmc5.bootdev.part_4

--- ----------- ------ -------- ---- ------------------------ ---------------- (5 bootflows, 5 valid)
test/boot/bootflow.c:1192, bootflow_cros(): console:
Expected ' 2 cros ready mmc 4 mmc5.bootdev.part_4 ',
got ' 2 cros ready mmc 2 mmc5.bootdev.part_2 '
Test bootflow_cros failed 1 times

[1] https://lore.kernel.org/r/all/[email protected]/
---
Changes in v2:
- Use UTF_DM | UTF_SCAN_FDT instead (Simon)
- Link to v1: https://lore.kernel.org/r/20241121-bootstd-test-fix-multiple-bind-v1-1-f6c06b9581b1@baylibre.com

---
 test/boot/bootflow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
test/boot/bootflow.c +2 -2
index 9397328609d0..da713d8ed72b 100644
@@ -1197,7 +1197,7 @@ static int bootflow_cros(struct unit_test_state *uts)
 
 	return 0;
 }
-BOOTSTD_TEST(bootflow_cros, UTF_CONSOLE);
+BOOTSTD_TEST(bootflow_cros, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT);
 
 /* Test Android bootmeth  */
 static int bootflow_android(struct unit_test_state *uts)
@@ -1220,7 +1220,7 @@ static int bootflow_android(struct unit_test_state *uts)
 
 	return 0;
 }
-BOOTSTD_TEST(bootflow_android, UTF_CONSOLE);
+BOOTSTD_TEST(bootflow_android, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT);
 
 /* Test EFI bootmeth */
 static int bootflow_efi(struct unit_test_state *uts)

---
base-commit: dc1859f8d2ac3faaa5e2e1d465ec4bd8980520a5
change-id: 20241121-bootstd-test-fix-multiple-bind-159bd2523414

Best regards,

Signature · 1 line
Mattijs Korpershoek <[email protected]>
#1 lore raw
Quoted 22 lines · Mattijs Korpershoek

We make fewer calls to dm_test_restore() since
commit fbdac8155c89 ("test: Expand implementation of ut_list_has_dm_tests()")

Because of this some valid test combinations are now broken:

$ ./test/py/test.py --bd sandbox --build -k test_ut
$ ./test/py/test.py --bd sandbox --build -k "bootflow_android or bootflow_cros"

Shows:

Expected ' 2 cros ready mmc 4 mmc5.bootdev.part_4 ',
got ' 2 cros ready mmc 2 mmc5.bootdev.part_2 '

Here prep_mmc_bootdev() is called twice and it will bind bootmeth_cros twice.

Since bootmeth_cros is bound twice, 'bootflow scan' will find 2x the expected bootflows.

Before
commit fbdac8155c89 ("test: Expand implementation of ut_list_has_dm_tests()") this did not happen because a cleanup was called each time.

Quoted 5 lines

Add UTF_DM and UTF_SCAN_FDT flags to both tests to make sure that the bootmeths are unbound after the test finishes.

Fixes fbdac8155c89 ("test: Expand implementation of ut_list_has_dm_tests()")

Applied to u-boot/master, thanks!

Signature · 1 line
Tom