diff options
Diffstat (limited to 'test/boot/bootflow.c')
-rw-r--r-- | test/boot/bootflow.c | 106 |
1 files changed, 83 insertions, 23 deletions
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 1ebb789e97b..85305234e01 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -9,13 +9,33 @@ #include <common.h> #include <bootdev.h> #include <bootflow.h> +#include <bootmeth.h> #include <bootstd.h> #include <dm.h> +#ifdef CONFIG_SANDBOX +#include <asm/test.h> +#endif #include <dm/lists.h> #include <test/suites.h> #include <test/ut.h> #include "bootstd_common.h" +static int inject_response(struct unit_test_state *uts) +{ + /* + * The image being booted presents a menu of options: + * + * Fedora-Workstation-armhfp-31-1.9 Boot Options. + * 1: Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl) + * Enter choice: + * + * Provide input for this, to avoid waiting two seconds for a timeout. + */ + ut_asserteq(2, console_in_puts("1\n")); + + return 0; +} + /* Check 'bootflow scan/list' commands */ static int bootflow_cmd(struct unit_test_state *uts) { @@ -73,7 +93,7 @@ static int bootflow_cmd_glob(struct unit_test_state *uts) ut_assertok(bootstd_test_drop_bootdev_order(uts)); console_record_reset_enable(); - ut_assertok(run_command("bootflow scan -l", 0)); + ut_assertok(run_command("bootflow scan -lG", 0)); ut_assert_nextline("Scanning for bootflows in all bootdevs"); ut_assert_nextline("Seq Method State Uclass Part Name Filename"); ut_assert_nextlinen("---"); @@ -105,7 +125,7 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts) ut_assertok(bootstd_test_drop_bootdev_order(uts)); console_record_reset_enable(); - ut_assertok(run_command("bootflow scan -ale", 0)); + ut_assertok(run_command("bootflow scan -aleG", 0)); ut_assert_nextline("Scanning for bootflows in all bootdevs"); ut_assert_nextline("Seq Method State Uclass Part Name Filename"); ut_assert_nextlinen("---"); @@ -188,6 +208,7 @@ BOOTSTD_TEST(bootflow_cmd_info, UT_TESTF_DM | UT_TESTF_SCAN_FDT); static int bootflow_scan_boot(struct unit_test_state *uts) { console_record_reset_enable(); + ut_assertok(inject_response(uts)); ut_assertok(run_command("bootflow scan -b", 0)); ut_assert_nextline( "** Booting bootflow 'mmc1.bootdev.part_1' with syslinux"); @@ -215,7 +236,7 @@ static int bootflow_iter(struct unit_test_state *uts) /* The first device is mmc2.bootdev which has no media */ ut_asserteq(-EPROTONOSUPPORT, - bootflow_scan_first(&iter, BOOTFLOWF_ALL, &bflow)); + bootflow_scan_first(&iter, BOOTFLOWF_ALL | BOOTFLOWF_SKIP_GLOBAL, &bflow)); ut_asserteq(2, iter.num_methods); ut_asserteq(0, iter.cur_method); ut_asserteq(0, iter.part); @@ -224,7 +245,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq(0, bflow.err); /* - * This shows MEDIA even though there is none, since int + * This shows MEDIA even though there is none, since in * bootdev_find_in_blk() we call part_get_info() which returns * -EPROTONOSUPPORT. Ideally it would return -EEOPNOTSUPP and we would * know. @@ -302,34 +323,31 @@ static int bootflow_iter(struct unit_test_state *uts) } BOOTSTD_TEST(bootflow_iter, UT_TESTF_DM | UT_TESTF_SCAN_FDT); +#if defined(CONFIG_SANDBOX) && defined(CONFIG_BOOTMETH_GLOBAL) /* Check using the system bootdev */ static int bootflow_system(struct unit_test_state *uts) { - struct udevice *bootstd, *dev; + struct udevice *dev; - /* Add the EFI bootmgr driver */ - ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); - ut_assertok(device_bind_driver(bootstd, "bootmeth_efi_mgr", "bootmgr", - &dev)); - - /* Add the system bootdev that it uses */ - ut_assertok(device_bind_driver(bootstd, "system_bootdev", - "system-bootdev", &dev)); - - ut_assertok(bootstd_test_drop_bootdev_order(uts)); + ut_assertok(uclass_get_device_by_name(UCLASS_BOOTMETH, "efi_mgr", + &dev)); + sandbox_set_fake_efi_mgr_dev(dev, true); /* We should get a single 'bootmgr' method right at the end */ bootstd_clear_glob(); console_record_reset_enable(); ut_assertok(run_command("bootflow scan -l", 0)); - ut_assert_skip_to_line(" 1 bootmgr ready bootstd 0 <NULL> <NULL>"); - ut_assert_nextline("No more bootdevs"); - ut_assert_skip_to_line("(2 bootflows, 2 valid)"); + 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_console_end(); return 0; } -BOOTSTD_TEST(bootflow_system, UT_TESTF_DM | UT_TESTF_SCAN_FDT); +BOOTSTD_TEST(bootflow_system, UT_TESTF_DM | UT_TESTF_SCAN_PDATA | + UT_TESTF_SCAN_FDT); +#endif /* Check disabling a bootmethod if it requests it */ static int bootflow_iter_disable(struct unit_test_state *uts) @@ -344,13 +362,11 @@ static int bootflow_iter_disable(struct unit_test_state *uts) ut_assertok(device_bind_driver(bootstd, "bootmeth_sandbox", "sandbox", &dev)); - /* Add the system bootdev that it uses */ - ut_assertok(device_bind_driver(bootstd, "system_bootdev", - "system-bootdev", &dev)); - ut_assertok(bootstd_test_drop_bootdev_order(uts)); bootstd_clear_glob(); + console_record_reset_enable(); + ut_assertok(inject_response(uts)); ut_assertok(run_command("bootflow scan -lb", 0)); /* Try to boot the bootmgr flow, which will fail */ @@ -358,6 +374,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts) ut_assertok(bootflow_scan_first(&iter, 0, &bflow)); ut_asserteq(3, iter.num_methods); ut_asserteq_str("sandbox", iter.method->name); + ut_assertok(inject_response(uts)); ut_asserteq(-ENOTSUPP, bootflow_run_boot(&iter, &bflow)); ut_assert_skip_to_line("Boot method 'sandbox' failed and will not be retried"); @@ -372,6 +389,47 @@ static int bootflow_iter_disable(struct unit_test_state *uts) } BOOTSTD_TEST(bootflow_iter_disable, UT_TESTF_DM | UT_TESTF_SCAN_FDT); +/* Check 'bootflow scan' with a bootmeth ordering including a global bootmeth */ +static int bootflow_scan_glob_bootmeth(struct unit_test_state *uts) +{ + if (!IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) + return 0; + + ut_assertok(bootstd_test_drop_bootdev_order(uts)); + + /* + * Make sure that the -G flag makes the scan fail, since this is not + * supported when an ordering is provided + */ + console_record_reset_enable(); + ut_assertok(bootmeth_set_order("efi firmware0")); + ut_assertok(run_command("bootflow scan -lG", 0)); + ut_assert_nextline("Scanning for bootflows in all bootdevs"); + ut_assert_nextline( + "Seq Method State Uclass Part Name Filename"); + ut_assert_nextlinen("---"); + ut_assert_nextlinen("---"); + ut_assert_nextline("(0 bootflows, 0 valid)"); + ut_assert_console_end(); + + ut_assertok(run_command("bootflow scan -l", 0)); + ut_assert_nextline("Scanning for bootflows in all bootdevs"); + ut_assert_nextline( + "Seq Method State Uclass Part Name Filename"); + ut_assert_nextlinen("---"); + ut_assert_nextline("Scanning global bootmeth 'firmware0':"); + ut_assert_nextline("Scanning bootdev 'mmc2.bootdev':"); + ut_assert_nextline("Scanning bootdev 'mmc1.bootdev':"); + ut_assert_nextline("Scanning bootdev 'mmc0.bootdev':"); + ut_assert_nextline("No more bootdevs"); + ut_assert_nextlinen("---"); + ut_assert_nextline("(0 bootflows, 0 valid)"); + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootflow_scan_glob_bootmeth, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + /* Check 'bootflow boot' to boot a selected bootflow */ static int bootflow_cmd_boot(struct unit_test_state *uts) { @@ -382,6 +440,8 @@ static int bootflow_cmd_boot(struct unit_test_state *uts) ut_assert_console_end(); ut_assertok(run_command("bootflow select 0", 0)); ut_assert_console_end(); + + ut_assertok(inject_response(uts)); ut_asserteq(1, run_command("bootflow boot", 0)); ut_assert_nextline( "** Booting bootflow 'mmc1.bootdev.part_1' with syslinux"); |