summaryrefslogtreecommitdiff
path: root/tests/vb2_ui_action_tests.c
diff options
context:
space:
mode:
authorChung-Sheng Wu <chungsheng@google.com>2021-03-23 18:33:54 +0800
committerCommit Bot <commit-bot@chromium.org>2021-04-21 03:58:35 +0000
commit029263c8be01430699553ddcf2631f7e37f2526c (patch)
treed6c0bd32b1fc591e407837a66183599c9de9b9c6 /tests/vb2_ui_action_tests.c
parent6f3c57ff008a313b8e2ae2e497fda737dd1eeb5b (diff)
downloadvboot-029263c8be01430699553ddcf2631f7e37f2526c.tar.gz
Add helper functions to check and set ui error code. The ui error handling shouldn't catch the requests but only the error. Add vb2_is_error() to 2api.h. This function is for checking if the return value is an error or not. BRANCH=none BUG=b:157625765 TEST=make clean && CC=x86_64-pc-linux-gnu-clang make runtests Signed-off-by: Chung-Sheng Wu <chungsheng@google.com> Change-Id: I5c9a34dadf749f3b5364860a1a034bfefe0a61f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2780821 Tested-by: Chung-Sheng Wu <chungsheng@chromium.org> Commit-Queue: Chung-Sheng Wu <chungsheng@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'tests/vb2_ui_action_tests.c')
-rw-r--r--tests/vb2_ui_action_tests.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/vb2_ui_action_tests.c b/tests/vb2_ui_action_tests.c
index 42546844..66a776eb 100644
--- a/tests/vb2_ui_action_tests.c
+++ b/tests/vb2_ui_action_tests.c
@@ -757,7 +757,9 @@ static void vb2_ui_developer_mode_boot_altfw_action_tests(void)
reset_common_data();
mock_dev_boot_altfw_allowed = 1;
TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context),
- VB2_SUCCESS, "not allowed: not in dev mode");
+ VB2_REQUEST_UI_CONTINUE, "not allowed: not in dev mode");
+ TEST_EQ(mock_ui_context.error_code, VB2_UI_ERROR_ALTFW_DISABLED,
+ "ui_error code is set");
TEST_EQ(mock_run_altfw_called, 0, " vb2ex_run_altfw not called");
/* Not allowed: dev boot not allowed */
@@ -766,14 +768,18 @@ static void vb2_ui_developer_mode_boot_altfw_action_tests(void)
mock_dev_boot_allowed = 0;
mock_dev_boot_altfw_allowed = 1;
TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context),
- VB2_SUCCESS, "not allowed: dev boot not allowed");
+ VB2_REQUEST_UI_CONTINUE, "not allowed: dev boot not allowed");
+ TEST_EQ(mock_ui_context.error_code, VB2_UI_ERROR_ALTFW_DISABLED,
+ "ui_error code is set");
TEST_EQ(mock_run_altfw_called, 0, " vb2ex_run_altfw not called");
/* Not allowed: boot altfw not allowed */
reset_common_data();
ctx->flags |= VB2_CONTEXT_DEVELOPER_MODE;
TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context),
- VB2_SUCCESS, "not allowed: boot altfw not allowed");
+ VB2_REQUEST_UI_CONTINUE, "not allowed: boot altfw not allowed");
+ TEST_EQ(mock_ui_context.error_code, VB2_UI_ERROR_ALTFW_DISABLED,
+ "ui_error code is set");
TEST_EQ(mock_run_altfw_called, 0, " vb2ex_run_altfw not called");
/* Allowed */
@@ -782,7 +788,9 @@ static void vb2_ui_developer_mode_boot_altfw_action_tests(void)
mock_dev_boot_altfw_allowed = 1;
mock_ui_context.state->selected_item = 2;
TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context),
- VB2_SUCCESS, "allowed");
+ VB2_REQUEST_UI_CONTINUE, "allowed");
+ TEST_EQ(mock_ui_context.error_code, VB2_UI_ERROR_ALTFW_FAILED,
+ "ui_error code is set");
TEST_EQ(mock_run_altfw_called, 1, " vb2ex_run_altfw called once");
TEST_EQ(mock_altfw_last, 2, " select bootloader #2");
@@ -793,7 +801,9 @@ static void vb2_ui_developer_mode_boot_altfw_action_tests(void)
mock_ui_context.key = VB_KEY_CTRL('L');
mock_ui_context.state->selected_item = 4; /* Ignored */
TEST_EQ(vb2_ui_developer_mode_boot_altfw_action(&mock_ui_context),
- VB2_SUCCESS, "allowed: ctrl+l");
+ VB2_REQUEST_UI_CONTINUE, "allowed: ctrl+l");
+ TEST_EQ(mock_ui_context.error_code, VB2_UI_ERROR_ALTFW_FAILED,
+ "ui_error code is set");
TEST_EQ(mock_run_altfw_called, 1, " vb2ex_run_altfw called once");
TEST_EQ(mock_altfw_last, 0, " select bootloader #0");