Message ID | 20240902011825.746421-15-sjg@chromium.org |
---|---|
State | Changes Requested |
Delegated to: | Heinrich Schuchardt |
Headers | show |
Series | efi: Add a test for EFI bootmeth | expand |
On 02.09.24 03:18, Simon Glass wrote: > Add a simple test of booting with the EFI bootmeth, which runs the app > and checks that it can call 'exit boot-services' (to check that all the > device-removal code doesn't break anything) and then exit back to > U-Boot. > > This uses a disk image containing the testapp, ready for execution by > sandbox when needed. > > Signed-off-by: Simon Glass <sjg@chromium.org> > > --- > > Changes in v5: > - Rebase on updated efif series > - Deal with sandbox CONFIG_LOGF_FUNC > > Changes in v4: > - Add efi_loader tag to some patches > - Split out non-EFI patches into a different series > > Changes in v2: > - Add many new patches to resolve all the outstanding test issues > > test/boot/bootflow.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 64 insertions(+) > > diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c > index 37884dbd441..d8da3aac493 100644 > --- a/test/boot/bootflow.c > +++ b/test/boot/bootflow.c > @@ -13,6 +13,7 @@ > #include <cli.h> > #include <dm.h> > #include <efi_default_filename.h> > +#include <efi_loader.h> > #include <expo.h> > #ifdef CONFIG_SANDBOX > #include <asm/test.h> > @@ -31,6 +32,9 @@ extern U_BOOT_DRIVER(bootmeth_android); > extern U_BOOT_DRIVER(bootmeth_cros); > extern U_BOOT_DRIVER(bootmeth_2script); > > +/* Use this as the vendor for EFI to tell the app to exit boot services */ > +static u16 __efi_runtime_data test_vendor[] = u"U-Boot testing"; > + > static int inject_response(struct unit_test_state *uts) > { > /* > @@ -1205,3 +1209,63 @@ static int bootflow_android(struct unit_test_state *uts) > return 0; > } > BOOTSTD_TEST(bootflow_android, UTF_CONSOLE); > + > +/* Test EFI bootmeth */ > +static int bootflow_efi(struct unit_test_state *uts) > +{ > + /* disable ethernet since the hunter will run dhcp */ > + test_set_eth_enable(false); > + > + /* make USB scan without delays */ > + test_set_skip_delays(true); > + > + bootstd_reset_usb(); > + > + /* Avoid outputting ANSI characters which mess with our asserts */ > + efi_console_set_ansi(false); > + > + ut_assertok(bootstd_test_drop_bootdev_order(uts)); > + ut_assertok(run_command("bootflow scan", 0)); > + ut_assert_skip_to_line( > + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); > + > + ut_assertok(run_command("bootflow list", 0)); > + > + ut_assert_nextlinen("Showing all"); > + ut_assert_nextlinen("Seq"); > + ut_assert_nextlinen("---"); > + ut_assert_nextlinen(" 0 extlinux"); > + ut_assert_nextlinen( > + " 1 efi ready usb_mass_ 1 usb_mass_storage.lun0.boo /EFI/BOOT/BOOTSBOX.EFI"); > + ut_assert_nextlinen("---"); > + ut_assert_skip_to_line("(2 bootflows, 2 valid)"); > + ut_assert_console_end(); > + > + ut_assertok(run_command("bootflow select 1", 0)); > + ut_assert_console_end(); > + > + /* signal to helloworld to exit boot services */ What 'helloworld' are you relating to? Best regards Heinrich > + systab.fw_vendor = test_vendor; > + > + ut_asserteq(1, run_command("bootflow boot", 0)); > + ut_assert_nextline( > + "** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi"); > + if (IS_ENABLED(CONFIG_LOGF_FUNC)) > + ut_assert_skip_to_line(" efi_run_image() Booting /\\EFI\\BOOT\\BOOTSBOX.EFI"); > + else > + ut_assert_skip_to_line("Booting /\\EFI\\BOOT\\BOOTSBOX.EFI"); > + > + /* TODO: Why the \r ? */ > + ut_assert_nextline("U-Boot test app for EFI_LOADER\r"); > + ut_assert_nextline("Exiting boot sevices"); > + if (IS_ENABLED(CONFIG_LOGF_FUNC)) > + ut_assert_nextline(" do_bootefi_exec() ## Application failed, r = 5"); > + else > + ut_assert_nextline("## Application failed, r = 5"); > + ut_assert_nextline("Boot failed (err=-22)"); > + > + ut_assert_console_end(); > + > + return 0; > +} > +BOOTSTD_TEST(bootflow_efi, UTF_CONSOLE);
Hi Heinrich, On Thu, 12 Sept 2024 at 09:12, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > > On 02.09.24 03:18, Simon Glass wrote: > > Add a simple test of booting with the EFI bootmeth, which runs the app > > and checks that it can call 'exit boot-services' (to check that all the > > device-removal code doesn't break anything) and then exit back to > > U-Boot. > > > > This uses a disk image containing the testapp, ready for execution by > > sandbox when needed. > > > > Signed-off-by: Simon Glass <sjg@chromium.org> > > > > --- > > > > Changes in v5: > > - Rebase on updated efif series > > - Deal with sandbox CONFIG_LOGF_FUNC > > > > Changes in v4: > > - Add efi_loader tag to some patches > > - Split out non-EFI patches into a different series > > > > Changes in v2: > > - Add many new patches to resolve all the outstanding test issues > > > > test/boot/bootflow.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 64 insertions(+) > > > > diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c > > index 37884dbd441..d8da3aac493 100644 > > --- a/test/boot/bootflow.c > > +++ b/test/boot/bootflow.c > > @@ -13,6 +13,7 @@ > > #include <cli.h> > > #include <dm.h> > > #include <efi_default_filename.h> > > +#include <efi_loader.h> > > #include <expo.h> > > #ifdef CONFIG_SANDBOX > > #include <asm/test.h> > > @@ -31,6 +32,9 @@ extern U_BOOT_DRIVER(bootmeth_android); > > extern U_BOOT_DRIVER(bootmeth_cros); > > extern U_BOOT_DRIVER(bootmeth_2script); > > > > +/* Use this as the vendor for EFI to tell the app to exit boot services */ > > +static u16 __efi_runtime_data test_vendor[] = u"U-Boot testing"; > > + > > static int inject_response(struct unit_test_state *uts) > > { > > /* > > @@ -1205,3 +1209,63 @@ static int bootflow_android(struct unit_test_state *uts) > > return 0; > > } > > BOOTSTD_TEST(bootflow_android, UTF_CONSOLE); > > + > > +/* Test EFI bootmeth */ > > +static int bootflow_efi(struct unit_test_state *uts) > > +{ > > + /* disable ethernet since the hunter will run dhcp */ > > + test_set_eth_enable(false); > > + > > + /* make USB scan without delays */ > > + test_set_skip_delays(true); > > + > > + bootstd_reset_usb(); > > + > > + /* Avoid outputting ANSI characters which mess with our asserts */ > > + efi_console_set_ansi(false); > > + > > + ut_assertok(bootstd_test_drop_bootdev_order(uts)); > > + ut_assertok(run_command("bootflow scan", 0)); > > + ut_assert_skip_to_line( > > + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); > > + > > + ut_assertok(run_command("bootflow list", 0)); > > + > > + ut_assert_nextlinen("Showing all"); > > + ut_assert_nextlinen("Seq"); > > + ut_assert_nextlinen("---"); > > + ut_assert_nextlinen(" 0 extlinux"); > > + ut_assert_nextlinen( > > + " 1 efi ready usb_mass_ 1 usb_mass_storage.lun0.boo /EFI/BOOT/BOOTSBOX.EFI"); > > + ut_assert_nextlinen("---"); > > + ut_assert_skip_to_line("(2 bootflows, 2 valid)"); > > + ut_assert_console_end(); > > + > > + ut_assertok(run_command("bootflow select 1", 0)); > > + ut_assert_console_end(); > > + > > + /* signal to helloworld to exit boot services */ > > > What 'helloworld' are you relating to? That comment is stale so can be dropped. It dates from when the test used the helloword binary. > > Best regards > > Heinrich > > > + systab.fw_vendor = test_vendor; > > + > > + ut_asserteq(1, run_command("bootflow boot", 0)); > > + ut_assert_nextline( > > + "** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi"); > > + if (IS_ENABLED(CONFIG_LOGF_FUNC)) > > + ut_assert_skip_to_line(" efi_run_image() Booting /\\EFI\\BOOT\\BOOTSBOX.EFI"); > > + else > > + ut_assert_skip_to_line("Booting /\\EFI\\BOOT\\BOOTSBOX.EFI"); > > + > > + /* TODO: Why the \r ? */ > > + ut_assert_nextline("U-Boot test app for EFI_LOADER\r"); > > + ut_assert_nextline("Exiting boot sevices"); > > + if (IS_ENABLED(CONFIG_LOGF_FUNC)) > > + ut_assert_nextline(" do_bootefi_exec() ## Application failed, r = 5"); > > + else > > + ut_assert_nextline("## Application failed, r = 5"); > > + ut_assert_nextline("Boot failed (err=-22)"); > > + > > + ut_assert_console_end(); > > + > > + return 0; > > +} > > +BOOTSTD_TEST(bootflow_efi, UTF_CONSOLE); > Regards, Simon
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 37884dbd441..d8da3aac493 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -13,6 +13,7 @@ #include <cli.h> #include <dm.h> #include <efi_default_filename.h> +#include <efi_loader.h> #include <expo.h> #ifdef CONFIG_SANDBOX #include <asm/test.h> @@ -31,6 +32,9 @@ extern U_BOOT_DRIVER(bootmeth_android); extern U_BOOT_DRIVER(bootmeth_cros); extern U_BOOT_DRIVER(bootmeth_2script); +/* Use this as the vendor for EFI to tell the app to exit boot services */ +static u16 __efi_runtime_data test_vendor[] = u"U-Boot testing"; + static int inject_response(struct unit_test_state *uts) { /* @@ -1205,3 +1209,63 @@ static int bootflow_android(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootflow_android, UTF_CONSOLE); + +/* Test EFI bootmeth */ +static int bootflow_efi(struct unit_test_state *uts) +{ + /* disable ethernet since the hunter will run dhcp */ + test_set_eth_enable(false); + + /* make USB scan without delays */ + test_set_skip_delays(true); + + bootstd_reset_usb(); + + /* Avoid outputting ANSI characters which mess with our asserts */ + efi_console_set_ansi(false); + + ut_assertok(bootstd_test_drop_bootdev_order(uts)); + ut_assertok(run_command("bootflow scan", 0)); + ut_assert_skip_to_line( + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); + + ut_assertok(run_command("bootflow list", 0)); + + ut_assert_nextlinen("Showing all"); + ut_assert_nextlinen("Seq"); + ut_assert_nextlinen("---"); + ut_assert_nextlinen(" 0 extlinux"); + ut_assert_nextlinen( + " 1 efi ready usb_mass_ 1 usb_mass_storage.lun0.boo /EFI/BOOT/BOOTSBOX.EFI"); + ut_assert_nextlinen("---"); + ut_assert_skip_to_line("(2 bootflows, 2 valid)"); + ut_assert_console_end(); + + ut_assertok(run_command("bootflow select 1", 0)); + ut_assert_console_end(); + + /* signal to helloworld to exit boot services */ + systab.fw_vendor = test_vendor; + + ut_asserteq(1, run_command("bootflow boot", 0)); + ut_assert_nextline( + "** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi"); + if (IS_ENABLED(CONFIG_LOGF_FUNC)) + ut_assert_skip_to_line(" efi_run_image() Booting /\\EFI\\BOOT\\BOOTSBOX.EFI"); + else + ut_assert_skip_to_line("Booting /\\EFI\\BOOT\\BOOTSBOX.EFI"); + + /* TODO: Why the \r ? */ + ut_assert_nextline("U-Boot test app for EFI_LOADER\r"); + ut_assert_nextline("Exiting boot sevices"); + if (IS_ENABLED(CONFIG_LOGF_FUNC)) + ut_assert_nextline(" do_bootefi_exec() ## Application failed, r = 5"); + else + ut_assert_nextline("## Application failed, r = 5"); + ut_assert_nextline("Boot failed (err=-22)"); + + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootflow_efi, UTF_CONSOLE);
Add a simple test of booting with the EFI bootmeth, which runs the app and checks that it can call 'exit boot-services' (to check that all the device-removal code doesn't break anything) and then exit back to U-Boot. This uses a disk image containing the testapp, ready for execution by sandbox when needed. Signed-off-by: Simon Glass <sjg@chromium.org> --- Changes in v5: - Rebase on updated efif series - Deal with sandbox CONFIG_LOGF_FUNC Changes in v4: - Add efi_loader tag to some patches - Split out non-EFI patches into a different series Changes in v2: - Add many new patches to resolve all the outstanding test issues test/boot/bootflow.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)