diff options
author | Julius Werner <jwerner@chromium.org> | 2019-10-14 16:37:46 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-22 22:03:31 +0000 |
commit | 0320617a0b9abf44eba822e1cb043a87a6e808fe (patch) | |
tree | 1a7ca105c2e4863f2684531c1e08a0c20a0f0a69 /tests | |
parent | ddcec12ff1a033dfc533212ca2012e406a58f458 (diff) | |
download | vboot-0320617a0b9abf44eba822e1cb043a87a6e808fe.tar.gz |
firmware: Don't set recovery reason for removable boot in TryLoadKernel
Right now TryLoadKernel() always sets a recovery reason when it did not
manage to load a kernel for any reason. In many cases (e.g. we're
already in recovery mode, or we're trying to boot off some random USB
stick in dev mode) we don't actually want that to happen, so there are
four different instances of code unconditionally clearing the recovery
reason again right after calling TryLoadKernel().
This is confusing and there's a far simpler solution: only set the
recovery reason when we're booting off a fixed disk. We never want to
set it when trying to boot a removable disk anyway, so centralizing this
distinction right in TryLoadKernel() makes the logic easier to follow.
BRANCH=None
BUG=None
TEST=make runtests, played around with a Kevin
Change-Id: I9d56356b0f3547b3690be2c24cf6936e57e4cf1f
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1859687
Diffstat (limited to 'tests')
-rw-r--r-- | tests/vboot_api_kernel_tests.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/vboot_api_kernel_tests.c b/tests/vboot_api_kernel_tests.c index 1734c386..8c57dee6 100644 --- a/tests/vboot_api_kernel_tests.c +++ b/tests/vboot_api_kernel_tests.c @@ -257,6 +257,38 @@ test_case_t test[] = { .expected_to_load_disk = 0, .expected_return_val = VBERROR_NO_KERNEL_FOUND, }, + { + .name = "invalid kernel (removable)", + .want_flags = VB_DISK_FLAG_REMOVABLE, + .disks_to_provide = { + {512, 100, VB_DISK_FLAG_REMOVABLE, "corrupted"}, + {512, 100, VB_DISK_FLAG_REMOVABLE, "data"}, + }, + .disk_count_to_return = DEFAULT_COUNT, + .diskgetinfo_return_val = VB2_SUCCESS, + .loadkernel_return_val = {VBERROR_INVALID_KERNEL_FOUND, + VBERROR_NO_KERNEL_FOUND}, + + .expected_recovery_request_val = VB2_RECOVERY_NOT_REQUESTED, + .expected_to_find_disk = DONT_CARE, + .expected_to_load_disk = 0, + .expected_return_val = VBERROR_INVALID_KERNEL_FOUND, + }, + { + .name = "no kernel (removable)", + .want_flags = VB_DISK_FLAG_REMOVABLE, + .disks_to_provide = { + {512, 100, VB_DISK_FLAG_REMOVABLE, "data"}, + }, + .disk_count_to_return = DEFAULT_COUNT, + .diskgetinfo_return_val = VB2_SUCCESS, + .loadkernel_return_val = {VBERROR_NO_KERNEL_FOUND}, + + .expected_recovery_request_val = VB2_RECOVERY_NOT_REQUESTED, + .expected_to_find_disk = DONT_CARE, + .expected_to_load_disk = 0, + .expected_return_val = VBERROR_NO_KERNEL_FOUND, + }, }; /****************************************************************************/ |