Re: [PATCH v6 08/12] efi_loader: Disable ANSI output for tests

Heinrich Schuchardt
2024-10-01T02:35:08Z

On 10/1/24 02:24, Tom Rini wrote:
> On Tue, Oct 01, 2024 at 01:38:56AM +0200, Heinrich Schuchardt wrote:
>> On 26.09.24 23:59, Simon Glass wrote:
>>> 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.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>
>> Please, consider prior review before resubmitting patches.
>>
>> As responded to all prior submissions:
>>
>> We want to test the code running on actual machines.
>> We don't want to have sandbox code everywhere.
>>
>> I cannot see any test that is not passing due to the current behavior.
>
> The pytests for the EFI selftests are unreliable for me, on Raspberry Pi
> 3, more often in 32bit mode than 64bit mode, but I feel like I see it
> there too. And when they fail, the console log is full of ANSI escape
> sequences. Is this specific test a test you run regularly on real
> hardware?
>

It is not only the EFI test but also pytest adding color to the console
output.

When I download a raw LOG and display it with

wget
https://source.denx.de/u-boot/custodians/u-boot-efi/-/jobs/904222/raw
less -r raw

I see the correct colored output. Same when I run

cat raw

If you want to strip ANSI codes from a file, you can use ansi2txt from
Ubuntu package colorized logs.

ansi2txt < raw > flat.log

I typically run UEFI tests interactively on the sandbox, virtual
machines, and on actual hardware.

lib/efi_selftest/efi_selftest_textoutput.c is specifically used to print
out all combinations of fore- and background colors.

Furthermore color is used in /lib/efi_selftest/ for:

* start of test
* success, warning, error

This coloring is not functionally necessary but for my taste makes the
output easier to read.

test/py/tests/test_efi_selftest.py just has no problems with the color
output when running:

if u_boot_console.p.expect(['Summary: 0 failures', 'Press any key']):

While color output in UEFI unit tests as said is not functionally
necessary in most tests, the current patch tries to suppress ANSI output
which is functionally necessary and which probably should be tested for.

Best regards

Heinrich