Hi Simon,

On 28/10/2026 09:25, Simon Glass wrote:
> Hi Jerome,
> 
> On 2026-10-27T16:02:12, Jerome Forissier <[email protected]> wrote:
>> test: Add helpers to preserve console silence state
>>
>> Some tests intentionally trigger diagnostics that the Python console
>> parser treats as unexpected errors.
>>
>> Add helpers that silence these diagnostics while preserving the previous
>> console state, allowing tests to hide expected errors without accessing
>> global data directly.
>>
>> Signed-off-by: Jerome Forissier <[email protected]>
>>
>>  include/test/ut.h | 17 +++++++++++++++++
>>  test/ut.c         | 15 +++++++++++++++
>>  2 files changed, 32 insertions(+)
> 
>> diff --git a/include/test/ut.h b/include/test/ut.h
>> @@ -549,6 +549,23 @@ long ut_check_delta(ulong last);
>> +/**
>> + * ut_silence_console_force() - Unconditionally silence the console
>> + *
>> + * This silences the console even when U-Boot is started with the sandbox -v
>> + * option.
>> + *
>> + * Return: true if the console was already silent
>> + */
>> +bool ut_silence_console_force(void);
> 
> My understanding is that you need the 'force' variant because test/py
> always starts sandbox with -v (see console_sandbox.py), so
> ut_silence_console() never takes effect under pytest.

Correct.
> The downside is that it also hides the output when someone runs the
> test by hand with -v to debug it, which is exactly when they want to
> see it!

Not a good thing indeed ;)

> Expected errors are normally handled on the Python side with
> ubman.disable_check(),  or the test avoids printing a line that matches
> a bad pattern.

In fact I'd rather adjust the test framework than the C code. Ideally the
implementation should not need to know it is being run under a test
framework. Thanks for pointing me to ubman.disable_check(), I like this
option. I will update the failing tests with a small exception in
test_ut().

Therefore this patch can be dropped.

Thanks,
-- 
Jerome> If the C test must stay quiet, it would be worth
> checking the expected output with console recording and
> ut_assert_nextline(), since recording still works while the console is
> silent.
> 
> If we really need this, it might be better to change the signature of
> the existing ut_silence_console() and ut_unsilence_console() rather
> than adding a second pair alongside them. What do you think?
>
> Regards,
> Simon

Reply via email to