summaryrefslogtreecommitdiff
path: root/test/nvmem.c
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-01-22 15:26:24 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-01-24 13:22:09 -0800
commit46ab85e60f0bf5e684609adce592a6f96774ce8e (patch)
tree6a2db111cc629acd2c7a1617fcfb1bb1f44a6ce7 /test/nvmem.c
parentd8ba70b296fac3c89b455cc8d096ae74adf6bf49 (diff)
downloadchrome-ec-46ab85e60f0bf5e684609adce592a6f96774ce8e.tar.gz
nvmem: rename version to generation
With upcoming versioning of NVMEM contents let's replace term 'version' with term 'generation' in the existing nvmem implementation. Generation would allow to tell between two instances of NVMEM stored in flash memory. The upcoming version field in the header will be used to tell between different nvmem layouts. This patch was created by invoking the following command: sed -i 's/VERSION/GENERATION/g;s/version/generation/g' \ common/nvmem.c include/nvmem.h test/nvmem.c and then editing a few remaining capitalized instances. This also fixes nvmem test broken by an earlier patch. BRANCH=none BUG=chrome-os-partner:62260 TEST=the following tests succeed: make buildall -j TEST_LIST_HOST=nvmem make runtests booitng reef with cr50 Change-Id: I96e52dc93ca7c52c55794ba3e8c2774571212de0 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/431312 Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'test/nvmem.c')
-rw-r--r--test/nvmem.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/test/nvmem.c b/test/nvmem.c
index 9f007f0191..5ed33f3445 100644
--- a/test/nvmem.c
+++ b/test/nvmem.c
@@ -154,7 +154,7 @@ static int test_configured_nvmem(void)
* partitions are configured and valid.
*/
- /* Configure all NvMem partitions with starting version number 0 */
+ /* Configure all NvMem partitions with starting generation number 0 */
nvmem_setup(0);
/* Call NvMem initialization */
return nvmem_init();
@@ -162,6 +162,7 @@ static int test_configured_nvmem(void)
static int test_corrupt_nvmem(void)
{
+ uint8_t invalid_value = 0x55;
int ret;
struct nvmem_tag *p_part;
uint8_t *p_data;
@@ -174,7 +175,7 @@ static int test_corrupt_nvmem(void)
*/
/* Overwrite each partition will all 0s */
- memset(write_buffer, 0, NVMEM_PARTITION_SIZE);
+ memset(write_buffer, invalid_value, NVMEM_PARTITION_SIZE);
flash_physical_write(CONFIG_FLASH_NVMEM_OFFSET_A,
NVMEM_PARTITION_SIZE,
(const char *)write_buffer);
@@ -192,27 +193,23 @@ static int test_corrupt_nvmem(void)
/* Fill buffer with 0xffs */
memset(write_buffer, 0xff, NVMEM_PARTITION_SIZE);
/*
- * nvmem_setup() will write put version 1 into partition 1 since the
- * commit() function toggles the active partition. Check here that
- * partition 0 has a version number of 1 and that all of the user buffer
- * data has been erased.
+ * nvmem_init() will create generation 0 in partition 0 and commit it.
+ * Check here that partition 0 has a generation number of 0 and that
+ * all of the user buffer data has been erased.
*/
p_part = (struct nvmem_tag *)CONFIG_FLASH_NVMEM_BASE_A;
- TEST_ASSERT(p_part->version == 1);
+ TEST_ASSERT(p_part->generation == 0);
p_data = (uint8_t *)p_part + sizeof(struct nvmem_tag);
/* Verify that partition 0 is fully erased */
TEST_ASSERT_ARRAY_EQ(write_buffer, p_data, NVMEM_PARTITION_SIZE -
sizeof(struct nvmem_tag));
- /* Run the same test for partition 1 which should have version 0 */
- p_part = (struct nvmem_tag *)CONFIG_FLASH_NVMEM_BASE_B;
- TEST_ASSERT(p_part->version == 0);
- p_data = (uint8_t *)p_part + sizeof(struct nvmem_tag);
- ccprintf("Partition Version = %d\n", p_part->version);
- /* Verify that partition 1 is fully erased */
- TEST_ASSERT_ARRAY_EQ(write_buffer, p_data, NVMEM_PARTITION_SIZE -
- sizeof(struct nvmem_tag));
- return ret;
+ /* Verify that partition 1 still has invalid values in it. */
+ p_data = (uint8_t *)CONFIG_FLASH_NVMEM_BASE_B;
+ memset(write_buffer, invalid_value, NVMEM_PARTITION_SIZE);
+ TEST_ASSERT_ARRAY_EQ(write_buffer, p_data, NVMEM_PARTITION_SIZE);
+
+ return EC_SUCCESS;
}
static int test_write_read_sequence(void)