summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2014-09-23 12:20:31 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-04 00:59:48 +0000
commit782300d093a2fbf2ca24e446fb6d65f9f28e56a6 (patch)
tree07e711928061b4b1c19845ca6bb17f4992ae5487 /tests
parent80872dbffcb2e0079bfe095d770ccc6c8bd5fd7a (diff)
downloadvboot-782300d093a2fbf2ca24e446fb6d65f9f28e56a6.tar.gz
vboot2: Add previously tried slot and result to NV storage
This gives recovery mode information on two boots back instead of one, which may be handy for debugging. It also allows determining whether a failure of the current boot should try the other slot or go to recovery, using only information stored in NV storage. Added crossystem support for printing the fields, and unit tests. BUG=chrome-os-partner:32585 BRANCH=none TEST=make runtests; VBOOT2=1 make runtests Change-Id: Ia9f4186210d30217b902db7c513ae4ab8851f8f4 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221230 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/vb2_misc_tests.c17
-rw-r--r--tests/vb2_nvstorage_tests.c2
-rw-r--r--tests/vboot_nvstorage_test.c2
3 files changed, 21 insertions, 0 deletions
diff --git a/tests/vb2_misc_tests.c b/tests/vb2_misc_tests.c
index 72c284c6..6155f23e 100644
--- a/tests/vb2_misc_tests.c
+++ b/tests/vb2_misc_tests.c
@@ -450,6 +450,23 @@ static void select_slot_tests(void)
TEST_EQ(sd->fw_slot, 0, "selected A");
TEST_EQ(cc.flags & VB2_CONTEXT_FW_SLOT_B, 0, "didn't choose B");
TEST_EQ(vb2_nv_get(&cc, VB2_NV_TRY_COUNT), 2, "tries decremented");
+
+ /* Tried/result get copied to the previous fields */
+ reset_common_data();
+ vb2_nv_set(&cc, VB2_NV_FW_TRIED, 0);
+ vb2_nv_set(&cc, VB2_NV_FW_RESULT, VB2_FW_RESULT_SUCCESS);
+ vb2_select_fw_slot(&cc);
+ TEST_EQ(vb2_nv_get(&cc, VB2_NV_FW_PREV_TRIED), 0, "prev A");
+ TEST_EQ(vb2_nv_get(&cc, VB2_NV_FW_PREV_RESULT), VB2_FW_RESULT_SUCCESS,
+ "prev success");
+
+ reset_common_data();
+ vb2_nv_set(&cc, VB2_NV_FW_TRIED, 1);
+ vb2_nv_set(&cc, VB2_NV_FW_RESULT, VB2_FW_RESULT_FAILURE);
+ vb2_select_fw_slot(&cc);
+ TEST_EQ(vb2_nv_get(&cc, VB2_NV_FW_PREV_TRIED), 1, "prev B");
+ TEST_EQ(vb2_nv_get(&cc, VB2_NV_FW_PREV_RESULT), VB2_FW_RESULT_FAILURE,
+ "prev failure");
}
int main(int argc, char* argv[])
diff --git a/tests/vb2_nvstorage_tests.c b/tests/vb2_nvstorage_tests.c
index b648ca95..46547f8f 100644
--- a/tests/vb2_nvstorage_tests.c
+++ b/tests/vb2_nvstorage_tests.c
@@ -34,6 +34,8 @@ static struct nv_field nvfields[] = {
{VB2_NV_TRY_COUNT, 0, 6, 15, "try B count"},
{VB2_NV_FW_TRIED, 0, 1, 0, "firmware tried"},
{VB2_NV_FW_RESULT, 0, 1, 2, "firmware result"},
+ {VB2_NV_FW_PREV_TRIED, 0, 1, 0, "firmware prev tried"},
+ {VB2_NV_FW_PREV_RESULT, 0, 1, 3, "firmware prev result"},
{VB2_NV_RECOVERY_REQUEST, 0, 0x42, 0xED, "recovery request"},
{VB2_NV_RECOVERY_SUBCODE, 0, 0x56, 0xAC, "recovery subcode"},
{VB2_NV_LOCALIZATION_INDEX, 0, 0x69, 0xB0, "localization index"},
diff --git a/tests/vboot_nvstorage_test.c b/tests/vboot_nvstorage_test.c
index 2d096182..ec857382 100644
--- a/tests/vboot_nvstorage_test.c
+++ b/tests/vboot_nvstorage_test.c
@@ -41,6 +41,8 @@ static VbNvField nvfields[] = {
{VBNV_FW_TRY_NEXT, 0, 1, 0, "try next"},
{VBNV_FW_TRIED, 0, 1, 0, "firmware tried"},
{VBNV_FW_RESULT, VBNV_FW_RESULT_UNKNOWN, 1, 2, "firmware result"},
+ {VBNV_FW_PREV_TRIED, 0, 1, 0, "firmware prev tried"},
+ {VBNV_FW_PREV_RESULT, VBNV_FW_RESULT_UNKNOWN, 1, 3, "firmware prev result"},
{0, 0, 0, 0, NULL}
};