bootstage: Add some more tests

There is already a Python test. Add a few C tests as well, for bootstage
itself and for the 'bootstage' command.

Add helpers to access the internal state. Be careful to zero records
when removing them, since if the record is later reused, bootstage
expects the time to be zero.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-10-23 06:00:21 +01:00
parent dbdd6fda44
commit 5094bffc50
6 changed files with 295 additions and 0 deletions

View File

@@ -212,6 +212,43 @@ uint32_t bootstage_accum(enum bootstage_id id)
return duration;
}
uint bootstage_get_rec_count(void)
{
struct bootstage_data *data = gd->bootstage;
if (!data)
return 0;
return data->rec_count;
}
const struct bootstage_record *bootstage_get_rec(uint index)
{
struct bootstage_data *data = gd->bootstage;
if (!data || index >= data->rec_count)
return NULL;
return &data->record[index];
}
void bootstage_set_rec_count(uint count)
{
struct bootstage_data *data = gd->bootstage;
uint i;
if (!data || count > RECORD_COUNT)
return;
/* Clear any records beyond the new count */
for (i = count; i < data->rec_count; i++) {
data->record[i].time_us = 0;
data->record[i].start_us = 0;
}
data->rec_count = count;
}
/**
* Get a record name as a printable string
*