bootstd: Record the bootdevs used during scanning
Add a way to record the bootdevs used when scanning for bootflows. This is useful for testing. Enable this only with BOOTSTD_FULL and do the same for the progress reporting. Re-enable and update the affected tests now that we have this feature. For bootdev_test_order_default() there is no-longer any support for using the bootdev aliases to specify an ordering, so drop that part of the test. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -186,7 +186,6 @@ static int bootdev_test_any(struct unit_test_state *uts)
|
||||
BOOTSTD_TEST(bootdev_test_any, UT_TESTF_DM | UT_TESTF_SCAN_FDT |
|
||||
UT_TESTF_ETH_BOOTDEV);
|
||||
|
||||
#if 0 /* disable for now */
|
||||
/* Check bootdev ordering with the bootdev-order property */
|
||||
static int bootdev_test_order(struct unit_test_state *uts)
|
||||
{
|
||||
@@ -205,18 +204,29 @@ static int bootdev_test_order(struct unit_test_state *uts)
|
||||
ut_assertok(env_set("boot_targets", NULL));
|
||||
ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
|
||||
ut_asserteq(2, iter.num_devs);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
|
||||
ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name);
|
||||
ut_asserteq_str("mmc1.bootdev", iter.dev_used[1]->name);
|
||||
bootflow_iter_uninit(&iter);
|
||||
|
||||
/* Use the environment variable to override it */
|
||||
ut_assertok(env_set("boot_targets", "mmc1 mmc2"));
|
||||
ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
|
||||
ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow));
|
||||
ut_asserteq(2, iter.num_devs);
|
||||
ut_asserteq_str("mmc1.bootdev", iter.dev_order[0]->name);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_order[1]->name);
|
||||
ut_asserteq_str("mmc1.bootdev", iter.dev_used[0]->name);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_used[1]->name);
|
||||
bootflow_iter_uninit(&iter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BOOTSTD_TEST(bootdev_test_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
|
||||
|
||||
/* Check default bootdev ordering */
|
||||
static int bootdev_test_order_default(struct unit_test_state *uts)
|
||||
{
|
||||
struct bootflow_iter iter;
|
||||
struct bootflow bflow;
|
||||
|
||||
/*
|
||||
* Now drop both orderings, to check the default (prioriy/sequence)
|
||||
* ordering
|
||||
@@ -225,30 +235,18 @@ static int bootdev_test_order(struct unit_test_state *uts)
|
||||
ut_assertok(bootstd_test_drop_bootdev_order(uts));
|
||||
|
||||
ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
|
||||
ut_asserteq(3, iter.num_devs);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
|
||||
ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name);
|
||||
ut_asserteq_str("mmc0.bootdev", iter.dev_order[2]->name);
|
||||
ut_asserteq(2, iter.num_devs);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name);
|
||||
ut_asserteq_str("mmc1.bootdev", iter.dev_used[1]->name);
|
||||
|
||||
/*
|
||||
* Check that adding aliases for the bootdevs works. We just fake it by
|
||||
* setting the sequence numbers directly.
|
||||
*/
|
||||
iter.dev_order[0]->seq_ = 0;
|
||||
iter.dev_order[1]->seq_ = 3;
|
||||
iter.dev_order[2]->seq_ = 2;
|
||||
bootflow_iter_uninit(&iter);
|
||||
|
||||
ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
|
||||
ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow));
|
||||
ut_asserteq(3, iter.num_devs);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
|
||||
ut_asserteq_str("mmc0.bootdev", iter.dev_order[1]->name);
|
||||
ut_asserteq_str("mmc1.bootdev", iter.dev_order[2]->name);
|
||||
ut_asserteq_str("mmc0.bootdev", iter.dev_used[2]->name);
|
||||
bootflow_iter_uninit(&iter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BOOTSTD_TEST(bootdev_test_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
|
||||
BOOTSTD_TEST(bootdev_test_order_default, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
|
||||
|
||||
/* Check bootdev ordering with the uclass priority */
|
||||
static int bootdev_test_prio(struct unit_test_state *uts)
|
||||
@@ -260,6 +258,9 @@ static int bootdev_test_prio(struct unit_test_state *uts)
|
||||
|
||||
test_set_skip_delays(true);
|
||||
|
||||
/* disable ethernet since the hunter will run dhcp */
|
||||
test_set_eth_enable(false);
|
||||
|
||||
/* Start up USB which gives us three additional bootdevs */
|
||||
usb_started = false;
|
||||
ut_assertok(run_command("usb start", 0));
|
||||
@@ -269,30 +270,32 @@ static int bootdev_test_prio(struct unit_test_state *uts)
|
||||
/* 3 MMC and 3 USB bootdevs: MMC should come before USB */
|
||||
console_record_reset_enable();
|
||||
ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
|
||||
ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow));
|
||||
ut_asserteq(6, iter.num_devs);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name);
|
||||
ut_asserteq_str("usb_mass_storage.lun0.bootdev",
|
||||
iter.dev_order[3]->name);
|
||||
iter.dev_used[3]->name);
|
||||
|
||||
ut_assertok(bootdev_get_sibling_blk(iter.dev_order[3], &blk));
|
||||
ut_assertok(bootdev_get_sibling_blk(iter.dev_used[3], &blk));
|
||||
ut_asserteq_str("usb_mass_storage.lun0", blk->name);
|
||||
|
||||
/* adjust the priority of the first USB bootdev to the highest */
|
||||
ucp = dev_get_uclass_plat(iter.dev_order[3]);
|
||||
ucp->prio = 1;
|
||||
ucp = dev_get_uclass_plat(iter.dev_used[3]);
|
||||
ucp->prio = BOOTDEVP_1_PRE_SCAN;
|
||||
|
||||
/* try again but enable hunting, which brings in SCSI */
|
||||
bootflow_iter_uninit(&iter);
|
||||
ut_assertok(bootflow_scan_first(NULL, NULL, &iter, BOOTFLOWF_HUNT,
|
||||
&bflow));
|
||||
ut_asserteq(6, iter.num_devs);
|
||||
ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow));
|
||||
ut_asserteq(7, iter.num_devs);
|
||||
ut_asserteq_str("usb_mass_storage.lun0.bootdev",
|
||||
iter.dev_order[0]->name);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_order[1]->name);
|
||||
iter.dev_used[0]->name);
|
||||
ut_asserteq_str("mmc2.bootdev", iter.dev_used[1]->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BOOTSTD_TEST(bootdev_test_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
|
||||
#endif
|
||||
|
||||
/* Check listing hunters */
|
||||
static int bootdev_test_hunter(struct unit_test_state *uts)
|
||||
|
Reference in New Issue
Block a user