diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2019-04-30 10:33:47 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-01 11:02:59 -0700 |
commit | 15bd8639ef6df248b4474808bd21d80b0c19bac4 (patch) | |
tree | 64bb5fd2113ab11b9849b30ee676781ced33e8bf /test/nvmem.c | |
parent | 13089909211c5289c46d22a3cb7fb9b06efcd917 (diff) | |
download | chrome-ec-15bd8639ef6df248b4474808bd21d80b0c19bac4.tar.gz |
nvmem: add test of recovery from interrupted saves
Add a test which introduces corrupted objects in the flash and
verifies that the initialization function is able to recover.
BRANCH=cr50, cr50-mp
BUG=b:69907320, b:129710256
TEST='make run-nvmem' succeeds
Change-Id: Ibb7d8181dfdeb097b79087cdae824564ec28921f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1590044
Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'test/nvmem.c')
-rw-r--r-- | test/nvmem.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/nvmem.c b/test/nvmem.c index a7e339ebf1..52cf40138a 100644 --- a/test/nvmem.c +++ b/test/nvmem.c @@ -828,6 +828,7 @@ static int test_nvmem_incomplete_transaction(void) uint16_t offsets[MAX_OFFSETS]; size_t num_objects; uint8_t buf[nvmem_user_sizes[NVMEM_TPM]]; + uint8_t *p; TEST_ASSERT(prepare_post_migration_nvmem() == EC_SUCCESS); num_objects = fill_obj_offsets(offsets, ARRAY_SIZE(offsets)); @@ -859,6 +860,19 @@ static int test_nvmem_incomplete_transaction(void) num_objects = fill_obj_offsets(offsets, ARRAY_SIZE(offsets)); TEST_ASSERT(num_objects == 7); + /* + * Now, let's modify an object and introduce corruption when saving + * it. + */ + p = evictable_offs_to_addr(offsets[4]); + p[10] ^= 0x55; + failure_mode = TEST_FAILED_HASH; + new_nvmem_save(); + failure_mode = TEST_NO_FAILURE; + + /* And verify that nvmem can still successfully initialize. */ + TEST_ASSERT(nvmem_init() == EC_SUCCESS); + return EC_SUCCESS; } |