Anastasia Klimchuk has uploaded this change for review.

View Change

tests: Setup mock chip memory in consistent and predictable way

This patch adds a macro MOCK_CHIP_CONTENT which represents a memory
state of a mock chip. The macro is used to initialise mock chip
memory at the beginning of a test (in setup_chip function).

Previously mock chip memory was not reset between tests. For
existing tests that did not matter, however new test for verify
operation (added later in this chain) needs mock chip memory to
be setup in a predictable way.

BUG=b:181803212
TEST=ninja test

Change-Id: I0d7623a601c207bfc62d54ab89d94cda56d85871
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M tests/chip.c
1 file changed, 3 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/37/59237/1
diff --git a/tests/chip.c b/tests/chip.c
index 9c06fe7..a166bb6 100644
--- a/tests/chip.c
+++ b/tests/chip.c
@@ -22,13 +22,14 @@
#include "programmer.h"

#define MOCK_CHIP_SIZE (8*MiB)
+#define MOCK_CHIP_CONTENT 0xff

static struct {
unsigned int unlock_calls; /* how many times unlock function was called */
uint8_t buf[MOCK_CHIP_SIZE]; /* buffer of total size of chip, to emulate a chip */
} g_chip_state = {
.unlock_calls = 0,
- .buf = { 0 },
+ .buf = { MOCK_CHIP_CONTENT },
};

int read_chip(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
@@ -92,6 +93,7 @@
flashctx->chip = chip;

g_chip_state.unlock_calls = 0;
+ memset(&g_chip_state.buf[0], MOCK_CHIP_CONTENT, MOCK_CHIP_SIZE);

printf("Creating layout with one included region... ");
assert_int_equal(0, flashrom_layout_new(layout));

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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I0d7623a601c207bfc62d54ab89d94cda56d85871
Gerrit-Change-Number: 59237
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-MessageType: newchange