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

32
test/cmd/bootstage.c Normal file
View File

@@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Tests for bootstage command
*
* Copyright 2025 Canonical Ltd
*/
#include <bootstage.h>
#include <test/cmd.h>
#include <test/ut.h>
static int cmd_bootstage_report(struct unit_test_state *uts)
{
uint count;
/* Get the current record count */
count = bootstage_get_rec_count();
ut_assert(count > 0);
/* Test the bootstage report command runs successfully */
ut_assertok(run_command("bootstage report", 0));
/* Verify the report contains expected headers and stages */
ut_assert_nextline("Timer summary in microseconds (%u records):",
count);
ut_assert_nextline(" Mark Elapsed Stage");
ut_assert_nextline(" 0 0 reset");
ut_assert_skip_to_line("Accumulated time:");
return 0;
}
CMD_TEST(cmd_bootstage_report, UTF_CONSOLE);