bootstd: Add a return code to bootflow menu

Return an error when the user does not select an OS, so we know whether
to boot or not.

Move calling of bootflow_menu_run() into a separate function so we can
call it from other places.

Expand the test to cover these cases.

Add some documentation also, while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2023-10-01 19:14:38 -06:00
parent baea7ec6a6
commit 3fa53b9531
3 changed files with 123 additions and 12 deletions

View File

@@ -604,8 +604,12 @@ static int scan_mmc4_bootdev(struct unit_test_state *uts)
/* Check 'bootflow menu' to select a bootflow */
static int bootflow_cmd_menu(struct unit_test_state *uts)
{
struct bootstd_priv *std;
char prev[3];
/* get access to the current bootflow */
ut_assertok(bootstd_get_priv(&std));
ut_assertok(scan_mmc4_bootdev(uts));
/* Add keypresses to move to and select the second one in the list */
@@ -616,6 +620,17 @@ static int bootflow_cmd_menu(struct unit_test_state *uts)
ut_assertok(run_command("bootflow menu", 0));
ut_assert_nextline("Selected: Armbian");
ut_assertnonnull(std->cur_bootflow);
ut_assert_console_end();
/* Check not selecting anything */
prev[0] = '\e';
prev[1] = '\0';
ut_asserteq(1, console_in_puts(prev));
ut_asserteq(1, run_command("bootflow menu", 0));
ut_assertnull(std->cur_bootflow);
ut_assert_nextline("Nothing chosen");
ut_assert_console_end();
return 0;