Anastasia Klimchuk has uploaded this change for review.

View Change

tests: Check verify op completed in full if chip memory modified

The patch adds new functionality to the test: tracking the areas of
chip memory that were modified (i.e. by erase or write operation),
and then checking those areas were completely covered by verify
operation.

The test operates over the mock chip memory of 16 bytes, so it is
possible to track each byte which was modified, and assert that is
has been verified afterwards.

Note: at the moment the test is not fully working, the following
write test cases fail (all erase test cases pass):

[ FAILED ] Write test case #1
Error: byte 15, modified: 1, verified: 0

[ FAILED ] Write test case #2
1353 Error: byte 7, modified: 1, verified: 0
1354 Error: byte 9, modified: 1, verified: 0
1355 Error: byte 14, modified: 1, verified: 0
1356 Error: byte 15, modified: 1, verified: 0

[ FAILED ] Write test case #10
1494 Error: byte 7, modified: 1, verified: 0
1495 Error: byte 9, modified: 1, verified: 0
1496 Error: byte 14, modified: 1, verified: 0
1497 Error: byte 15, modified: 1, verified: 0

As usual, there are two options: either the test is not fully working
or there is a bug in the code.

Change-Id: I3c5d55a0deb20f23f4072caac8c0dce04cc98fd4
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
---
M tests/erase_func_algo.c
1 file changed, 51 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/78/84078/1
diff --git a/tests/erase_func_algo.c b/tests/erase_func_algo.c
index 576923f..9dce6ca 100644
--- a/tests/erase_func_algo.c
+++ b/tests/erase_func_algo.c
@@ -57,6 +57,8 @@

struct all_state {
uint8_t buf[MIN_REAL_CHIP_SIZE]; /* Buffer emulating the memory of the mock chip. */
+ uint8_t was_modified[MIN_REAL_CHIP_SIZE]; /* Which bytes were modified, 0x1 if byte was modified. */
+ uint8_t was_verified[MIN_REAL_CHIP_SIZE]; /* Which bytes were verified, 0x1 if byte was verified. */
struct erase_invoke eraseblocks_actual[MOCK_CHIP_SIZE]; /* The actual order of eraseblocks invocations. */
unsigned int eraseblocks_actual_ind; /* Actual number of eraseblocks invocations. */
const struct test_case* current_test_case; /* Currently executed test case. */
@@ -70,6 +72,11 @@
assert_in_range(start + len, 0, MIN_REAL_CHIP_SIZE);

memcpy(buf, &g_state.buf[start], len);
+
+ /* If these bytes were modified before => current read op is verify op, track it */
+ if (g_state.was_modified[start] == 0x1)
+ memset(&g_state.was_verified[start], 0x1, len);
+
return 0;
}

@@ -81,6 +88,10 @@
assert_in_range(start + len, 0, MIN_REAL_CHIP_SIZE);

memcpy(&g_state.buf[start], buf, len);
+
+ /* Track the bytes were written */
+ memset(&g_state.was_modified[start], 0x1, len);
+
return 0;
}

@@ -101,6 +112,10 @@
assert_in_range(blockaddr + blocklen, 0, MIN_REAL_CHIP_SIZE);

memset(&g_state.buf[blockaddr], ERASE_VALUE, blocklen);
+
+ /* Track the bytes were erased */
+ memset(&g_state.was_modified[blockaddr], 0x1, blocklen);
+
return 0;
}

@@ -223,6 +238,11 @@
memset(g_state.eraseblocks_actual, 0, MOCK_CHIP_SIZE * sizeof(struct erase_invoke));
g_state.eraseblocks_actual_ind = 0;

+ /* Clear the tracking of each byte modified. */
+ memset(g_state.was_modified, 0, MIN_REAL_CHIP_SIZE);
+ /* Clear the tracking of each byte verified. */
+ memset(g_state.was_verified, 0, MIN_REAL_CHIP_SIZE);
+
flashctx->chip = current_test_case->chip;

printf("Creating layout ... ");
@@ -771,7 +791,7 @@

/*
* Setup all test cases with protected region.
- * Protected region is the same for all test cases, between bytes 8 - 15.
+ * Protected region is the same for all test cases, between bytes START_PROTECTED_REGION and up to END_PROTECTED_REGION.
*/
static struct test_case test_cases_protected_region[] = {
{
@@ -1060,6 +1080,13 @@
int eraseblocks_invocations = (g_state.eraseblocks_actual_ind ==
current_test_case->eraseblocks_expected_ind);

+ int chip_verified = 1;
+ for (int i = 0; i < MOCK_CHIP_SIZE; i++)
+ if (g_state.was_modified[i] == 0x1 && g_state.was_verified[i] != 0x1) {
+ chip_verified = 0; /* byte was modified, but not verified after */
+ printf("Error: byte %d, modified: %d, verified: %d\n", i, g_state.was_modified[i], g_state.was_verified[i]);
+ }
+
if (chip_erased)
printf("Erased chip memory state for %s is CORRECT\n",
current_test_case->erase_test_name);
@@ -1083,10 +1110,18 @@
current_test_case->eraseblocks_expected_ind,
g_state.eraseblocks_actual_ind);

+ if (chip_verified)
+ printf("Erased chip memory state for %s was verified successfully\n",
+ current_test_case->erase_test_name);
+ else
+ printf("Erased chip memory state for %s was NOT verified completely\n",
+ current_test_case->erase_test_name);
+
all_erase_tests_result |= ret;
all_erase_tests_result |= !chip_erased;
all_erase_tests_result |= !eraseblocks_in_order;
all_erase_tests_result |= !eraseblocks_invocations;
+ all_erase_tests_result |= !chip_verified;

teardown_chip(&layout);

@@ -1117,6 +1152,13 @@

int chip_written = !memcmp(g_state.buf, current_test_case->written_buf, MOCK_CHIP_SIZE);

+ int chip_verified = 1;
+ for (int i = 0; i < MOCK_CHIP_SIZE; i++)
+ if (g_state.was_modified[i] == 0x1 && g_state.was_verified[i] != 0x1) {
+ chip_verified = 0; /* the byte was modified, but not verified after */
+ printf("Error: byte %d, modified: %d, verified: %d\n", i, g_state.was_modified[i], g_state.was_verified[i]);
+ }
+
if (chip_written)
printf("Written chip memory state for %s is CORRECT\n",
current_test_case->write_test_name);
@@ -1124,8 +1166,16 @@
printf("Written chip memory state for %s is WRONG\n",
current_test_case->write_test_name);

+ if (chip_verified)
+ printf("Written chip memory state for %s was verified successfully\n",
+ current_test_case->write_test_name);
+ else
+ printf("Written chip memory state for %s was NOT verified completely\n",
+ current_test_case->write_test_name);
+
all_write_test_result |= ret;
all_write_test_result |= !chip_written;
+ all_write_test_result |= !chip_verified;

teardown_chip(&layout);


To view, visit change 84078. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: I3c5d55a0deb20f23f4072caac8c0dce04cc98fd4
Gerrit-Change-Number: 84078
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>