[PATCH 7/8] efi_selftest: Add box drawing character selftest

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Mon Jan 10 10:23:20 CET 2022


On 1/10/22 01:56, Andre Przywara wrote:
> UEFI applications rely on Unicode output capability, and might use that
> for drawing pseudo-graphical interfaces using Unicode defined box
> drawing characters.
> 
> Add a simple test to display the most basic box characters, which would
> need to be checked manually on the screen for correctness.
> To facilitate this, add a three second delay after the output at this
> point.
> 
> Signed-off-by: Andre Przywara <andre.przywara at arm.com>
> ---
>   lib/efi_selftest/efi_selftest_textoutput.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/lib/efi_selftest/efi_selftest_textoutput.c b/lib/efi_selftest/efi_selftest_textoutput.c
> index a437732496b..1542c187de7 100644
> --- a/lib/efi_selftest/efi_selftest_textoutput.c
> +++ b/lib/efi_selftest/efi_selftest_textoutput.c
> @@ -123,6 +123,17 @@ static int execute(void)
>   		efi_st_error("OutputString failed for international chars\n");
>   		return EFI_ST_FAILURE;
>   	}
> +	ret  = con_out->output_string(con_out, L"┌─┬─┐\n");
> +	ret |= con_out->output_string(con_out, L"│ │ │\n");
> +	ret |= con_out->output_string(con_out, L"├─┼─┤\n");
> +	ret |= con_out->output_string(con_out, L"│ │ │\n");
> +	ret |= con_out->output_string(con_out, L"└─┴─┘\n");

%s/L"/u"/

Unicode characters in code are not supported by all tools. The 
interpretation may further depend on the users locale. Please, use \u 
escape sequences. A single output_string() call is enough. A notice for 
the user might be helpful. So I suggest:

This should render as four boxes with text
┌─────────────┬───────────────┐
│ left top    │ right top     │
├─────────────┼───────────────┤
│ left bottom │ right bottom  │
└─────────────┴───────────────┘

const u16 text[] =
u"This should render as four boxes with text\n"
u"\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
u"\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
u"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502"
u" left top    \u2502 right top     \u2502\n\u251c\u2500"
u"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
u"\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
u"\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 "
u"left bottom \u2502 right bottom  \u2502\n\u2514\u2500\u2500\u2500"
u"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534"
u"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
u"\u2500\u2500\u2500\u2500\u2518\n";

Best regards

Heinrich

> +	if (ret != EFI_ST_SUCCESS) {
> +		efi_st_error("OutputString failed for box drawing chars\n");
> +		return EFI_ST_FAILURE;
> +	}
> +	con_out->output_string(con_out, L"waiting for admiration...\n");
> +	EFI_CALL(systab.boottime->stall(3000000));
>   	efi_st_printf("\n");
>   
>   	return EFI_ST_SUCCESS;



More information about the U-Boot mailing list