efi_loader: Disable ANSI output for tests
PATCH v6 8/12 efi_loader: Disable ANSI output for tests
We don't want ANSI characters written in tests since it is a pain to check the output with ut_assert_nextline() et al.
Provide a way to tests to request that ANSI characters not be sent.
Add a proper function comment while we are here, to encourage others.
---
(no changes since v1)
include/efi_loader.h | 21 ++++++++++++++++++++- lib/efi_loader/efi_console.c | 26 +++++++++++++++++--------- 2 files changed, 37 insertions(+), 10 deletions(-)
include/efi_loader.h +20 -1
@@ -531,8 +531,27 @@ efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index);efi_status_t efi_bootmgr_run (void *fdt);/* search the boot option index in BootOrder */ bool efi_search_bootorder (u16 *bootorder,efi_uintn_t num,u32 target,u32 *index); -/* Set up console modes */ + +/** +* efi_setup_console_size() - update the mode table. +* +* By default the only mode available is 80x25. If the console has at least 50 +* lines, enable mode 80x50. If we can query the console size and it is neither +* 80x25 nor 80x50, set it as an additional mode. +*/ void efi_setup_console_size (void ); + +/** +* efi_console_set_ansi() - Set whether ANSI characters should be emitted +* +* These characters mess up tests which use ut_assert_nextline(). Call this +* function to tell efi_loader not to emit these characters when starting up the +* terminal +* +* @allow_ansi: Allow emitting ANSI characters +*/ +void efi_console_set_ansi (bool allow_ansi); +/* Set up load options from environment variable */ efi_status_t efi_env_set_load_options (efi_handle_t handle,const char *env_var,u16 **load_options);
lib/efi_loader/efi_console.c +17 -9
@@ -30,6 +30,17 @@ struct cout_mode {__maybe_unused static struct efi_object uart_obj; +/* +* suppress emission of ANSI codes for use by unit tests. Leave it as 0 for the +* default behaviour +*/ +static bool no_ansi; + +void efi_console_set_ansi (bool allow_ansi) +{ + no_ansi = !allow_ansi; +} +static struct cout_mode efi_cout_modes[] = {/* EFI Mode 0 is 80x25 and always present */ {
@@ -348,13 +359,6 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols)return 0 ; } -/** -* efi_setup_console_size() - update the mode table. -* -* By default the only mode available is 80x25. If the console has at least 50 -* lines, enable mode 80x50. If we can query the console size and it is neither -* 80x25 nor 80x50, set it as an additional mode. -*/ void efi_setup_console_size (void ) {int rows =25 , cols =80 ;
@@ -362,8 +366,12 @@ void efi_setup_console_size(void)if (IS_ENABLED (CONFIG_VIDEO )) ret =query_vidconsole (&rows, &cols); -if (ret) - ret =query_console_serial (&rows, &cols); +if (ret) { +if (no_ansi) + ret =0 ; +else + ret =query_console_serial (&rows, &cols); + }if (ret)return ;
Signature · 1 line
2.43.0
PATCH v6 9/12 efi_loader: Add a test app
Add a simple app to use for testing. This is intended to do whatever it needs to for testing purposes. For now it just prints a message and exits boot services.
---
(no changes since v1)
lib/efi_loader/Kconfig | 10 ++++++ lib/efi_loader/Makefile | 1 + lib/efi_loader/testapp.c | 68 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 lib/efi_loader/testapp.c
lib/efi_loader/Kconfig +10 -0
@@ -564,6 +564,16 @@ config BOOTEFI_HELLO_COMPILE No additional space will be required in the resulting U-Boot binary when this option is enabled. +config BOOTEFI_TESTAPP_COMPILE + bool "Compile an EFI test app for testing" + default y + help + This compiles an app designed for testing. It is packed into an image + by the test.py testing frame in the setup_efi_image() function. + + No additional space will be required in the resulting U-Boot binary + when this option is enabled. + endif source "lib/efi/Kconfig"
lib/efi_loader/Makefile +1 -0
@@ -20,6 +20,7 @@ apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) apps-y += dtbdump endif +apps-$(CONFIG_BOOTEFI_TESTAPP_COMPILE) += testapp obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.o
lib/efi_loader/testapp.c new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v6 09/12] efi_loader: Add a test app
Hi Simon,
Quoted 106 lines · Simon Glass
Add a simple app to use for testing. This is intended to do whatever it needs to for testing purposes. For now it just prints a message and exits boot services.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
lib/efi_loader/Kconfig | 10 ++++++ lib/efi_loader/Makefile | 1 + lib/efi_loader/testapp.c | 68 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 lib/efi_loader/testapp.clib/efi_loader/Kconfig +10
-0@@ -564,6 +564,16 @@ config BOOTEFI_HELLO_COMPILE No additional space will be required in the resulting U-Boot binary when this option is enabled. +config BOOTEFI_TESTAPP_COMPILE + bool "Compile an EFI test app for testing" + default y + help + This compiles an app designed for testing. It is packed into an image + by the test.py testing frame in the setup_efi_image() function. + + No additional space will be required in the resulting U-Boot binary + when this option is enabled. + endif source "lib/efi/Kconfig"lib/efi_loader/Makefile +1
-0@@ -20,6 +20,7 @@ apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) apps-y += dtbdump endif +apps-$(CONFIG_BOOTEFI_TESTAPP_COMPILE) += testapp obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.olib/efi_loader/testapp.c new file +51
-0@@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Hello world EFI application +* +* Copyright 2024 Google LLC +* Written by Simon Glass <[email protected]> +* +* This test program is used to test the invocation of an EFI application. +* It writes a few messages to the console and then exits boot services +*/ + +#include <efi_api.h> + +static const efi_guid_t loaded_image_guid =EFI_LOADED_IMAGE_PROTOCOL_GUID ; + +static struct efi_system_table *systable; +static struct efi_boot_services *boottime; +static struct efi_simple_text_output_protocol *con_out; + +/** +* efi_main() - entry point of the EFI application. +* +* @handle: handle of the loaded image +* @systab: system table +* Return: status code +*/ +efi_status_t EFIAPI efi_main(efi_handle_t handle, +struct efi_system_table *systab) +{ +struct efi_loaded_image *loaded_image; +efi_status_t ret; +efi_uintn_t map_size; +efi_uintn_t map_key; +efi_uintn_t desc_size; +u32 desc_version; + + systable = systab; + boottime = systable->boottime; + con_out = systable->con_out; + +/* Get the loaded image protocol */ + ret = boottime->open_protocol (handle, &loaded_image_guid, + (void **)&loaded_image,NULL ,NULL , +EFI_OPEN_PROTOCOL_GET_PROTOCOL ); +if (ret !=EFI_SUCCESS ) { + con_out->output_string + (con_out,u"Cannot open loaded image protocol\r\n" ); + goto out; + } + +/* UEFI requires CR LF */
lib/efi_loader/testapp.c line 61
Quoted 10 lines
lib/efi_loader/testapp.c new file +10
-0+ con_out->output_string (con_out,u"U-Boot test app for EFI_LOADER\r\n" ); + +out: + map_size =0 ; + ret = boottime->get_memory_map (&map_size,NULL , &map_key, &desc_size, + &desc_version); + con_out->output_string (con_out,u"Exiting boot sevices\n" ); + +/* exit boot services so that this part of U-Boot can be tested */ + boottime->exit_boot_services (handle, map_key);
What Heinrich keeps repeating here, is that after you call EBS, boot services must not be called again.
lib/efi_loader/testapp.c line 64
Quoted 3 lines
lib/efi_loader/testapp.c new file +3
-0+ +/* now exit for real */ + ret = boottime->exit (handle, ret,0 ,NULL );
IOW this is wrong. It might happen to work because not much has run and the memory will still be there. But you certainly should not rely on that
Thanks
/Ilias
Quoted 7 lines
lib/efi_loader/testapp.c new file +4
-1+ +/* We should never arrive here */ +return ret; +} --2.43.0
Re: [PATCH v6 09/12] efi_loader: Add a test app
Hi Ilias,
Quoted 124 lines · Ilias Apalodimas
Hi Simon,
Quoted 106 lines · Simon Glass
Add a simple app to use for testing. This is intended to do whatever it needs to for testing purposes. For now it just prints a message and exits boot services.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
lib/efi_loader/Kconfig | 10 ++++++ lib/efi_loader/Makefile | 1 + lib/efi_loader/testapp.c | 68 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 lib/efi_loader/testapp.clib/efi_loader/Kconfig +10
-0@@ -564,6 +564,16 @@ config BOOTEFI_HELLO_COMPILE No additional space will be required in the resulting U-Boot binary when this option is enabled. +config BOOTEFI_TESTAPP_COMPILE + bool "Compile an EFI test app for testing" + default y + help + This compiles an app designed for testing. It is packed into an image + by the test.py testing frame in the setup_efi_image() function. + + No additional space will be required in the resulting U-Boot binary + when this option is enabled. + endif source "lib/efi/Kconfig"lib/efi_loader/Makefile +1
-0@@ -20,6 +20,7 @@ apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) apps-y += dtbdump endif +apps-$(CONFIG_BOOTEFI_TESTAPP_COMPILE) += testapp obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.olib/efi_loader/testapp.c new file +51
-0@@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Hello world EFI application +* +* Copyright 2024 Google LLC +* Written by Simon Glass <[email protected]> +* +* This test program is used to test the invocation of an EFI application. +* It writes a few messages to the console and then exits boot services +*/ + +#include <efi_api.h> + +static const efi_guid_t loaded_image_guid =EFI_LOADED_IMAGE_PROTOCOL_GUID ; + +static struct efi_system_table *systable; +static struct efi_boot_services *boottime; +static struct efi_simple_text_output_protocol *con_out; + +/** +* efi_main() - entry point of the EFI application. +* +* @handle: handle of the loaded image +* @systab: system table +* Return: status code +*/ +efi_status_t EFIAPI efi_main(efi_handle_t handle, +struct efi_system_table *systab) +{ +struct efi_loaded_image *loaded_image; +efi_status_t ret; +efi_uintn_t map_size; +efi_uintn_t map_key; +efi_uintn_t desc_size; +u32 desc_version; + + systable = systab; + boottime = systable->boottime; + con_out = systable->con_out; + +/* Get the loaded image protocol */ + ret = boottime->open_protocol (handle, &loaded_image_guid, + (void **)&loaded_image,NULL ,NULL , +EFI_OPEN_PROTOCOL_GET_PROTOCOL ); +if (ret !=EFI_SUCCESS ) { + con_out->output_string + (con_out,u"Cannot open loaded image protocol\r\n" ); + goto out; + } + +/* UEFI requires CR LF */ lib/efi_loader/testapp.c line 61
Quoted 10 lines
lib/efi_loader/testapp.c new file +10
-0+ con_out->output_string (con_out,u"U-Boot test app for EFI_LOADER\r\n" ); + +out: + map_size =0 ; + ret = boottime->get_memory_map (&map_size,NULL , &map_key, &desc_size, + &desc_version); + con_out->output_string (con_out,u"Exiting boot sevices\n" ); + +/* exit boot services so that this part of U-Boot can be tested */ + boottime->exit_boot_services (handle, map_key);What Heinrich keeps repeating here, is that after you call EBS, boot services must not be called again.
Quoted 7 lines
lib/efi_loader/testapp.c line 64
Quoted 3 lines
lib/efi_loader/testapp.c new file +3
-0+ +/* now exit for real */ + ret = boottime->exit (handle, ret,0 ,NULL );IOW this is wrong. It might happen to work because not much has run and the memory will still be there. But you certainly should not rely on that
Well, not much has run because it is running the test program. So we know it will be OK.
One of the challenges we have is that we need to design things for testing, i.e. to make testing easy and practical. The call to exit() happily returns back to sandbox and all is well. It serves the purpose of the test, which is all the app is wanting to do.
So I have to ask, what problem are you seeing?
Quoted 11 lines
Thanks
/Ilias
Quoted 7 lines
lib/efi_loader/testapp.c new file +4
-1+ +/* We should never arrive here */ +return ret; +} --2.43.0
Regards,
SImon
Re: [PATCH v6 09/12] efi_loader: Add a test app
Quoted 139 lines · Simon Glass
Hi Ilias,
Quoted 124 lines · Ilias Apalodimas
Hi Simon,
Quoted 106 lines · Simon Glass
Add a simple app to use for testing. This is intended to do whatever it needs to for testing purposes. For now it just prints a message and exits boot services.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
lib/efi_loader/Kconfig | 10 ++++++ lib/efi_loader/Makefile | 1 + lib/efi_loader/testapp.c | 68 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+)create mode 100644
lib/efi_loader/testapp.clib/efi_loader/Kconfig +10
-0@@ -564,6 +564,16 @@ config BOOTEFI_HELLO_COMPILE No additional space will be required in the resulting U-Boot binary when this option is enabled. +config BOOTEFI_TESTAPP_COMPILE + bool "Compile an EFI test app for testing" + default y + help + This compiles an app designed for testing. It is packed into an image + by the test.py testing frame in the setup_efi_image() function. + + No additional space will be required in the resulting U-Boot binary + when this option is enabled. + endif source "lib/efi/Kconfig"lib/efi_loader/Makefile +1
-0@@ -20,6 +20,7 @@ apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) apps-y += dtbdump endif +apps-$(CONFIG_BOOTEFI_TESTAPP_COMPILE) += testapp obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.olib/efi_loader/testapp.c new file +51
-0@@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Hello world EFI application +* +* Copyright 2024 Google LLC +* Written by Simon Glass <[email protected]> +* +* This test program is used to test the invocation of an EFI application. +* It writes a few messages to the console and then exits boot services +*/ + +#include <efi_api.h> + +static const efi_guid_t loaded_image_guid =EFI_LOADED_IMAGE_PROTOCOL_GUID ; + +static struct efi_system_table *systable; +static struct efi_boot_services *boottime; +static struct efi_simple_text_output_protocol *con_out; + +/** +* efi_main() - entry point of the EFI application. +* +* @handle: handle of the loaded image +* @systab: system table +* Return: status code +*/ +efi_status_t EFIAPI efi_main(efi_handle_t handle, +struct efi_system_table *systab) +{ +struct efi_loaded_image *loaded_image; +efi_status_t ret; +efi_uintn_t map_size; +efi_uintn_t map_key; +efi_uintn_t desc_size; +u32 desc_version; + + systable = systab; + boottime = systable->boottime; + con_out = systable->con_out; + +/* Get the loaded image protocol */ + ret = boottime->open_protocol (handle, &loaded_image_guid, + (void **)&loaded_image,NULL ,NULL , +EFI_OPEN_PROTOCOL_GET_PROTOCOL ); +if (ret !=EFI_SUCCESS ) { + con_out->output_string + (con_out,u"Cannot open loaded image protocol\r\n" ); + goto out; + } + +/* UEFI requires CR LF */ lib/efi_loader/testapp.c line 61
Quoted 10 lines
lib/efi_loader/testapp.c new file +10
-0+ con_out->output_string (con_out,u"U-Boot test app for EFI_LOADER\r\n" ); + +out: + map_size =0 ; + ret = boottime->get_memory_map (&map_size,NULL , &map_key, &desc_size, + &desc_version); + con_out->output_string (con_out,u"Exiting boot sevices\n" ); + +/* exit boot services so that this part of U-Boot can be tested */ + boottime->exit_boot_services (handle, map_key);What Heinrich keeps repeating here, is that after you call EBS, boot services must not be called again.
Quoted 7 lines
lib/efi_loader/testapp.c line 64
Quoted 3 lines
lib/efi_loader/testapp.c new file +3
-0+ +/* now exit for real */ + ret = boottime->exit (handle, ret,0 ,NULL );IOW this is wrong. It might happen to work because not much has run and the memory will still be there. But you certainly should not rely on that
Well, not much has run because it is running the test program. So we know it will be OK.
Quoted 6 lines
One of the challenges we have is that we need to design things for testing, i.e. to make testing easy and practical. The call to
exit()happily returns back to sandbox and all is well. It serves the purpose of the test, which is all the app is wanting to do.So I have to ask, what problem are you seeing?
We write tests to see if our firmware conforms to the UEFI specification. This requires that our tests are conformant.
Please, call the ResetSystem() runtime service here.
I would prefer if you could at least consider suggestions.
Best regards
Heinrich
Quoted 15 lines
Quoted 4 lines
Thanks
Quoted 8 lines
/Ilias
Quoted 7 lines
lib/efi_loader/testapp.c new file +4
-1+ +/* We should never arrive here */ +return ret; +} --2.43.0
Regards,
SImon
Re: [PATCH v6 09/12] efi_loader: Add a test app
Hi Heinrich,
Quoted 146 lines · Heinrich Schuchardt
Quoted 144 lines · Simon Glass
Hi Ilias,
Quoted 124 lines · Ilias Apalodimas
Hi Simon,
Quoted 106 lines · Simon Glass
Add a simple app to use for testing. This is intended to do whatever it needs to for testing purposes. For now it just prints a message and exits boot services.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
lib/efi_loader/Kconfig | 10 ++++++ lib/efi_loader/Makefile | 1 + lib/efi_loader/testapp.c | 68 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+)create mode 100644
lib/efi_loader/testapp.clib/efi_loader/Kconfig +10
-0@@ -564,6 +564,16 @@ config BOOTEFI_HELLO_COMPILE No additional space will be required in the resulting U-Boot binary when this option is enabled. +config BOOTEFI_TESTAPP_COMPILE + bool "Compile an EFI test app for testing" + default y + help + This compiles an app designed for testing. It is packed into an image + by the test.py testing frame in the setup_efi_image() function. + + No additional space will be required in the resulting U-Boot binary + when this option is enabled. + endif source "lib/efi/Kconfig"lib/efi_loader/Makefile +1
-0@@ -20,6 +20,7 @@ apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) apps-y += dtbdump endif +apps-$(CONFIG_BOOTEFI_TESTAPP_COMPILE) += testapp obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.olib/efi_loader/testapp.c new file +51
-0@@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Hello world EFI application +* +* Copyright 2024 Google LLC +* Written by Simon Glass <[email protected]> +* +* This test program is used to test the invocation of an EFI application. +* It writes a few messages to the console and then exits boot services +*/ + +#include <efi_api.h> + +static const efi_guid_t loaded_image_guid =EFI_LOADED_IMAGE_PROTOCOL_GUID ; + +static struct efi_system_table *systable; +static struct efi_boot_services *boottime; +static struct efi_simple_text_output_protocol *con_out; + +/** +* efi_main() - entry point of the EFI application. +* +* @handle: handle of the loaded image +* @systab: system table +* Return: status code +*/ +efi_status_t EFIAPI efi_main(efi_handle_t handle, +struct efi_system_table *systab) +{ +struct efi_loaded_image *loaded_image; +efi_status_t ret; +efi_uintn_t map_size; +efi_uintn_t map_key; +efi_uintn_t desc_size; +u32 desc_version; + + systable = systab; + boottime = systable->boottime; + con_out = systable->con_out; + +/* Get the loaded image protocol */ + ret = boottime->open_protocol (handle, &loaded_image_guid, + (void **)&loaded_image,NULL ,NULL , +EFI_OPEN_PROTOCOL_GET_PROTOCOL ); +if (ret !=EFI_SUCCESS ) { + con_out->output_string + (con_out,u"Cannot open loaded image protocol\r\n" ); + goto out; + } + +/* UEFI requires CR LF */ lib/efi_loader/testapp.c line 61
Quoted 10 lines
lib/efi_loader/testapp.c new file +10
-0+ con_out->output_string (con_out,u"U-Boot test app for EFI_LOADER\r\n" ); + +out: + map_size =0 ; + ret = boottime->get_memory_map (&map_size,NULL , &map_key, &desc_size, + &desc_version); + con_out->output_string (con_out,u"Exiting boot sevices\n" ); + +/* exit boot services so that this part of U-Boot can be tested */ + boottime->exit_boot_services (handle, map_key);What Heinrich keeps repeating here, is that after you call EBS, boot services must not be called again.
Quoted 7 lines
lib/efi_loader/testapp.c line 64
Quoted 3 lines
lib/efi_loader/testapp.c new file +3
-0+ +/* now exit for real */ + ret = boottime->exit (handle, ret,0 ,NULL );IOW this is wrong. It might happen to work because not much has run and the memory will still be there. But you certainly should not rely on that
Well, not much has run because it is running the test program. So we know it will be OK.
One of the challenges we have is that we need to design things for testing, i.e. to make testing easy and practical. The call to
exit()happily returns back to sandbox and all is well. It serves the purpose of the test, which is all the app is wanting to do.
Quoted 8 lines
Quoted 1 line
So I have to ask, what problem are you seeing?
We write tests to see if our firmware conforms to the UEFI specification. This requires that our tests are conformant.
Please, call the
ResetSystem()runtime service here.I would prefer if you could at least consider suggestions.
I have not seen any suggestions about the boottime-exit() prior to this one. Did I miss something? Anyway, I will give it a try.
Reegards,
Simon
PATCH v6 10/12 sandbox: virtio: Disable the sandbox virtio blk device
In reply to Simon GlassThis is not implemented so cannot actually be used to read blocks. Disable it until it is implemented, to avoid causing a hang with EFI, which probes every available BLK device.
Issue: https://source.denx.de/u-boot/u-boot/-/issues/37
---
Changes in v6:
- Drop the patch to disable sandbox virtio blk with EFI
- Add new patch to disable the sandbox virtio blk device
arch/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/Kconfig +2 -1
@@ -212,7 +212,8 @@ config SANDBOX imply VIRTIO_MMIO imply VIRTIO_PCI imply VIRTIO_SANDBOX - imply VIRTIO_BLK + # Re-enable this when fully implemented + # imply VIRTIO_BLK imply VIRTIO_NET imply DM_SOUND imply PCI_SANDBOX_EP
Signature · 1 line
2.43.0
Re: [PATCH v6 10/12] sandbox: virtio: Disable the sandbox virtio blk device
Quoted 6 lines · Simon Glass
This is not implemented so cannot actually be used to read blocks. Disable it until it is implemented, to avoid causing a hang with EFI, which probes every available BLK device.
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
PATCH v6 11/12 test: efi: boot: Set up an image suitable for EFI testing
In reply to Simon GlassCreate a new disk for use with tests, which contains the new 'testapp' EFI app specifically intended for testing the EFI loader.
Attach it to the USB device, since most testing is currently done with mmc.
Initially this image will be used to test the EFI bootmeth.
Fix a stale comment in prep_mmc_bootdev() while we are here.
For now this uses sudo and a compressed fallback file, like all the other bootstd tests. Once this series is in, the patch which moves this to use user-space tools will be cleaned up and re-submitted.
---
(no changes since v1)
arch/sandbox/dts/test.dts | 2 +- test/boot/bootdev.c | 18 +++++++++- test/boot/bootflow.c | 2 +- test/py/tests/bootstd/flash1.img.xz | Bin 0 -> 5016 bytes test/py/tests/test_ut.py | 52 ++++++++++++++++++++++++---- 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 test/py/tests/bootstd/flash1.img.xz
arch/sandbox/dts/test.dts +1 -1
@@ -1507,7 +1507,7 @@ flash-stick@1 { reg = <1>; compatible = "sandbox,usb-flash"; - sandbox,filepath = "testflash1.bin"; + sandbox,filepath = "flash1.img"; }; flash-stick@2 {
test/boot/bootdev.c +17 -1
@@ -212,6 +212,10 @@ static int bootdev_test_order(struct unit_test_state *uts)/* Use the environment variable to override it */ ut_assertok (env_set ("boot_targets" ,"mmc1 mmc2 usb" ));ut_assertok (bootflow_scan_first (NULL ,NULL , &iter,0 , &bflow)); + +/* get the usb device which has a backing file (flash1.img) */ +ut_asserteq (0 ,bootflow_scan_next (&iter, &bflow)); +ut_asserteq (-ENODEV ,bootflow_scan_next (&iter, &bflow));ut_asserteq (5 , iter.num_devs);ut_asserteq_str ("mmc1.bootdev" , iter.dev_used[0 ]->name);
@@ -251,7 +255,11 @@ static int bootdev_test_order(struct unit_test_state *uts)ut_assertok (bootflow_scan_first (NULL ,NULL , &iter,0 , &bflow));ut_asserteq (2 , iter.num_devs); -/* Now scan past mmc1 and make sure that the 3 USB devices show up */ +/* +* Now scan past mmc1 and make sure that the 3 USB devices show up. The +* first one has a backing file so returns success +*/ +ut_asserteq (0 ,bootflow_scan_next (&iter, &bflow));ut_asserteq (-ENODEV ,bootflow_scan_next (&iter, &bflow));ut_asserteq (6 , iter.num_devs);ut_asserteq_str ("mmc2.bootdev" , iter.dev_used[0 ]->name);
@@ -313,6 +321,10 @@ static int bootdev_test_prio(struct unit_test_state *uts)/* 3 MMC and 3 USB bootdevs: MMC should come before USB */ ut_assertok (bootflow_scan_first (NULL ,NULL , &iter,0 , &bflow)); + +/* get the usb device which has a backing file (flash1.img) */ +ut_asserteq (0 ,bootflow_scan_next (&iter, &bflow)); +ut_asserteq (-ENODEV ,bootflow_scan_next (&iter, &bflow));ut_asserteq (6 , iter.num_devs);ut_asserteq_str ("mmc2.bootdev" , iter.dev_used[0 ]->name);
@@ -330,6 +342,10 @@ static int bootdev_test_prio(struct unit_test_state *uts)bootflow_iter_uninit (&iter);ut_assertok (bootflow_scan_first (NULL ,NULL , &iter,BOOTFLOWIF_HUNT , &bflow)); + +/* get the usb device which has a backing file (flash1.img) */ +ut_asserteq (0 ,bootflow_scan_next (&iter, &bflow)); +ut_asserteq (-ENODEV ,bootflow_scan_next (&iter, &bflow));ut_asserteq (7 , iter.num_devs); ut_asserteq_str("usb_mass_storage.lun0.bootdev",
test/boot/bootflow.c +1 -1
@@ -525,7 +525,7 @@ static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev, order[2 ] = mmc_dev; -/* Enable the mmc4 node since we need a second bootflow */ +/* Enable the requested mmc node since we need a second bootflow */ root =oftree_root (oftree_default ()); node =ofnode_find_subnode (root, mmc_dev);ut_assert (ofnode_valid (node));
test/py/tests/bootstd/flash1.img.xz new file binary +0 -0
test/py/tests/test_ut.py +46 -6
95 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v6 12/12 test: efi: boot: Add a test for the efi bootmeth
In reply to Simon GlassAdd 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.
---
Changes in v6:
- Deal with sandbox CONFIG_LOGF_FUNC
- Rebase on -next
- Drop patches previously applied
- Drop mention of helloworld since it is no-longer used by this test
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 | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)
test/boot/bootflow.c +63 -0
@@ -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,62 @@ 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 (); + + 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 );
Signature · 1 line
2.43.0
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
Quoted 9 lines · Simon Glass
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 <[email protected]>
So lets go to the problem point. What asserts here fail due to ANSI escape codes being in the output and needing to be filtered out?
[snip]
Quoted 85 lines
test/boot/bootflow.c +63
-0@@ -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,62 @@ 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 (); + + 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 );
Signature · 1 line
Tom
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
Hi Tom,
Quoted 94 lines · Tom Rini
Quoted 9 lines · Simon Glass
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 <[email protected]>So lets go to the problem point. What asserts here fail due to ANSI escape codes being in the output and needing to be filtered out?
[snip]
Quoted 77 lines
test/boot/bootflow.c +55
-0@@ -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,62 @@ 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 (); + + 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
Quoted 8 lines
test/boot/bootflow.c static int bootflow_android(struct unit_test_state *uts) · line 1270
Quoted 8 lines
test/boot/bootflow.c +8
-0+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 );
Thanks for taking an interest in this.
Nothing at present, as I added ut_assert_skip_to_line() to skip it all. But it really is just wrong...I get gibberish showing up in the terminal after I run tests! This is what I see with this series:
** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi
7 [r [999;999H [6n 8No EFI system partition
^^^ strange output there but I'm not sure if it will come through on email
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
Booting /\EFI\BOOT\BOOTSBOX.EFI
U-Boot test app for EFI_LOADER
Exiting boot sevices
## Application failed, r = 5
Boot failed (err=-22)
Failures: 0
Quoted 3 lines
--
Tom
I just want this applied or some other fix to stop it happening. It doesn't hurt anything and it should not be controversial.
Regards,
Simon
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
Quoted 126 lines · Simon Glass
Hi Tom,
Quoted 94 lines · Tom Rini
Quoted 9 lines · Simon Glass
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 <[email protected]>So lets go to the problem point. What asserts here fail due to ANSI escape codes being in the output and needing to be filtered out?
[snip]
Quoted 77 lines
test/boot/bootflow.c +55
-0@@ -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,62 @@ 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 (); + + 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 Quoted 8 lines
test/boot/bootflow.c static int bootflow_android(struct unit_test_state *uts) · line 1270
Quoted 8 lines
test/boot/bootflow.c +8
-0+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 );Thanks for taking an interest in this.
Nothing at present, as I added
ut_assert_skip_to_line()to skip it all. But it really is just wrong...I get gibberish showing up in the terminal after I run tests! This is what I see with this series:** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi
7 [r [999;999H [6n 8No EFI system partition^^^ strange output there but I'm not sure if it will come through on email
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
Booting /\EFI\BOOT\BOOTSBOX.EFI
U-Boot test app forEFI_LOADER
Quoted 4 lines
Exiting boot sevices
## Application failed, r = 5
Boot failed (err=-22)
Failures: 0
So we're finally making progress I think to see what the problem you're trying to solve is. I think the next thing to figure out is if you use picocom or screen or whatever on console, the codes are handled correctly, or no? Specifically, picocom? Next, is this perhaps just another strange artifact of how oddly (and as you've noted before, slowly) pytest consumes the console input? It feels like maybe we're doing several layers of wrong there? Because to be clear, this is not a sandbox problem. Looking back at the log I had posted about the watchdog reset not counting banners correctly I see that same escape sequence, now that I know what I'm looking for/at.
All of that said, if it's not a pytest-consuming-the-console problem (and it's not a picocom problem, like I was just asking about since the board failure in question was via labgrid-client), maybe it's just a thing to note about making sure tests understand. And perhaps document somewhere why it matters (and I'm not saying it doesn't!) that we know what the dimensions of the console are, for EFI, and so that's why we init them when/where we do.
Signature · 1 line
Tom
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
Am 14. Oktober 2024 05:51:22 MESZ schrieb Tom Rini <[email protected]>:
Quoted 109 lines · Simon Glass
Quoted 108 lines
Hi Tom,
Quoted 94 lines · Tom Rini
Quoted 9 lines · Simon Glass
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 <[email protected]>So lets go to the problem point. What asserts here fail due to ANSI escape codes being in the output and needing to be filtered out?
[snip]
Quoted 77 lines
test/boot/bootflow.c +55
-0@@ -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,62 @@ 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 (); + + 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 Quoted 8 lines
test/boot/bootflow.c static int bootflow_android(struct unit_test_state *uts) · line 1270
Quoted 8 lines
test/boot/bootflow.c +8
-0+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 );Thanks for taking an interest in this.
Quoted 8 lines
Quoted 8 lines
Nothing at present, as I added
ut_assert_skip_to_line()to skip it all. But it really is just wrong...I get gibberish showing up in the terminal after I run tests! This is what I see with this series:** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi
7 [r [999;999H [6n 8No EFI system partition^^^ strange output there but I'm not sure if it will come through on email
It seems you are not providing a video console. So the EFI sub-system is asking the serial console for its size in query_console_serial().
Set CONFIG_VIDEO=y and let vidconsole be your first output device to avoid query_console_serial() being called.
Best regards
Heinrich
Quoted 34 lines
Quoted 10 lines
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
Booting /\EFI\BOOT\BOOTSBOX.EFI
U-Boot test app forEFI_LOADERQuoted 4 lines
Exiting boot sevices
## Application failed, r = 5
Boot failed (err=-22)
Failures: 0So we're finally making progress I think to see what the problem you're trying to solve is. I think the next thing to figure out is if you use picocom or screen or whatever on console, the codes are handled correctly, or no? Specifically, picocom? Next, is this perhaps just another strange artifact of how oddly (and as you've noted before, slowly) pytest consumes the console input? It feels like maybe we're doing several layers of wrong there? Because to be clear, this is not a sandbox problem. Looking back at the log I had posted about the watchdog reset not counting banners correctly I see that same escape sequence, now that I know what I'm looking for/at.
All of that said, if it's not a pytest-consuming-the-console problem (and it's not a picocom problem, like I was just asking about since the board failure in question was via labgrid-client), maybe it's just a thing to note about making sure tests understand. And perhaps document somewhere why it matters (and I'm not saying it doesn't!) that we know what the dimensions of the console are, for EFI, and so that's why we init them when/where we do.
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
Quoted 116 lines · Heinrich Schuchardt
Am 14. Oktober 2024 05:51:22 MESZ schrieb Tom Rini <[email protected]>:
Quoted 113 lines · Simon Glass
Quoted 112 lines
Hi Tom,
Quoted 94 lines · Tom Rini
Quoted 9 lines · Simon Glass
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 <[email protected]>So lets go to the problem point. What asserts here fail due to ANSI escape codes being in the output and needing to be filtered out?
[snip]
Quoted 77 lines
test/boot/bootflow.c +55
-0@@ -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,62 @@ 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 (); + + 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 Quoted 8 lines
test/boot/bootflow.c static int bootflow_android(struct unit_test_state *uts) · line 1270
Quoted 8 lines
test/boot/bootflow.c +8
-0+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 );Thanks for taking an interest in this.
Nothing at present, as I added
ut_assert_skip_to_line()to skip it all. But it really is just wrong...I get gibberish showing up in the terminal after I run tests! This is what I see with this series:
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi
7 [r [999;999H [6n 8No EFI system partition^^^ strange output there but I'm not sure if it will come through on email
It seems you are not providing a video console. So the EFI sub-system is asking the serial console for its size in
query_console_serial().Set
CONFIG_VIDEO=yand let vidconsole be your first output device to avoidquery_console_serial()being called.
That's not an answer to the problem. Please note that rpi_arm64_defconfig shows this same issue, and it's about being able to run tests on hardware and parse the output reasonably. And so:
Quoted 38 lines
Best regards
Heinrich
Quoted 33 lines
Quoted 10 lines
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
Booting /\EFI\BOOT\BOOTSBOX.EFI
U-Boot test app forEFI_LOADERQuoted 4 lines
Exiting boot sevices
## Application failed, r = 5
Boot failed (err=-22)
Failures: 0So we're finally making progress I think to see what the problem you're trying to solve is. I think the next thing to figure out is if you use picocom or screen or whatever on console, the codes are handled correctly, or no? Specifically, picocom? Next, is this perhaps just another strange artifact of how oddly (and as you've noted before, slowly) pytest consumes the console input? It feels like maybe we're doing several layers of wrong there? Because to be clear, this is not a sandbox problem. Looking back at the log I had posted about the watchdog reset not counting banners correctly I see that same escape sequence, now that I know what I'm looking for/at.
All of that said, if it's not a pytest-consuming-the-console problem (and it's not a picocom problem, like I was just asking about since the board failure in question was via labgrid-client), maybe it's just a thing to note about making sure tests understand. And perhaps document somewhere why it matters (and I'm not saying it doesn't!) that we know what the dimensions of the console are, for EFI, and so that's why we init them when/where we do.
My last question here was to you or Ilias, thanks.
Signature · 1 line
Tom
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
In reply to Tom RiniHi Tom,
Quoted 133 lines · Tom Rini
Quoted 126 lines · Simon Glass
Hi Tom,
Quoted 94 lines · Tom Rini
Quoted 9 lines · Simon Glass
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 <[email protected]>So lets go to the problem point. What asserts here fail due to ANSI escape codes being in the output and needing to be filtered out?
[snip]
Quoted 77 lines
test/boot/bootflow.c +55
-0@@ -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,62 @@ 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 (); + + 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 Quoted 8 lines
test/boot/bootflow.c static int bootflow_android(struct unit_test_state *uts) · line 1270
Quoted 8 lines
test/boot/bootflow.c +8
-0+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 );Thanks for taking an interest in this.
Nothing at present, as I added
ut_assert_skip_to_line()to skip it all. But it really is just wrong...I get gibberish showing up in the terminal after I run tests! This is what I see with this series:** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi
7 [r [999;999H [6n 8No EFI system partition^^^ strange output there but I'm not sure if it will come through on email
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
Booting /\EFI\BOOT\BOOTSBOX.EFI
U-Boot test app forEFI_LOADERQuoted 4 lines
Exiting boot sevices
## Application failed, r = 5
Boot failed (err=-22)
Failures: 0
Quoted 4 lines
So we're finally making progress I think to see what the problem you're trying to solve is. I think the next thing to figure out is if you use picocom or screen or whatever on console, the codes are handled correctly, or no? Specifically, picocom?
This is my running tests on my normal machine in a terminal. So it is just a sandbox connection, with no picocom, etc. See the Spawn class in test/py
Quoted 4 lines
Next, is this perhaps just
another strange artifact of how oddly (and as you've noted before, slowly) pytest consumes the console input? It feels like maybe we're doing several layers of wrong there?
Well to be frank I would have just applied my ANSI patch some months ago and stopped worrying about it. We just shouldn't be sending ANSI characters unless we know there is a terminal there. See Color() in tools/u_boot_pylib/terminal.py
But even if we did want to blindly send characters, we should have a way to turn it off.
Quoted 4 lines
Because to be clear, this is not a
sandbox problem. Looking back at the log I had posted about the watchdog reset not counting banners correctly I see that same escape sequence, now that I know what I'm looking for/at.
I see it all over CI as well. We also have [1].
Quoted 8 lines
All of that said, if it's not a pytest-consuming-the-console problem (and it's not a picocom problem, like I was just asking about since the board failure in question was via labgrid-client), maybe it's just a thing to note about making sure tests understand. And perhaps document somewhere why it matters (and I'm not saying it doesn't!) that we know what the dimensions of the console are, for EFI, and so that's why we init them when/where we do.
Or perhaps just have a way to turn it off? I first sent this patch last November. It is just wrong to generate output like this which we don't want. There isn't even a test for it, so just add a way to disable it, and be done!
Regards,
SImon
[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
On Mon, Oct 14, 2024 at 01:13:41PM -0600, Simon Glass wrote:
[snip]
Quoted 4 lines
Or perhaps just have a way to turn it off? I first sent this patch last November. It is just wrong to generate output like this which we don't want. There isn't even a test for it, so just add a way to disable it, and be done!
I don't know that it's unwanted. As I'm trying to get Heinrich to explain, _why_ does efi_setup_console_size need to exist, and do what it does? This isn't the case of color-coding the output of tests as they happen, there must be a reason we care about knowing the console size. At that point we can figure out if the right answer is:
- Don't generate that check on serial ports, it's somewhere between misleading to wrong.
- text-based tests just need to expect and skip it because there's a good reason to need to know the console size and not just assume 80x24.
- Something else we won't know until it's clearly explained why we do this.
Signature · 1 line
Tom
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
Quoted 11 lines
Date: Mon, 14 Oct 2024 15:11:50 -0600
From: Tom Rini <[email protected]>On Mon, Oct 14, 2024 at 01:13:41PM -0600, Simon Glass wrote:
[snip]
Quoted 4 lines
Or perhaps just have a way to turn it off? I first sent this patch last November. It is just wrong to generate output like this which we don't want. There isn't even a test for it, so just add a way to disable it, and be done!
Quoted 12 lines
I don't know that it's unwanted. As I'm trying to get Heinrich to explain, _why_ does
efi_setup_console_sizeneed to exist, and do what it does? This isn't the case of color-coding the output of tests as they happen, there must be a reason we care about knowing the console size. At that point we can figure out if the right answer is:
- Don't generate that check on serial ports, it's somewhere between misleading to wrong.
- text-based tests just need to expect and skip it because there's a good reason to need to know the console size and not just assume 80x24.
- Something else we won't know until it's clearly explained why we do this.
Sadly this is a misfeature of UEFI. The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is required if console devices are supported by the UEFI implementation, and is built around the concept of "text mode" with a fixed number of character rows and columns. That pretty much assumes there is some sort of terminal emulator on the other end. And this is pretty much incompatible with anything that just want to log serial output.
I think it is possible to do better though. Instead of calling efi_setup_console_size() in efi_init_obj_list(), we could postpone this until the application makes a call that requires us to know the size. This would mean that a simple EFI application that just uses EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString() (such as the Hello world EFI application or the OpenBSD EFI bootloader) wouldn't have to do the size query.
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
Quoted 32 lines · Mark Kettenis
Quoted 11 lines
Date: Mon, 14 Oct 2024 15:11:50 -0600
From: Tom Rini <[email protected]>On Mon, Oct 14, 2024 at 01:13:41PM -0600, Simon Glass wrote:
[snip]
Quoted 4 lines
Or perhaps just have a way to turn it off? I first sent this patch last November. It is just wrong to generate output like this which we don't want. There isn't even a test for it, so just add a way to disable it, and be done!
Quoted 12 lines
I don't know that it's unwanted. As I'm trying to get Heinrich to explain, _why_ does
efi_setup_console_sizeneed to exist, and do what it does? This isn't the case of color-coding the output of tests as they happen, there must be a reason we care about knowing the console size. At that point we can figure out if the right answer is:
- Don't generate that check on serial ports, it's somewhere between misleading to wrong.
- text-based tests just need to expect and skip it because there's a good reason to need to know the console size and not just assume 80x24.
- Something else we won't know until it's clearly explained why we do this.Sadly this is a misfeature of UEFI. The
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLis required if console devices are supported by the UEFI implementation, and is built around the concept of "text mode" with a fixed number of character rows and columns. That pretty much assumes there is some sort of terminal emulator on the other end. And this is pretty much incompatible with anything that just want to log serial output.
Quoted 7 lines
I think it is possible to do better though. Instead of calling
efi_setup_console_size()inefi_init_obj_list(), we could postpone this until the application makes a call that requires us to know the size. This would mean that a simple EFI application that just usesEFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString()(such as the Hello world EFI application or the OpenBSD EFI bootloader) wouldn't have to do the size query.
The implementation of EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString() needs to know the output size to update the cursor position in
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.MODE.CursorColumn EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.MODE.CursorRow
The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is passed to the entry point of any EFI application via the system table.
We could delay the invocation of efi_setup_console_size() to the launch of the first EFI application (efi_start_image()).
Best regards
Heinrich
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
Hi Heinrich,
Quoted 45 lines · Heinrich Schuchardt
Quoted 32 lines · Mark Kettenis
Quoted 11 lines
Date: Mon, 14 Oct 2024 15:11:50 -0600
From: Tom Rini <[email protected]>On Mon, Oct 14, 2024 at 01:13:41PM -0600, Simon Glass wrote:
[snip]
Quoted 4 lines
Or perhaps just have a way to turn it off? I first sent this patch last November. It is just wrong to generate output like this which we don't want. There isn't even a test for it, so just add a way to disable it, and be done!
Quoted 12 lines
I don't know that it's unwanted. As I'm trying to get Heinrich to explain, _why_ does
efi_setup_console_sizeneed to exist, and do what it does? This isn't the case of color-coding the output of tests as they happen, there must be a reason we care about knowing the console size. At that point we can figure out if the right answer is:
- Don't generate that check on serial ports, it's somewhere between misleading to wrong.
- text-based tests just need to expect and skip it because there's a good reason to need to know the console size and not just assume 80x24.
- Something else we won't know until it's clearly explained why we do this.Sadly this is a misfeature of UEFI. The
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLis required if console devices are supported by the UEFI implementation, and is built around the concept of "text mode" with a fixed number of character rows and columns. That pretty much assumes there is some sort of terminal emulator on the other end. And this is pretty much incompatible with anything that just want to log serial output.Quoted 7 lines
I think it is possible to do better though. Instead of calling
efi_setup_console_size()inefi_init_obj_list(), we could postpone this until the application makes a call that requires us to know the size. This would mean that a simple EFI application that just usesEFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString()(such as the Hello world EFI application or the OpenBSD EFI bootloader) wouldn't have to do the size query.The implementation of
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString()needs to know the output size to update the cursor position in
Quoted 8 lines
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.MODE.CursorColumn EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.MODE.CursorRow
The
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLis passed to the entry point of any EFI application via the system table.We could delay the invocation of
efi_setup_console_size()to the launch of the first EFI application (efi_start_image()).
That's a start, but I think the right answer here is to use my flag and in efi_setup_console_size() don't call query_console_serial() if the flag is set. Then the default (80x25) will be returned, which is fine for the test which is the subject of this series.
Regards,
Simon
Re: [PATCH v6 12/12] test: efi: boot: Add a test for the efi bootmeth
Quoted 56 lines · Simon Glass
Hi Heinrich,
Quoted 53 lines · Heinrich Schuchardt
Quoted 32 lines · Mark Kettenis
Quoted 11 lines
Date: Mon, 14 Oct 2024 15:11:50 -0600
From: Tom Rini <[email protected]>On Mon, Oct 14, 2024 at 01:13:41PM -0600, Simon Glass wrote:
[snip]
Quoted 4 lines
Or perhaps just have a way to turn it off? I first sent this patch last November. It is just wrong to generate output like this which we don't want. There isn't even a test for it, so just add a way to disable it, and be done!
Quoted 12 lines
I don't know that it's unwanted. As I'm trying to get Heinrich to explain, _why_ does
efi_setup_console_sizeneed to exist, and do what it does? This isn't the case of color-coding the output of tests as they happen, there must be a reason we care about knowing the console size. At that point we can figure out if the right answer is:
- Don't generate that check on serial ports, it's somewhere between misleading to wrong.
- text-based tests just need to expect and skip it because there's a good reason to need to know the console size and not just assume 80x24.
- Something else we won't know until it's clearly explained why we do this.Sadly this is a misfeature of UEFI. The
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLis required if console devices are supported by the UEFI implementation, and is built around the concept of "text mode" with a fixed number of character rows and columns. That pretty much assumes there is some sort of terminal emulator on the other end. And this is pretty much incompatible with anything that just want to log serial output.Quoted 7 lines
I think it is possible to do better though. Instead of calling
efi_setup_console_size()inefi_init_obj_list(), we could postpone this until the application makes a call that requires us to know the size. This would mean that a simple EFI application that just usesEFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString()(such as the Hello world EFI application or the OpenBSD EFI bootloader) wouldn't have to do the size query.The implementation of
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString()needs to know the output size to update the cursor position inEFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.MODE.CursorColumn EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.MODE.CursorRow
The
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLis passed to the entry point of any EFI application via the system table.We could delay the invocation of
efi_setup_console_size()to the launch of the first EFI application (efi_start_image()).
This discussion I believe should continue as it does sound like we can be a bit better about when we do this required series of events.
Quoted 4 lines
That's a start, but I think the right answer here is to use my flag and in
efi_setup_console_size()don't callquery_console_serial()if the flag is set. Then the default (80x25) will be returned, which is fine for the test which is the subject of this series.
No, your series, like other tests that already exist and have this escape code printed, should just swallow the escape sequence if it shows up because, sadly, there is reason for it. I wonder if we should have some test _for_ this sequence, or otherwise make sure we see it when we should see it?
Signature · 1 line
Tom