bootstd: Add a new pre-scan priority for bootdevs

We need extensions to be set up before we start trying to boot any of the
bootdevs. Add a new priority before all the others for tht sort of thing.
Also add a 'none' option, so that the first one is not 0.

While we are here, comment enum bootdev_prio_t fully and expand the test
for the 'bootdev hunt' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2023-01-17 10:48:08 -07:00
committed by Tom Rini
parent 79a7d4a61f
commit eacc261178
12 changed files with 84 additions and 44 deletions

View File

@@ -247,14 +247,14 @@ static int bootdev_test_hunter(struct unit_test_state *uts)
bootdev_list_hunters(std);
ut_assert_nextline("Prio Used Uclass Hunter");
ut_assert_nextlinen("----");
ut_assert_nextline(" 50 ethernet eth_bootdev");
ut_assert_nextline(" 40 ide ide_bootdev");
ut_assert_nextline(" 10 mmc mmc_bootdev");
ut_assert_nextline(" 30 nvme nvme_bootdev");
ut_assert_nextline(" 30 scsi scsi_bootdev");
ut_assert_nextline(" 30 spi_flash sf_bootdev");
ut_assert_nextline(" 40 usb usb_bootdev");
ut_assert_nextline(" 30 virtio virtio_bootdev");
ut_assert_nextline(" 6 ethernet eth_bootdev");
ut_assert_nextline(" 5 ide ide_bootdev");
ut_assert_nextline(" 2 mmc mmc_bootdev");
ut_assert_nextline(" 4 nvme nvme_bootdev");
ut_assert_nextline(" 4 scsi scsi_bootdev");
ut_assert_nextline(" 4 spi_flash sf_bootdev");
ut_assert_nextline(" 5 usb usb_bootdev");
ut_assert_nextline(" 4 virtio virtio_bootdev");
ut_assert_nextline("(total hunters: 8)");
ut_assert_console_end();
@@ -284,17 +284,28 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
ut_assertok(run_command("bootdev hunt -l", 0));
ut_assert_nextline("Prio Used Uclass Hunter");
ut_assert_nextlinen("----");
ut_assert_nextline(" 6 ethernet eth_bootdev");
ut_assert_skip_to_line("(total hunters: 8)");
ut_assert_console_end();
/* Use the MMC hunter and see that it updates */
ut_assertok(run_command("bootdev hunt mmc", 0));
ut_assertok(run_command("bootdev hunt -l", 0));
ut_assert_skip_to_line(" 5 ide ide_bootdev");
ut_assert_nextline(" 2 * mmc mmc_bootdev");
ut_assert_skip_to_line("(total hunters: 8)");
ut_assert_console_end();
/* Scan all hunters */
sandbox_set_eth_enable(false);
test_set_skip_delays(true);
ut_assertok(run_command("bootdev hunt", 0));
ut_assert_nextline("Hunting with: ethernet");
ut_assert_nextline("Hunting with: ide");
ut_assert_nextline("Bus 0: not available ");
ut_assert_nextline("Hunting with: mmc");
/* mmc hunter has already been used so should not run again */
ut_assert_nextline("Hunting with: nvme");
ut_assert_nextline("Hunting with: scsi");
ut_assert_nextline("scanning bus for devices...");
@@ -309,14 +320,14 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
ut_assertok(run_command("bootdev hunt -l", 0));
ut_assert_nextlinen("Prio");
ut_assert_nextlinen("----");
ut_assert_nextline(" 50 * ethernet eth_bootdev");
ut_assert_nextline(" 40 * ide ide_bootdev");
ut_assert_nextline(" 10 * mmc mmc_bootdev");
ut_assert_nextline(" 30 * nvme nvme_bootdev");
ut_assert_nextline(" 30 * scsi scsi_bootdev");
ut_assert_nextline(" 30 * spi_flash sf_bootdev");
ut_assert_nextline(" 40 * usb usb_bootdev");
ut_assert_nextline(" 30 * virtio virtio_bootdev");
ut_assert_nextline(" 6 * ethernet eth_bootdev");
ut_assert_nextline(" 5 * ide ide_bootdev");
ut_assert_nextline(" 2 * mmc mmc_bootdev");
ut_assert_nextline(" 4 * nvme nvme_bootdev");
ut_assert_nextline(" 4 * scsi scsi_bootdev");
ut_assert_nextline(" 4 * spi_flash sf_bootdev");
ut_assert_nextline(" 5 * usb usb_bootdev");
ut_assert_nextline(" 4 * virtio virtio_bootdev");
ut_assert_nextline("(total hunters: 8)");
ut_assert_console_end();
@@ -370,14 +381,14 @@ static int bootdev_test_hunt_prio(struct unit_test_state *uts)
test_set_skip_delays(true);
console_record_reset_enable();
ut_assertok(bootdev_hunt_prio(BOOTDEVP_2_SCAN_FAST, false));
ut_assertok(bootdev_hunt_prio(BOOTDEVP_4_SCAN_FAST, false));
ut_assert_nextline("scanning bus for devices...");
ut_assert_skip_to_line(" Type: Hard Disk");
ut_assert_nextlinen(" Capacity:");
ut_assert_console_end();
/* now try a different priority, verbosely */
ut_assertok(bootdev_hunt_prio(BOOTDEVP_3_SCAN_SLOW, true));
ut_assertok(bootdev_hunt_prio(BOOTDEVP_5_SCAN_SLOW, true));
ut_assert_nextline("Hunting with: ide");
ut_assert_nextline("Bus 0: not available ");
ut_assert_nextline("Hunting with: usb");