From 50fa4408ada6b891ce77de2879ea0bd7f875787f Mon Sep 17 00:00:00 2001 From: edisonhello Date: Mon, 16 Aug 2021 15:51:23 +0800 Subject: vboot/ui: Remove manual recovery and related screen This CL is a part of centralizing ui codes. The removed screens and unit tests will be added in depthcharge. Remove manual recovery menu and its action function. Remove recovery select, recovery phone step *, recovery disk step *, recovery invalid screens. Add vb2ex_manual_recovery_ui declaration. Remove unit tests of above screens, menu and actions. BUG=b:172339016 TEST=Hayato booted into developer mode TEST=Hayato showed manual recovery screen TEST=export CC=x86_64-pc-linux-gnu-clang DEBUG=1 DETACHABLE=0; \ make -j test_setup && make -j runtests TEST=export CC=x86_64-pc-linux-gnu-clang DEBUG=1 DETACHABLE=1; \ make -j test_setup && make -j runtests BRANCH=none Cq-Depend: chromium:3099529 Signed-off-by: edisonhello Change-Id: I330098200d45d094d4faab90b96355b5b19e3fea Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3116108 Reviewed-by: Julius Werner Reviewed-by: Yu-Ping Wu --- tests/vb2_ui_action_tests.c | 71 ----- tests/vb2_ui_tests.c | 581 ---------------------------------------- tests/vboot_api_kernel4_tests.c | 2 +- 3 files changed, 1 insertion(+), 653 deletions(-) (limited to 'tests') diff --git a/tests/vb2_ui_action_tests.c b/tests/vb2_ui_action_tests.c index 8c6b7421..70ca23af 100644 --- a/tests/vb2_ui_action_tests.c +++ b/tests/vb2_ui_action_tests.c @@ -231,13 +231,6 @@ static void add_mock_keypress(uint32_t press) add_mock_key(press, 0); } - -static void set_mock_vbtlk(vb2_error_t retval, uint32_t disk_flags) -{ - mock_vbtlk_retval = retval; - mock_vbtlk_expected_flag = disk_flags; -} - static void displayed_eq(const char *text, enum vb2_screen screen, uint32_t locale_id, @@ -795,67 +788,6 @@ static void vb2_ui_developer_mode_boot_altfw_action_tests(void) VB2_DEBUG("...done.\n"); } -static void manual_recovery_action_tests(void) -{ - VB2_DEBUG("Testing manual recovery action...\n"); - - /* SUCCESS */ - reset_common_data(); - set_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(manual_recovery_action(&mock_ui_context), VB2_REQUEST_UI_EXIT, - "EXIT"); - TEST_EQ(mock_get_screen_info_called, 0, " no change_screen"); - - /* NO_DISK_FOUND */ - reset_common_data(); - set_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(manual_recovery_action(&mock_ui_context), - VB2_REQUEST_UI_CONTINUE, "NO_DISK_FOUND"); - screen_state_eq(mock_ui_context.state, VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE); - - /* NO_DISK_FOUND -> INVALID_KERNEL -> SUCCESS */ - reset_common_data(); - set_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(manual_recovery_action(&mock_ui_context), - VB2_REQUEST_UI_CONTINUE, "NO_DISK_FOUND"); - set_mock_vbtlk(VB2_ERROR_LK_INVALID_KERNEL_FOUND, - VB_DISK_FLAG_REMOVABLE); - TEST_EQ(manual_recovery_action(&mock_ui_context), - VB2_REQUEST_UI_CONTINUE, "INVALID_KERNEL"); - set_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(manual_recovery_action(&mock_ui_context), VB2_REQUEST_UI_EXIT, - "EXIT"); - screen_state_eq(mock_ui_context.state, VB2_SCREEN_RECOVERY_INVALID, - MOCK_IGNORE, MOCK_IGNORE); - - /* INVALID_KERNEL */ - reset_common_data(); - set_mock_vbtlk(VB2_ERROR_LK_INVALID_KERNEL_FOUND, - VB_DISK_FLAG_REMOVABLE); - TEST_EQ(manual_recovery_action(&mock_ui_context), - VB2_REQUEST_UI_CONTINUE, "INVALID_KERNEL"); - screen_state_eq(mock_ui_context.state, VB2_SCREEN_RECOVERY_INVALID, - MOCK_IGNORE, MOCK_IGNORE); - - /* INVALID_KERNEL -> NO_DISK_FOUND -> SUCCESS */ - reset_common_data(); - set_mock_vbtlk(VB2_ERROR_LK_INVALID_KERNEL_FOUND, - VB_DISK_FLAG_REMOVABLE); - TEST_EQ(manual_recovery_action(&mock_ui_context), - VB2_REQUEST_UI_CONTINUE, "INVALID_KERNEL"); - set_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(manual_recovery_action(&mock_ui_context), - VB2_REQUEST_UI_CONTINUE, "NO_DISK_FOUND"); - set_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(manual_recovery_action(&mock_ui_context), VB2_REQUEST_UI_EXIT, - "EXIT"); - screen_state_eq(mock_ui_context.state, VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE); - - VB2_DEBUG("...done.\n"); -} - static void ui_loop_tests(void) { int i; @@ -1060,9 +992,6 @@ int main(void) /* Screen actions */ vb2_ui_developer_mode_boot_altfw_action_tests(); - /* Global actions */ - manual_recovery_action_tests(); - /* Core UI loop */ ui_loop_tests(); ui_loop_delay_tests(); diff --git a/tests/vb2_ui_tests.c b/tests/vb2_ui_tests.c index 8790e75d..2eaae0c3 100644 --- a/tests/vb2_ui_tests.c +++ b/tests/vb2_ui_tests.c @@ -804,278 +804,6 @@ static void developer_tests(void) VB2_DEBUG("...done.\n"); } -static void manual_recovery_tests(void) -{ - VB2_DEBUG("Testing manual recovery mode...\n"); - - /* Timeout, shutdown */ - reset_common_data(FOR_MANUAL_RECOVERY); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "timeout, shutdown"); - TEST_EQ(mock_displayed_count, 1, " root screen only"); - - /* Power button short pressed = shutdown request */ - if (!DETACHABLE) { - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_keypress(VB_BUTTON_POWER_SHORT_PRESS); - TEST_EQ(vb2_manual_recovery_menu(ctx), - VB2_REQUEST_SHUTDOWN, - "power button short pressed = shutdown"); - } - - /* Boots if we have a valid image on first try */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_REMOVABLE); - add_mock_vbtlk(VB2_ERROR_MOCK, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_SUCCESS, - "boots if valid on first try"); - - /* Boots eventually if we get a valid image later */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_REMOVABLE); - add_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_REMOVABLE); - add_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_REMOVABLE); - add_mock_vbtlk(VB2_ERROR_MOCK, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_SUCCESS, - "boots after valid image appears"); - - /* Invalid image, then remove, then valid image */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_vbtlk(VB2_ERROR_MOCK, VB_DISK_FLAG_REMOVABLE); - add_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_REMOVABLE); - add_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_REMOVABLE); - add_mock_vbtlk(VB2_SUCCESS, VB_DISK_FLAG_REMOVABLE); - add_mock_vbtlk(VB2_ERROR_MOCK, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_SUCCESS, - "boots after valid image appears"); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - DISPLAYED_EQ("recovery invalid", VB2_SCREEN_RECOVERY_INVALID, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - /* Ctrl+D = to_dev; space = cancel */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_key(VB_KEY_CTRL('D'), 1); - add_mock_keypress(' '); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "ctrl+d = to_dev; space = cancel"); - TEST_EQ(mock_enable_dev_mode, 0, " dev mode not enabled"); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - DISPLAYED_EQ("to_dev", VB2_SCREEN_RECOVERY_TO_DEV, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - /* Cancel to_dev transition */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_key(VB_KEY_CTRL('D'), 1); - if (PHYSICAL_PRESENCE_KEYBOARD) - add_mock_key(VB_KEY_DOWN, 1); - add_mock_key(VB_KEY_ENTER, 1); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "cancel to_dev transition"); - TEST_EQ(mock_enable_dev_mode, 0, " dev mode not enabled"); - - /* Confirm to_dev transition */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_key(VB_KEY_CTRL('D'), 1); - if (PHYSICAL_PRESENCE_KEYBOARD) { - add_mock_key(VB_KEY_ENTER, 1); - } else { - add_mock_pp_pressed(0); - add_mock_pp_pressed(1); - add_mock_pp_pressed(1); - add_mock_pp_pressed(0); - } - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_REBOOT_EC_TO_RO, - "confirm to_dev transition"); - if (!PHYSICAL_PRESENCE_KEYBOARD) - TEST_TRUE(mock_iters >= mock_pp_pressed_total - 1, - " used up mock_pp_pressed"); - TEST_EQ(mock_enable_dev_mode, 1, " dev mode enabled"); - - /* Cannot confirm physical presence by untrusted keyboard */ - if (PHYSICAL_PRESENCE_KEYBOARD) { - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_key(VB_KEY_CTRL('D'), 1); - add_mock_key(VB_KEY_ENTER, 0); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "cannot confirm physical presence" - " by untrusted keyboard"); - TEST_EQ(mock_enable_dev_mode, 0, " dev mode not enabled"); - } - - /* Cannot enable dev mode if already enabled */ - reset_common_data(FOR_MANUAL_RECOVERY); - sd->flags |= VB2_SD_FLAG_DEV_MODE_ENABLED; - add_mock_key(VB_KEY_CTRL('D'), 1); - if (PHYSICAL_PRESENCE_KEYBOARD) { - add_mock_key(VB_KEY_ENTER, 1); - } else { - add_mock_pp_pressed(0); - add_mock_pp_pressed(1); - add_mock_pp_pressed(0); - } - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "cannot enable dev mode if already enabled"); - TEST_EQ(mock_enable_dev_mode, 0, " dev mode already on"); - - /* Physical presence button tests */ - if (!PHYSICAL_PRESENCE_KEYBOARD) { - /* Physical presence button stuck? */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_key(VB_KEY_CTRL('D'), 1); - add_mock_pp_pressed(1); /* Hold since boot */ - add_mock_pp_pressed(0); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "physical presence button stuck?"); - TEST_EQ(mock_enable_dev_mode, 0, " dev mode not enabled"); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - /* Button stuck, enter to_dev again */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_key(VB_KEY_CTRL('D'), 1); - add_mock_key(VB_KEY_CTRL('D'), 1); - add_mock_pp_pressed(1); /* Hold since boot */ - add_mock_pp_pressed(0); - add_mock_pp_pressed(1); /* Press again */ - add_mock_pp_pressed(0); - TEST_EQ(vb2_manual_recovery_menu(ctx), - VB2_REQUEST_REBOOT_EC_TO_RO, - "button stuck, enter to_dev again"); - TEST_TRUE(mock_iters >= mock_pp_pressed_total - 1, - " used up mock_pp_pressed"); - TEST_EQ(mock_enable_dev_mode, 1, " dev mode enabled"); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("to_dev", VB2_SCREEN_RECOVERY_TO_DEV, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - /* Cancel with holding pp button, enter again */ - reset_common_data(FOR_MANUAL_RECOVERY); - /* Enter to_dev */ - add_mock_key(VB_KEY_CTRL('D'), 1); - add_mock_pp_pressed(0); - /* Press pp button */ - add_mock_keypress(0); - add_mock_pp_pressed(1); - /* Space = back */ - add_mock_keypress(' '); - add_mock_pp_pressed(1); - /* Wait */ - add_mock_keypress(0); - add_mock_pp_pressed(0); - /* Enter to_dev again */ - add_mock_key(VB_KEY_CTRL('D'), 1); - add_mock_pp_pressed(0); - /* Press pp button again */ - add_mock_pp_pressed(1); - /* Release */ - add_mock_pp_pressed(0); - TEST_EQ(vb2_manual_recovery_menu(ctx), - VB2_REQUEST_REBOOT_EC_TO_RO, - "cancel with holding pp button, enter again"); - TEST_TRUE(mock_iters >= mock_pp_pressed_total - 1, - " used up mock_pp_pressed"); - TEST_EQ(mock_enable_dev_mode, 1, " dev mode enabled"); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("to_dev", VB2_SCREEN_RECOVERY_TO_DEV, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("to_dev", VB2_SCREEN_RECOVERY_TO_DEV, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - } - - /* Enter diagnostics */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - TEST_EQ(vb2_manual_recovery_menu(ctx), - VB2_REQUEST_REBOOT, - "Reboot immediately after request diagnostics"); - TEST_EQ(vb2_nv_get(ctx, VB2_NV_DIAG_REQUEST), 1, - "VB2_NV_DIAG_REQUEST is set"); - - VB2_DEBUG("...done.\n"); -} - -static void language_selection_tests(void) -{ - VB2_DEBUG("Testing language selection...\n"); - - /* Enter language menu and change language */ - reset_common_data(FOR_MANUAL_RECOVERY); - mock_locale_count = 100; - vb2_nv_set(ctx, VB2_NV_LOCALIZATION_INDEX, 23); - add_mock_keypress(VB_KEY_UP); - add_mock_keypress(VB_KEY_ENTER); /* select language */ - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); /* select locale 24 */ - add_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "change language"); - DISPLAYED_EQ("RECOVERY_SELECT default", VB2_SCREEN_RECOVERY_SELECT, - 23, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("RECOVERY_SELECT lang", VB2_SCREEN_RECOVERY_SELECT, - 23, 0, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("LANGUAGE_SELECT 23", VB2_SCREEN_LANGUAGE_SELECT, - 23, 23, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("LANGUAGE_SELECT 24", VB2_SCREEN_LANGUAGE_SELECT, - 23, 24, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("RECOVERY_SELECT new locale", VB2_SCREEN_RECOVERY_SELECT, - 24, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - TEST_EQ(vb2_nv_get(ctx, VB2_NV_LOCALIZATION_INDEX), 24, - " locale 24 saved to nvdata"); - - /* Locale count = 0 */ - reset_common_data(FOR_MANUAL_RECOVERY); - mock_locale_count = 0; - vb2_nv_set(ctx, VB2_NV_LOCALIZATION_INDEX, 23); - add_mock_keypress(VB_KEY_UP); - add_mock_keypress(VB_KEY_ENTER); /* select language */ - add_mock_keypress(VB_KEY_ENTER); /* select locale 0 */ - add_mock_vbtlk(VB2_ERROR_LK_NO_DISK_FOUND, VB_DISK_FLAG_REMOVABLE); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "enter language menu"); - DISPLAYED_EQ("RECOVERY_SELECT default", VB2_SCREEN_RECOVERY_SELECT, - 23, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("RECOVERY_SELECT lang", VB2_SCREEN_RECOVERY_SELECT, - 23, 0, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("LANGUAGE_SELECT index 0", VB2_SCREEN_LANGUAGE_SELECT, - 23, 0, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("RECOVERY_SELECT locale 0", VB2_SCREEN_RECOVERY_SELECT, - 0, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - VB2_DEBUG("...done.\n"); -} - static void debug_info_tests(void) { VB2_DEBUG("Testing debug info screen...\n"); @@ -1090,143 +818,6 @@ static void debug_info_tests(void) MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); DISPLAYED_NO_EXTRA(); - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_keypress('\t'); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "tab = debug info in manual recovery mode"); - DISPLAYED_PASS(); - DISPLAYED_EQ("debug info", VB2_SCREEN_DEBUG_INFO, MOCK_IGNORE, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - /* Failed to enter debug info */ - reset_common_data(FOR_MANUAL_RECOVERY); - mock_log_page_count = 0; - add_mock_keypress('\t'); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "failed to enter debug info"); - DISPLAYED_PASS(); - DISPLAYED_PASS(); /* error code */ - DISPLAYED_NO_EXTRA(); - - /* Get a one-page debug info */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_keypress('\t'); - add_mock_keypress(VB_KEY_ENTER); /* back */ - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "get a one-page debug info"); - DISPLAYED_PASS(); - DISPLAYED_EQ("debug info", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 3, 0x6, 0x0, 0); - DISPLAYED_EQ("back to root screen", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - /* Get a three-page debug info and navigate */ - reset_common_data(FOR_MANUAL_RECOVERY); - mock_log_page_count = 3; - add_mock_keypress('\t'); - add_mock_keypress(VB_KEY_ENTER); /* page 0, select on page down */ - add_mock_keypress(VB_KEY_ENTER); /* page 1, select on page down */ - add_mock_keypress(VB_KEY_UP); /* page 2, select on page down */ - add_mock_keypress(VB_KEY_ENTER); /* page 2, select on page up */ - add_mock_keypress(VB_KEY_ENTER); /* page 1, select on page up */ - add_mock_keypress(VB_KEY_DOWN); /* page 0, select on page up */ - add_mock_keypress(VB_KEY_ENTER); /* page 0, select on page down */ - add_mock_keypress(VB_KEY_DOWN); /* page 1, select on page down */ - add_mock_keypress(VB_KEY_ENTER); /* page 1, select on back */ - extend_calls_until_shutdown(); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "get a three-page debug info and navigate"); - DISPLAYED_PASS(); - DISPLAYED_EQ("debug info page #0", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 2, 0x2, 0x0, 0); - DISPLAYED_EQ("debug info page #1", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 2, 0x0, 0x0, 1); - DISPLAYED_EQ("debug info page #2", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 2, 0x4, 0x0, 2); - DISPLAYED_EQ("debug info page #2", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 1, 0x4, 0x0, 2); - DISPLAYED_EQ("debug info page #1", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 1, 0x0, 0x0, 1); - DISPLAYED_EQ("debug info page #0", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 1, 0x2, 0x0, 0); - DISPLAYED_EQ("debug info page #0", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 2, 0x2, 0x0, 0); - DISPLAYED_EQ("debug info page #1", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 2, 0x0, 0x0, 1); - DISPLAYED_EQ("debug info page #1", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, 3, 0x0, 0x0, 1); - DISPLAYED_EQ("back to root screen", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - VB2_DEBUG("...done.\n"); -} - -static void firmware_log_tests(void) -{ - VB2_DEBUG("Testing firmware log screens...\n"); - - /* Get firmware log */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "get firmware log"); - TEST_EQ(mock_prepare_log_count, 1, - " prepared firmware log once"); - TEST_EQ(strcmp(mock_prepare_log[0], "1"), 0, - " got correct firmware log"); - - /* Enter firmware log screen again will reacquire a newer one */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - add_mock_keypress(VB_KEY_ESC); - add_mock_keypress(VB_KEY_ENTER); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "enter the screen again and reacquire a new log"); - TEST_EQ(mock_prepare_log_count, 2, - " prepared firmware log twice"); - TEST_EQ(strcmp(mock_prepare_log[0], "1"), 0, - " got correct firmware log"); - TEST_EQ(strcmp(mock_prepare_log[1], "2"), 0, - " got a new firmware log"); - - /* Back to firmware log screen again will not reacquire a newer one */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - add_mock_keypress('\t'); /* enter debug info screen */ - add_mock_keypress(VB_KEY_ESC); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "back to the screen and do not reacquire a new log"); - TEST_EQ(mock_prepare_log_count, 3, - " prepared firmware log three times"); - TEST_EQ(strcmp(mock_prepare_log[0], "1"), 0, - " got correct firmware log"); - /* Skip entry #1 which is for preparing debug info */ - TEST_EQ(strcmp(mock_prepare_log[2], "1"), 0, - " got the same firmware log"); - VB2_DEBUG("...done.\n"); } @@ -1445,174 +1036,6 @@ static void developer_screen_tests(void) VB2_DEBUG("...done.\n"); } -static void manual_recovery_screen_tests(void) -{ - /* Recovery select screen: disabled and hidden item mask */ - reset_common_data(FOR_MANUAL_RECOVERY); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "recovery select screen: no disabled or hidden item"); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, 0x0, 0x0, MOCK_IGNORE); - - /* Recovery select screen */ - reset_common_data(FOR_MANUAL_RECOVERY); - /* #0: Language menu */ - add_mock_keypress(VB_KEY_UP); - add_mock_keypress(VB_KEY_ENTER); - /* #1: Phone recovery */ - add_mock_keypress(VB_KEY_ESC); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - /* #2: External disk recovery */ - add_mock_keypress(VB_KEY_ESC); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - add_mock_keypress(VB_KEY_ESC); - /* #3: Launch diagnostics */ - add_mock_keypress(VB_KEY_DOWN); - /* #4: Advanced options */ - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - /* End of menu */ - add_mock_keypress(VB_KEY_ESC); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); /* Blocked */ - extend_calls_until_shutdown(); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "recovery select screen"); - /* #0: Language menu */ - DISPLAYED_PASS(); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, 0, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("#0: language menu", VB2_SCREEN_LANGUAGE_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - /* #1: Phone recovery */ - DISPLAYED_PASS(); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, 1, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("#1: phone recovery", VB2_SCREEN_RECOVERY_PHONE_STEP1, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - /* #2: External disk recovery */ - DISPLAYED_PASS(); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, 2, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("#2: disk recovery", VB2_SCREEN_RECOVERY_DISK_STEP1, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, 2, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - /* #3: Launch diagnostics */ - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, 3, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - /* #4: Advanced options */ - DISPLAYED_EQ("recovery select", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, 4, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - - DISPLAYED_EQ("#3: advanced options", VB2_SCREEN_ADVANCED_OPTIONS, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - /* End of menu */ - DISPLAYED_PASS(); - DISPLAYED_EQ("end of menu", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, 5, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - /* Advanced options screen: disabled and hidden item mask */ - reset_common_data(FOR_MANUAL_RECOVERY); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "advanced options screen: no disabled or hidden item"); - DISPLAYED_PASS(); - DISPLAYED_PASS(); - DISPLAYED_PASS(); - DISPLAYED_PASS(); - DISPLAYED_EQ("advanced options", VB2_SCREEN_ADVANCED_OPTIONS, - MOCK_IGNORE, MOCK_IGNORE, 0x0, 0x0, MOCK_IGNORE); - - /* Advanced options screen */ - reset_common_data(FOR_MANUAL_RECOVERY); - /* #0: Language menu */ - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - add_mock_keypress(VB_KEY_UP); - add_mock_keypress(VB_KEY_ENTER); - /* #1: Enable dev mode */ - add_mock_keypress(VB_KEY_ESC); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - /* #2: Debug info */ - add_mock_keypress(VB_KEY_ESC); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - /* #3: Firmware log */ - add_mock_keypress(VB_KEY_ESC); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - /* #4: Back */ - add_mock_keypress(VB_KEY_ESC); - add_mock_keypress(VB_KEY_DOWN); - add_mock_keypress(VB_KEY_ENTER); - /* End of menu */ - add_mock_keypress(VB_KEY_ENTER); - add_mock_keypress(VB_KEY_DOWN); - extend_calls_until_shutdown(); - TEST_EQ(vb2_manual_recovery_menu(ctx), VB2_REQUEST_SHUTDOWN, - "advanced options screen"); - DISPLAYED_PASS(); - DISPLAYED_PASS(); - DISPLAYED_PASS(); - DISPLAYED_PASS(); - /* #0: Language menu */ - DISPLAYED_PASS(); - DISPLAYED_EQ("advanced options", VB2_SCREEN_ADVANCED_OPTIONS, - MOCK_IGNORE, 0, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("#0: language menu", VB2_SCREEN_LANGUAGE_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - /* #1: Enable dev mode */ - DISPLAYED_PASS(); - DISPLAYED_EQ("advanced options", VB2_SCREEN_ADVANCED_OPTIONS, - MOCK_IGNORE, 1, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("#1: enable dev mode", VB2_SCREEN_RECOVERY_TO_DEV, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - /* #2: Debug info */ - DISPLAYED_PASS(); - DISPLAYED_EQ("advanced options", VB2_SCREEN_ADVANCED_OPTIONS, - MOCK_IGNORE, 2, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("#2: debug info", VB2_SCREEN_DEBUG_INFO, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - /* #3: Firmware log */ - DISPLAYED_PASS(); - DISPLAYED_EQ("advanced options", VB2_SCREEN_ADVANCED_OPTIONS, - MOCK_IGNORE, 3, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("#3: firmware log", VB2_SCREEN_FIRMWARE_LOG, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - /* #4: Back */ - DISPLAYED_PASS(); - DISPLAYED_EQ("advanced options", VB2_SCREEN_ADVANCED_OPTIONS, - MOCK_IGNORE, 4, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_EQ("#4: back", VB2_SCREEN_RECOVERY_SELECT, - MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE, - MOCK_IGNORE); - /* End of menu */ - DISPLAYED_PASS(); - DISPLAYED_EQ("end of menu", VB2_SCREEN_ADVANCED_OPTIONS, - MOCK_IGNORE, 2, MOCK_IGNORE, MOCK_IGNORE, MOCK_IGNORE); - DISPLAYED_NO_EXTRA(); - - VB2_DEBUG("...done.\n"); -} - static void diagnostics_screen_tests(void) { VB2_DEBUG("Testing diagnostic screens...\n"); @@ -1724,14 +1147,10 @@ static void diagnostics_screen_tests(void) int main(void) { developer_tests(); - manual_recovery_tests(); - language_selection_tests(); debug_info_tests(); - firmware_log_tests(); /* Screen displayed */ developer_screen_tests(); - manual_recovery_screen_tests(); diagnostics_screen_tests(); return gTestSuccess ? 0 : 255; diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c index ae0e0064..2e4026df 100644 --- a/tests/vboot_api_kernel4_tests.c +++ b/tests/vboot_api_kernel4_tests.c @@ -149,7 +149,7 @@ static void rec_check(struct vb2_context *c) TEST_TRUE(commit_data_called, " commit data"); } -vb2_error_t vb2_manual_recovery_menu(struct vb2_context *c) +vb2_error_t vb2ex_manual_recovery_ui(struct vb2_context *c) { rec_check(c); if (vbboot_retval == -3) -- cgit v1.2.1