test: Show the required size when console-record overflows

When the console-record buffer overflows, show both the current buffer
size and the size needed. This helps the user know what value to set
for CONFIG_CONSOLE_RECORD_OUT_SIZE.

Add a console_out_ovf field to global_data to track the number of bytes
that could not be written due to overflow.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2025-12-08 15:11:40 -07:00
parent 8f8c862a7a
commit c17d68b0fb
3 changed files with 38 additions and 7 deletions

View File

@@ -36,21 +36,26 @@ static void console_record_putc(const char c)
{
if (!(gd->flags & GD_FLG_RECORD))
return;
if (gd->console_out.start &&
!membuf_putbyte((struct membuf *)&gd->console_out, c))
if (gd->console_out.start &&
!membuf_putbyte((struct membuf *)&gd->console_out, c)) {
gd->flags |= GD_FLG_RECORD_OVF;
gd->console_out_ovf++;
}
}
static void console_record_puts(const char *s)
{
if (!(gd->flags & GD_FLG_RECORD))
return;
if (gd->console_out.start) {
if (gd->console_out.start) {
int len = strlen(s);
int written;
if (membuf_put((struct membuf *)&gd->console_out, s, len) !=
len)
written = membuf_put((struct membuf *)&gd->console_out, s, len);
if (written != len) {
gd->flags |= GD_FLG_RECORD_OVF;
gd->console_out_ovf += len - written;
}
}
}
@@ -893,6 +898,7 @@ void console_record_reset(void)
membuf_purge((struct membuf *)&gd->console_out);
membuf_purge((struct membuf *)&gd->console_in);
gd->flags &= ~GD_FLG_RECORD_OVF;
gd->console_out_ovf = 0;
}
int console_record_reset_enable(void)