diff options
author | Joel Kitching <kitching@google.com> | 2020-03-20 16:50:48 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-20 09:42:29 +0000 |
commit | cc719d12112eadb578480b26e323f0760e0c13f6 (patch) | |
tree | 17efc8b513817b23980bde63b4e6fc082567af2f /tests | |
parent | 7ea99225b562b49b30fc374065f9dd48ed52f70d (diff) | |
download | vboot-cc719d12112eadb578480b26e323f0760e0c13f6.tar.gz |
vboot: move recovery reason strings to vboot2 namespace
Make recovery reason strings more widely available, and
print them in kernel verification console messages.
Note that we purposely do not print strings in firmware
verification in order to avoid linking recovery reason
strings into coreboot stages.
BUG=b:124141368, chromium:968464
TEST=make clean && make runtests
TEST=trigger recovery, check console logs
BRANCH=none
Change-Id: Ica82a60075da53e4ad0a0403eb8a88685c3bdbd6
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2112321
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/vb2_recovery_reasons_tests.c | 31 | ||||
-rw-r--r-- | tests/vboot_display_tests.c | 6 |
2 files changed, 31 insertions, 6 deletions
diff --git a/tests/vb2_recovery_reasons_tests.c b/tests/vb2_recovery_reasons_tests.c new file mode 100644 index 00000000..c1cb95b6 --- /dev/null +++ b/tests/vb2_recovery_reasons_tests.c @@ -0,0 +1,31 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Tests for recovery reasons. + */ + +#include "2recovery_reasons.h" +#include "test_common.h" + +static void get_recovery_reason_string_tests(void) +{ + int i; + + /* Recovery string should be non-null for any code */ + for (i = 0; i < 0x100; i++) + TEST_PTR_NEQ(vb2_get_recovery_reason_string(i), NULL, + "Non-null reason"); + + /* Sanity check on one of the strings */ + TEST_EQ(strcmp(vb2_get_recovery_reason_string(VB2_RECOVERY_GBB_HEADER), + "Error parsing GBB header"), 0, + "Recovery reason sanity check"); +} + +int main(void) +{ + get_recovery_reason_string_tests(); + + return gTestSuccess ? 0 : 255; +} diff --git a/tests/vboot_display_tests.c b/tests/vboot_display_tests.c index a640556c..b57915fb 100644 --- a/tests/vboot_display_tests.c +++ b/tests/vboot_display_tests.c @@ -73,12 +73,6 @@ vb2_error_t vb2ex_commit_data(struct vb2_context *c) /* Test displaying debug info */ static void DebugInfoTest(void) { - int i; - - /* Recovery string should be non-null for any code */ - for (i = 0; i < 0x100; i++) - TEST_PTR_NEQ(RecoveryReasonString(i), NULL, "Non-null reason"); - /* Display debug info */ ResetMocks(); TEST_SUCC(VbDisplayDebugInfo(ctx), |