summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMathew King <mathewk@chromium.org>2019-02-19 10:43:32 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-02-22 11:01:10 -0800
commitaf26dc17173d82c75821cf5385054a3b3b17165d (patch)
treeb4085a4a5eae2789d4090dfa9e41ec7b934716e1 /tests
parent1e177741c3a9bfb8bd69a92b6d3bf4b25655a71f (diff)
downloadvboot-af26dc17173d82c75821cf5385054a3b3b17165d.tar.gz
vboot: Don't hardcode special keyboard values.
BUG=chromium:933391 TEST=make runtests Test ctrl+d, ctrl+u, and ctrl+l on device BRANCH=none Change-Id: Icf8699e5facac44a074cfd47e796b9957fd6b714 Reviewed-on: https://chromium-review.googlesource.com/1475781 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Mathew King <mathewk@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Mathew King <mathewk@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/vboot_api_kernel2_tests.c70
-rw-r--r--tests/vboot_detach_menu_tests.c48
2 files changed, 59 insertions, 59 deletions
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index 2f1dee90..9b887597 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -222,7 +222,7 @@ static void VbUserConfirmsTest(void)
TEST_EQ(VbUserConfirms(&ctx, 0), -1, "Shutdown requested");
ResetMocks();
- mock_keypress[0] = '\r';
+ mock_keypress[0] = VB_KEY_ENTER;
TEST_EQ(VbUserConfirms(&ctx, 0), 1, "Enter");
ResetMocks();
@@ -241,13 +241,13 @@ static void VbUserConfirmsTest(void)
TEST_EQ(VbUserConfirms(&ctx, 0), -1, "Space ignored");
ResetMocks();
- mock_keypress[0] = '\r';
+ mock_keypress[0] = VB_KEY_ENTER;
mock_keyflags[0] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
TEST_EQ(VbUserConfirms(&ctx, VB_CONFIRM_MUST_TRUST_KEYBOARD),
1, "Enter with trusted keyboard");
ResetMocks();
- mock_keypress[0] = '\r'; /* untrusted */
+ mock_keypress[0] = VB_KEY_ENTER; /* untrusted */
mock_keypress[1] = ' ';
TEST_EQ(VbUserConfirms(&ctx,
VB_CONFIRM_SPACE_MEANS_NO |
@@ -262,7 +262,7 @@ static void VbUserConfirmsTest(void)
1, "Recovery button");
ResetMocks();
- mock_keypress[0] = '\r';
+ mock_keypress[0] = VB_KEY_ENTER;
mock_keypress[1] = 'y';
mock_keypress[2] = 'z';
mock_keypress[3] = ' ';
@@ -390,7 +390,7 @@ static void VbBootDevTest(void)
ResetMocks();
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_DEV_SWITCH_ON;
mock_keypress[0] = ' ';
- mock_keypress[1] = '\r';
+ mock_keypress[1] = VB_KEY_ENTER;
TEST_EQ(VbBootDeveloper(&ctx), VBERROR_REBOOT_REQUIRED,
"Space = tonorm");
TEST_EQ(screens_displayed[0], VB_SCREEN_DEVELOPER_WARNING,
@@ -419,16 +419,16 @@ static void VbBootDevTest(void)
/* Enter doesn't by default */
ResetMocks();
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_DEV_SWITCH_ON;
- mock_keypress[0] = '\r';
- mock_keypress[1] = '\r';
+ mock_keypress[0] = VB_KEY_ENTER;
+ mock_keypress[1] = VB_KEY_ENTER;
TEST_EQ(VbBootDeveloper(&ctx), 1002, "Enter ignored");
/* Enter does if GBB flag set */
ResetMocks();
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_DEV_SWITCH_ON;
sd->gbb_flags |= VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM;
- mock_keypress[0] = '\r';
- mock_keypress[1] = '\r';
+ mock_keypress[0] = VB_KEY_ENTER;
+ mock_keypress[1] = VB_KEY_ENTER;
TEST_EQ(VbBootDeveloper(&ctx), VBERROR_REBOOT_REQUIRED,
"Enter = tonorm");
@@ -437,7 +437,7 @@ static void VbBootDevTest(void)
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_DEV_SWITCH_ON;
sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON;
mock_keypress[0] = ' ';
- mock_keypress[1] = '\r';
+ mock_keypress[1] = VB_KEY_ENTER;
TEST_EQ(VbBootDeveloper(&ctx), 1002,
"Can't tonorm gbb-dev");
@@ -464,7 +464,7 @@ static void VbBootDevTest(void)
/* Ctrl+D dismisses warning */
ResetMocks();
- mock_keypress[0] = 0x04;
+ mock_keypress[0] = VB_KEY_CTRL('D');
TEST_EQ(VbBootDeveloper(&ctx), 1002, "Ctrl+D");
TEST_EQ(vb2_nv_get(&ctx, VB2_NV_RECOVERY_REQUEST), 0,
" recovery reason");
@@ -473,14 +473,14 @@ static void VbBootDevTest(void)
/* Ctrl+D doesn't boot legacy even if GBB flag is set */
ResetMocks();
- mock_keypress[0] = 0x04;
+ mock_keypress[0] = VB_KEY_CTRL('D');
sd->gbb_flags |= VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY;
TEST_EQ(VbBootDeveloper(&ctx), 1002, "Ctrl+D");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
/* Ctrl+L tries legacy boot mode only if enabled */
ResetMocks();
- mock_keypress[0] = 0x0c;
+ mock_keypress[0] = VB_KEY_CTRL('L');
TEST_EQ(VbBootDeveloper(&ctx), 1002, "Ctrl+L normal");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
@@ -488,7 +488,7 @@ static void VbBootDevTest(void)
ResetMocks();
shutdown_request_calls_left = 1000;
sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
- mock_keypress[0] = 0x0c;
+ mock_keypress[0] = VB_KEY_CTRL('L');
TEST_EQ(VbBootDeveloper(&ctx), VBERROR_SHUTDOWN_REQUESTED,
"Ctrl+L force legacy");
TEST_EQ(vbexlegacy_called, 0, " try legacy");
@@ -496,7 +496,7 @@ static void VbBootDevTest(void)
/* Enter altfw menu and select firmware 0 */
ResetMocks();
sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
- mock_keypress[0] = 0x0c;
+ mock_keypress[0] = VB_KEY_CTRL('L');
mock_keypress[1] = '0';
TEST_EQ(VbBootDeveloper(&ctx), 1002,
"Ctrl+L force legacy");
@@ -506,7 +506,7 @@ static void VbBootDevTest(void)
/* Enter altfw menu and then exit it */
ResetMocks();
vb2_nv_set(&ctx, VB2_NV_DEV_BOOT_LEGACY, 1);
- mock_keypress[0] = 0x0c;
+ mock_keypress[0] = VB_KEY_CTRL('L');
mock_keypress[1] = VB_KEY_ESC;
TEST_EQ(VbBootDeveloper(&ctx), 1002,
"Ctrl+L nv legacy");
@@ -515,7 +515,7 @@ static void VbBootDevTest(void)
/* Enter altfw menu and select firmware 0 */
ResetMocks();
vb2_nv_set(&ctx, VB2_NV_DEV_BOOT_LEGACY, 1);
- mock_keypress[0] = 0x0c;
+ mock_keypress[0] = VB_KEY_CTRL('L');
mock_keypress[1] = '0';
TEST_EQ(VbBootDeveloper(&ctx), 1002,
"Ctrl+L nv legacy");
@@ -525,7 +525,7 @@ static void VbBootDevTest(void)
/* Enter altfw menu and select firmware 0 */
ResetMocks();
VbApiKernelGetFwmp()->flags |= FWMP_DEV_ENABLE_LEGACY;
- mock_keypress[0] = 0x0c;
+ mock_keypress[0] = VB_KEY_CTRL('L');
mock_keypress[1] = '0';
TEST_EQ(VbBootDeveloper(&ctx), 1002,
"Ctrl+L fwmp legacy");
@@ -566,34 +566,34 @@ static void VbBootDevTest(void)
/* Ctrl+U boots USB only if enabled */
ResetMocks();
- mock_keypress[0] = 0x15;
+ mock_keypress[0] = VB_KEY_CTRL('U');
TEST_EQ(VbBootDeveloper(&ctx), 1002, "Ctrl+U normal");
/* Ctrl+U enabled, with good USB boot */
ResetMocks();
vb2_nv_set(&ctx, VB2_NV_DEV_BOOT_USB, 1);
- mock_keypress[0] = 0x15;
+ mock_keypress[0] = VB_KEY_CTRL('U');
vbtlk_retval = VBERROR_SUCCESS - VB_DISK_FLAG_REMOVABLE;
TEST_EQ(VbBootDeveloper(&ctx), 0, "Ctrl+U USB");
/* Ctrl+U enabled via GBB */
ResetMocks();
sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_USB;
- mock_keypress[0] = 0x15;
+ mock_keypress[0] = VB_KEY_CTRL('U');
vbtlk_retval = VBERROR_SUCCESS - VB_DISK_FLAG_REMOVABLE;
TEST_EQ(VbBootDeveloper(&ctx), 0, "Ctrl+U force USB");
/* Ctrl+U enabled via FWMP */
ResetMocks();
VbApiKernelGetFwmp()->flags |= FWMP_DEV_ENABLE_USB;
- mock_keypress[0] = 0x15;
+ mock_keypress[0] = VB_KEY_CTRL('U');
vbtlk_retval = VBERROR_SUCCESS - VB_DISK_FLAG_REMOVABLE;
TEST_EQ(VbBootDeveloper(&ctx), 0, "Ctrl+U force USB");
/* If no USB, eventually times out and tries fixed disk */
ResetMocks();
vb2_nv_set(&ctx, VB2_NV_DEV_BOOT_USB, 1);
- mock_keypress[0] = 0x15;
+ mock_keypress[0] = VB_KEY_CTRL('U');
TEST_EQ(VbBootDeveloper(&ctx), 1002, "Ctrl+U enabled");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
TEST_EQ(vb2_nv_get(&ctx, VB2_NV_RECOVERY_REQUEST), 0,
@@ -603,8 +603,8 @@ static void VbBootDevTest(void)
/* If dev mode is disabled, goes to TONORM screen repeatedly */
ResetMocks();
VbApiKernelGetFwmp()->flags |= FWMP_DEV_DISABLE_BOOT;
- mock_keypress[0] = '\x1b'; /* Just causes TONORM again */
- mock_keypress[1] = '\r';
+ mock_keypress[0] = VB_KEY_ESC; /* Just causes TONORM again */
+ mock_keypress[1] = VB_KEY_ENTER;
TEST_EQ(VbBootDeveloper(&ctx), VBERROR_REBOOT_REQUIRED,
"FWMP dev disabled");
TEST_EQ(screens_displayed[0], VB_SCREEN_DEVELOPER_TO_NORM,
@@ -763,7 +763,7 @@ static void VbBootRecTest(void)
ResetMocks();
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_REC_SWITCH_ON;
shutdown_request_calls_left = 100;
- mock_keypress[0] = 0x04;
+ mock_keypress[0] = VB_KEY_CTRL('D');
trust_ec = 0;
TEST_EQ(VbBootRecovery(&ctx),
VBERROR_SHUTDOWN_REQUESTED,
@@ -777,7 +777,7 @@ static void VbBootRecTest(void)
VBSD_BOOT_DEV_SWITCH_ON;
trust_ec = 1;
shutdown_request_calls_left = 100;
- mock_keypress[0] = 0x04;
+ mock_keypress[0] = VB_KEY_CTRL('D');
TEST_EQ(VbBootRecovery(&ctx),
VBERROR_SHUTDOWN_REQUESTED,
"Ctrl+D ignored if already in dev mode");
@@ -789,7 +789,7 @@ static void VbBootRecTest(void)
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH;
trust_ec = 1;
shutdown_request_calls_left = 100;
- mock_keypress[0] = 0x04;
+ mock_keypress[0] = VB_KEY_CTRL('D');
TEST_EQ(VbBootRecovery(&ctx),
VBERROR_SHUTDOWN_REQUESTED,
"Ctrl+D ignored if recovery not manually triggered");
@@ -801,7 +801,7 @@ static void VbBootRecTest(void)
shared->flags = VBSD_BOOT_REC_SWITCH_ON;
trust_ec = 1;
shutdown_request_calls_left = 100;
- mock_keypress[0] = 0x04;
+ mock_keypress[0] = VB_KEY_CTRL('D');
TEST_EQ(VbBootRecovery(&ctx),
VBERROR_SHUTDOWN_REQUESTED,
"Ctrl+D ignored if no virtual dev switch");
@@ -816,7 +816,7 @@ static void VbBootRecTest(void)
shared->flags = VBSD_BOOT_REC_SWITCH_ON;
trust_ec = 1;
shutdown_request_calls_left = 100;
- mock_keypress[0] = 0x04;
+ mock_keypress[0] = VB_KEY_CTRL('D');
mock_switches[0] = VB_INIT_FLAG_REC_BUTTON_PRESSED;
TEST_EQ(VbBootRecovery(&ctx),
VBERROR_SHUTDOWN_REQUESTED,
@@ -830,7 +830,7 @@ static void VbBootRecTest(void)
shutdown_request_calls_left = 100;
vbtlk_retval = VBERROR_NO_DISK_FOUND - VB_DISK_FLAG_REMOVABLE;
trust_ec = 1;
- mock_keypress[0] = 0x04;
+ mock_keypress[0] = VB_KEY_CTRL('D');
mock_keypress[1] = ' ';
TEST_EQ(VbBootRecovery(&ctx),
VBERROR_SHUTDOWN_REQUESTED,
@@ -849,8 +849,8 @@ static void VbBootRecTest(void)
shutdown_request_calls_left = 100;
vbtlk_retval = VBERROR_NO_DISK_FOUND - VB_DISK_FLAG_REMOVABLE;
trust_ec = 1;
- mock_keypress[0] = 0x04;
- mock_keypress[1] = '\r';
+ mock_keypress[0] = VB_KEY_CTRL('D');
+ mock_keypress[1] = VB_KEY_ENTER;
mock_keyflags[1] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
TEST_EQ(VbBootRecovery(&ctx), VBERROR_EC_REBOOT_TO_RO_REQUIRED,
"Ctrl+D todev confirm");
@@ -862,8 +862,8 @@ static void VbBootRecTest(void)
shutdown_request_calls_left = 100;
vbtlk_retval = VBERROR_NO_DISK_FOUND - VB_DISK_FLAG_REMOVABLE;
trust_ec = 1;
- mock_keypress[0] = 0x04;
- mock_keypress[1] = '\r';
+ mock_keypress[0] = VB_KEY_CTRL('D');
+ mock_keypress[1] = VB_KEY_ENTER;
mock_keyflags[1] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
virtdev_retval = VBERROR_SIMULATED;
TEST_EQ(VbBootRecovery(&ctx),
diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c
index a9034b33..68a8a2c2 100644
--- a/tests/vboot_detach_menu_tests.c
+++ b/tests/vboot_detach_menu_tests.c
@@ -456,7 +456,7 @@ static void VbBootDevTest(void)
/* Pressing ENTER is equivalent to power button. */
ResetMocksForDeveloper();
- mock_keypress[0] = '\r';
+ mock_keypress[0] = VB_KEY_ENTER;
TEST_EQ(VbBootDeveloperMenu(&ctx), VBERROR_SHUTDOWN_REQUESTED,
"dev warning menu: ENTER is power button");
TEST_EQ(screens_displayed[0], VB_SCREEN_DEVELOPER_WARNING_MENU,
@@ -469,7 +469,7 @@ static void VbBootDevTest(void)
/* ENTER functionality is unaffected by GBB flag in detachable UI. */
ResetMocksForDeveloper();
sd->gbb_flags |= GBB_FLAG_ENTER_TRIGGERS_TONORM;
- mock_keypress[0] = '\r';
+ mock_keypress[0] = VB_KEY_ENTER;
TEST_EQ(VbBootDeveloperMenu(&ctx), VBERROR_SHUTDOWN_REQUESTED,
"dev warning menu: ENTER unaffected by GBB");
TEST_EQ(screens_displayed[0], VB_SCREEN_DEVELOPER_WARNING_MENU,
@@ -568,7 +568,7 @@ static void VbBootDevTest(void)
/* Ctrl+D dismisses warning */
ResetMocksForDeveloper();
- mock_keypress[0] = 'D' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('D');
TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed, "Ctrl+D");
TEST_EQ(vb2_nv_get(&ctx, VB2_NV_RECOVERY_REQUEST), 0,
" recovery reason");
@@ -583,7 +583,7 @@ static void VbBootDevTest(void)
/* Ctrl+D doesn't boot legacy even if GBB flag is set */
ResetMocksForDeveloper();
- mock_keypress[0] = 'D' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('D');
sd->gbb_flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY;
TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed, "Ctrl+D");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
@@ -605,7 +605,7 @@ static void VbBootDevTest(void)
/* Ctrl+L tries legacy boot mode only if enabled */
ResetMocksForDeveloper();
- mock_keypress[0] = 'L' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('L');
TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed, "Ctrl+L normal");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
TEST_EQ(vb2_nv_get(&ctx, VB2_NV_RECOVERY_REQUEST), 0, " no recovery");
@@ -625,7 +625,7 @@ static void VbBootDevTest(void)
/* Ctrl+L boots legacy if enabled by GBB flag */
ResetMocksForDeveloper();
sd->gbb_flags |= GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
- mock_keypress[0] = 'L' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('L');
mock_keypress[1] = VB_BUTTON_POWER_SHORT_PRESS;
TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed,
"Ctrl+L force legacy");
@@ -644,7 +644,7 @@ static void VbBootDevTest(void)
/* Ctrl+L boots legacy if enabled by NVRAM */
ResetMocksForDeveloper();
vb2_nv_set(&ctx, VB2_NV_DEV_BOOT_LEGACY, 1);
- mock_keypress[0] = 'L' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('L');
mock_keypress[1] = VB_BUTTON_POWER_SHORT_PRESS;
TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed,
"Ctrl+L nv legacy");
@@ -663,7 +663,7 @@ static void VbBootDevTest(void)
/* Ctrl+L boots legacy if enabled by FWMP */
ResetMocksForDeveloper();
VbApiKernelGetFwmp()->flags |= FWMP_DEV_ENABLE_LEGACY;
- mock_keypress[0] = 'L' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('L');
mock_keypress[1] = VB_BUTTON_POWER_SHORT_PRESS;
TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed,
"Ctrl+L fwmp legacy");
@@ -683,7 +683,7 @@ static void VbBootDevTest(void)
/* Ctrl+U boots USB only if enabled */
ResetMocksForDeveloper();
- mock_keypress[0] = 'U' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('U');
TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed,
"Ctrl+U not enabled");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
@@ -704,7 +704,7 @@ static void VbBootDevTest(void)
/* Ctrl+U enabled, with good USB boot */
ResetMocksForDeveloper();
vb2_nv_set(&ctx, VB2_NV_DEV_BOOT_USB, 1);
- mock_keypress[0] = 'U' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('U');
vbtlk_retval[0] = VBERROR_SUCCESS - VB_DISK_FLAG_REMOVABLE;
TEST_EQ(VbBootDeveloperMenu(&ctx), VBERROR_SUCCESS, "Ctrl+U USB");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
@@ -720,7 +720,7 @@ static void VbBootDevTest(void)
/* Ctrl+U enabled, without valid USB */
ResetMocksForDeveloper();
vb2_nv_set(&ctx, VB2_NV_DEV_BOOT_USB, 1);
- mock_keypress[0] = 'U' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('U');
TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed,
"Ctrl+U without valid USB");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
@@ -740,7 +740,7 @@ static void VbBootDevTest(void)
/* Ctrl+U enabled via GBB */
ResetMocksForDeveloper();
sd->gbb_flags |= GBB_FLAG_FORCE_DEV_BOOT_USB;
- mock_keypress[0] = 0x15;
+ mock_keypress[0] = VB_KEY_CTRL('U');
vbtlk_retval[0] = VBERROR_SUCCESS - VB_DISK_FLAG_REMOVABLE;
TEST_EQ(VbBootDeveloperMenu(&ctx), VBERROR_SUCCESS, "Ctrl+U force USB");
TEST_NEQ(audio_looping_calls_left, 0, " aborts audio");
@@ -753,7 +753,7 @@ static void VbBootDevTest(void)
/* Ctrl+U enabled via FWMP */
ResetMocksForDeveloper();
VbApiKernelGetFwmp()->flags |= FWMP_DEV_ENABLE_USB;
- mock_keypress[0] = 0x15;
+ mock_keypress[0] = VB_KEY_CTRL('U');
vbtlk_retval[0] = VBERROR_SUCCESS - VB_DISK_FLAG_REMOVABLE;
TEST_EQ(VbBootDeveloperMenu(&ctx), VBERROR_SUCCESS, "Ctrl+U force USB");
TEST_NEQ(audio_looping_calls_left, 0, " aborts audio");
@@ -766,7 +766,7 @@ static void VbBootDevTest(void)
/* If no valid USB, eventually times out and tries fixed disk */
ResetMocksForDeveloper();
vb2_nv_set(&ctx, VB2_NV_DEV_BOOT_USB, 1);
- mock_keypress[0] = 'U' & 0x1f;
+ mock_keypress[0] = VB_KEY_CTRL('U');
TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed,
"Ctrl+U failed - no USB");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
@@ -1148,13 +1148,13 @@ static void VbBootDevTest(void)
VbApiKernelGetFwmp()->flags |= FWMP_DEV_DISABLE_BOOT;
audio_looping_calls_left = 1; /* Confirm audio doesn't tick down. */
i = 0;
- mock_keypress[i++] = 'D' & 0x1f; /* Just stays on TONORM and flashes */
- mock_keypress[i++] = 'U' & 0x1f; /* same */
- mock_keypress[i++] = 'L' & 0x1f; /* same */
+ mock_keypress[i++] = VB_KEY_CTRL('D'); /* Just stays on TONORM and flashes */
+ mock_keypress[i++] = VB_KEY_CTRL('U'); /* same */
+ mock_keypress[i++] = VB_KEY_CTRL('L'); /* same */
mock_keypress[i++] = VB_BUTTON_VOL_UP_LONG_PRESS; /* same */
mock_keypress[i++] = VB_BUTTON_VOL_DOWN_LONG_PRESS; /* same */
mock_keypress[i++] = VB_BUTTON_VOL_UP_DOWN_COMBO_PRESS; /* noop */
- mock_keypress[i++] = '\r';
+ mock_keypress[i++] = VB_KEY_ENTER;
TEST_EQ(VbBootDeveloperMenu(&ctx), VBERROR_REBOOT_REQUIRED,
"FWMP dev disabled");
TEST_EQ(vb2_nv_get(&ctx, VB2_NV_DISABLE_DEV_REQUEST), 1,
@@ -1457,11 +1457,11 @@ static void VbBootRecTest(void)
ResetMocks();
i = 0;
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
- mock_keypress[i++] = 'D' & 0x1f;
+ mock_keypress[i++] = VB_KEY_CTRL('D');
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
- mock_keypress[i++] = 'U' & 0x1f;
+ mock_keypress[i++] = VB_KEY_CTRL('U');
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
- mock_keypress[i++] = 'L' & 0x1f;
+ mock_keypress[i++] = VB_KEY_CTRL('L');
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
mock_keypress[i++] = VB_BUTTON_VOL_UP_DOWN_COMBO_PRESS;
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
@@ -1485,11 +1485,11 @@ static void VbBootRecTest(void)
ResetMocksForManualRecovery();
i = 0;
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
- mock_keypress[i++] = 'D' & 0x1f;
+ mock_keypress[i++] = VB_KEY_CTRL('D');
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
- mock_keypress[i++] = 'U' & 0x1f;
+ mock_keypress[i++] = VB_KEY_CTRL('U');
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
- mock_keypress[i++] = 'L' & 0x1f;
+ mock_keypress[i++] = VB_KEY_CTRL('L');
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;
mock_keypress[i++] = VB_BUTTON_VOL_UP_LONG_PRESS;
mock_keypress[i] = VB_KEY_FLAG_TRUSTED_KEYBOARD;