1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-28 15:33:42 +02:00

tests: Set up 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>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/59237
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
Anastasia Klimchuk 2021-11-12 16:22:29 +11:00 committed by Edward O'Callaghan
parent 94f91ef864
commit 3f8d1b4f2b

View File

@ -23,6 +23,7 @@
#include "programmer.h" #include "programmer.h"
#define MOCK_CHIP_SIZE (8*MiB) #define MOCK_CHIP_SIZE (8*MiB)
#define MOCK_CHIP_CONTENT 0xff
static struct { static struct {
unsigned int unlock_calls; /* how many times unlock function was called */ unsigned int unlock_calls; /* how many times unlock function was called */
@ -93,6 +94,7 @@ static void setup_chip(struct flashrom_flashctx *flashctx, struct flashrom_layou
flashctx->chip = chip; flashctx->chip = chip;
g_chip_state.unlock_calls = 0; g_chip_state.unlock_calls = 0;
memset(g_chip_state.buf, MOCK_CHIP_CONTENT, sizeof(g_chip_state.buf));
printf("Creating layout with one included region... "); printf("Creating layout with one included region... ");
assert_int_equal(0, flashrom_layout_new(layout)); assert_int_equal(0, flashrom_layout_new(layout));