Peter Marheine submitted this change.

View Change

Approvals: Anastasia Klimchuk: Looks good to me, approved build bot (Jenkins): Verified
tests/erase: record the opcode for each erase

This allows tests to verify that the correct opcode is used when
erasing, which is required to unit-test the fix to issue #525 where in
some situations an incorrect erase opcode will be used.

BUG=https://ticket.coreboot.org/issues/525

Change-Id: I3983fe42c2e7f06668a1bd20d2db7fafa93b8043
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/82251
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
---
M flashrom.c
M include/flash.h
M tests/chip.c
M tests/erase_func_algo.c
M tests/meson.build
5 files changed, 157 insertions(+), 58 deletions(-)

diff --git a/flashrom.c b/flashrom.c
index a365303..a056929 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -402,8 +402,10 @@
return 0;
}

-/* special unit-test hook */
-erasefunc_t *g_test_erase_injector;
+#ifdef FLASHROM_TEST
+/* special unit-test hooks */
+erasefunc_t *g_test_erase_injector[NUM_TEST_ERASE_INJECTORS];
+#endif

erasefunc_t *lookup_erase_func_ptr(const struct block_eraser *const eraser)
{
@@ -442,7 +444,14 @@
case ERASE_SECTOR_49LFXXXC: return &erase_sector_49lfxxxc;
case STM50_SECTOR_ERASE: return &erase_sector_stm50; // TODO rename to &stm50_sector_erase;
case EDI_CHIP_BLOCK_ERASE: return &edi_chip_block_erase;
- case TEST_ERASE_INJECTOR: return g_test_erase_injector;
+#ifdef FLASHROM_TEST
+ case TEST_ERASE_INJECTOR_1:
+ case TEST_ERASE_INJECTOR_2:
+ case TEST_ERASE_INJECTOR_3:
+ case TEST_ERASE_INJECTOR_4:
+ case TEST_ERASE_INJECTOR_5:
+ return g_test_erase_injector[eraser->block_erase - TEST_ERASE_INJECTOR_1];
+#endif
/* default: total function, 0 indicates no erase function set.
* We explicitly do not want a default catch-all case in the switch
* to ensure unhandled enum's are compiler warnings.
@@ -540,8 +549,10 @@
return ret;
}

+#ifdef FLASHROM_TEST
/* special unit-test hook */
read_func_t *g_test_read_injector;
+#endif

static read_func_t *lookup_read_func_ptr(const struct flashchip *chip)
{
@@ -552,7 +563,9 @@
case EDI_CHIP_READ: return &edi_chip_read;
case SPI_READ_AT45DB: return spi_read_at45db;
case SPI_READ_AT45DB_E8: return spi_read_at45db_e8;
+#ifdef FLASHROM_TEST
case TEST_READ_INJECTOR: return g_test_read_injector;
+#endif
/* default: total function, 0 indicates no read function set.
* We explicitly do not want a default catch-all case in the switch
* to ensure unhandled enum's are compiler warnings.
@@ -976,7 +989,9 @@
}

/* special unit-test hook */
+#ifdef FLASHROM_TEST
write_func_t *g_test_write_injector;
+#endif

static write_func_t *lookup_write_func_ptr(const struct flashchip *chip)
{
@@ -992,7 +1007,9 @@
case WRITE_82802AB: return &write_82802ab;
case WRITE_EN29LV640B: return &write_en29lv640b;
case EDI_CHIP_WRITE: return &edi_chip_write;
+#ifdef FLASHROM_TEST
case TEST_WRITE_INJECTOR: return g_test_write_injector;
+#endif
/* default: total function, 0 indicates no write function set.
* We explicitly do not want a default catch-all case in the switch
* to ensure unhandled enum's are compiler warnings.
diff --git a/include/flash.h b/include/flash.h
index 284461e..aa89409 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -266,10 +266,16 @@
WRITE_82802AB,
WRITE_EN29LV640B,
EDI_CHIP_WRITE,
+#ifdef FLASHROM_TEST
TEST_WRITE_INJECTOR, /* special case must come last. */
+#endif
};
typedef int (write_func_t)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);

+#ifdef FLASHROM_TEST
+extern write_func_t *g_test_write_injector;
+#endif
+
enum read_func {
NO_READ_FUNC = 0, /* 0 indicates no read function set. */
SPI_CHIP_READ = 1,
@@ -278,11 +284,17 @@
EDI_CHIP_READ,
SPI_READ_AT45DB,
SPI_READ_AT45DB_E8,
+#ifdef FLASHROM_TEST
TEST_READ_INJECTOR, /* special case must come last. */
+#endif
};
typedef int (read_func_t)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
int read_flash(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);

+#ifdef FLASHROM_TEST
+extern read_func_t *g_test_read_injector;
+#endif
+
enum block_erase_func {
NO_BLOCK_ERASE_FUNC = 0, /* 0 indicates no block erase function set. */
SPI_BLOCK_ERASE_EMULATION = 1,
@@ -319,9 +331,21 @@
ERASE_SECTOR_49LFXXXC,
STM50_SECTOR_ERASE,
EDI_CHIP_BLOCK_ERASE,
- TEST_ERASE_INJECTOR, /* special case must come last. */
+#ifdef FLASHROM_TEST
+ /* special cases must come last. */
+ TEST_ERASE_INJECTOR_1,
+ TEST_ERASE_INJECTOR_2,
+ TEST_ERASE_INJECTOR_3,
+ TEST_ERASE_INJECTOR_4,
+ TEST_ERASE_INJECTOR_5,
+#endif
};

+#ifdef FLASHROM_TEST
+#define NUM_TEST_ERASE_INJECTORS 5
+extern erasefunc_t *g_test_erase_injector[NUM_TEST_ERASE_INJECTORS];
+#endif
+
enum blockprotect_func {
NO_BLOCKPROTECT_FUNC = 0, /* 0 indicates no unlock function set. */
SPI_DISABLE_BLOCKPROTECT,
diff --git a/tests/chip.c b/tests/chip.c
index 96be7b1..3e1ae3b 100644
--- a/tests/chip.c
+++ b/tests/chip.c
@@ -118,10 +118,6 @@
io_mock_register(NULL);
}

-extern write_func_t *g_test_write_injector;
-extern read_func_t *g_test_read_injector;
-extern erasefunc_t *g_test_erase_injector;
-
static const struct flashchip chip_8MiB = {
.vendor = "aklm",
.total_size = MOCK_CHIP_SIZE / KiB,
@@ -132,7 +128,7 @@
{{
/* All blocks within total size of the chip. */
.eraseblocks = { {2 * MiB, 4} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_1,
}},
};

@@ -179,7 +175,7 @@

g_test_write_injector = write_chip;
g_test_read_injector = read_chip;
- g_test_erase_injector = block_erase_chip;
+ g_test_erase_injector[0] = block_erase_chip;
struct flashrom_flashctx flashctx = { 0 };
struct flashrom_layout *layout;
struct flashchip mock_chip = chip_8MiB;
@@ -238,7 +234,7 @@

g_test_write_injector = write_chip;
g_test_read_injector = read_chip;
- g_test_erase_injector = block_erase_chip;
+ g_test_erase_injector[0] = block_erase_chip;
struct flashrom_flashctx flashctx = { 0 };
struct flashrom_layout *layout;
struct flashchip mock_chip = chip_8MiB;
@@ -313,7 +309,7 @@

g_test_write_injector = write_chip;
g_test_read_injector = read_chip;
- g_test_erase_injector = block_erase_chip;
+ g_test_erase_injector[0] = block_erase_chip;
struct flashrom_flashctx flashctx = { 0 };
struct flashrom_layout *layout;
struct flashchip mock_chip = chip_8MiB;
@@ -504,7 +500,7 @@

g_test_write_injector = write_chip;
g_test_read_injector = read_chip;
- g_test_erase_injector = block_erase_chip;
+ g_test_erase_injector[0] = block_erase_chip;
struct flashrom_flashctx flashctx = { 0 };
struct flashrom_layout *layout;
struct flashchip mock_chip = chip_8MiB;
diff --git a/tests/erase_func_algo.c b/tests/erase_func_algo.c
index ed9eb04..b0969c2 100644
--- a/tests/erase_func_algo.c
+++ b/tests/erase_func_algo.c
@@ -39,6 +39,7 @@
struct erase_invoke {
unsigned int blockaddr;
unsigned int blocklen;
+ enum block_erase_func erase_func;
};

struct test_case {
@@ -82,16 +83,17 @@
return 0;
}

-static int block_erase_chip(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen)
+static int block_erase_chip_tagged(struct flashctx *flash, enum block_erase_func erase_func, unsigned int blockaddr, unsigned int blocklen)
{
if (blockaddr + blocklen <= MOCK_CHIP_SIZE) {
LOG_ERASE_FUNC;

/* Register eraseblock invocation. */
- g_state.eraseblocks_actual[g_state.eraseblocks_actual_ind].blocklen
- = blocklen;
- g_state.eraseblocks_actual[g_state.eraseblocks_actual_ind].blockaddr
- = blockaddr;
+ g_state.eraseblocks_actual[g_state.eraseblocks_actual_ind] = (struct erase_invoke){
+ .blocklen = blocklen,
+ .blockaddr = blockaddr,
+ .erase_func = erase_func,
+ };
g_state.eraseblocks_actual_ind++;
}

@@ -101,10 +103,6 @@
return 0;
}

-extern write_func_t *g_test_write_injector;
-extern read_func_t *g_test_read_injector;
-extern erasefunc_t *g_test_erase_injector;
-
static struct flashchip chip_1_2_4_8_16 = {
.vendor = "aklm",
/*
@@ -127,19 +125,19 @@
{
{
.eraseblocks = { {1, MIN_REAL_CHIP_SIZE} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_1,
}, {
.eraseblocks = { {2, MIN_REAL_CHIP_SIZE / 2} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_2,
}, {
.eraseblocks = { {4, MIN_REAL_CHIP_SIZE / 4} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_3,
}, {
.eraseblocks = { {8, MIN_REAL_CHIP_SIZE / 8} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_4,
}, {
.eraseblocks = { {16, MIN_REAL_CHIP_SIZE / 16} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_5,
}
},
};
@@ -156,13 +154,13 @@
{
{
.eraseblocks = { {1, MIN_REAL_CHIP_SIZE} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_1,
}, {
.eraseblocks = { {8, MIN_REAL_CHIP_SIZE / 8} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_4,
}, {
.eraseblocks = { {16, MIN_REAL_CHIP_SIZE / 16} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_5,
}
},
};
@@ -179,20 +177,41 @@
{
{
.eraseblocks = { {8, MIN_REAL_CHIP_SIZE / 8} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_4,
}, {
.eraseblocks = { {16, MIN_REAL_CHIP_SIZE / 16} },
- .block_erase = TEST_ERASE_INJECTOR,
+ .block_erase = TEST_ERASE_INJECTOR_5,
}
},
};

+#define BLOCK_ERASE_FUNC(n) \
+ static int block_erase_chip_ ## n (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen) { \
+ return block_erase_chip_tagged(flash, TEST_ERASE_INJECTOR_ ## n, blockaddr, blocklen); \
+ }
+BLOCK_ERASE_FUNC(1)
+BLOCK_ERASE_FUNC(2)
+BLOCK_ERASE_FUNC(3)
+BLOCK_ERASE_FUNC(4)
+BLOCK_ERASE_FUNC(5)
+
static void setup_chip(struct flashrom_flashctx *flashctx, struct flashrom_layout **layout,
const char *programmer_param, struct test_case *current_test_case)
{
g_test_write_injector = write_chip;
g_test_read_injector = read_chip;
- g_test_erase_injector = block_erase_chip;
+ /* Each erasefunc corresponds to an operation that erases a block of
+ * the chip with a particular size in bytes. */
+ memcpy(g_test_erase_injector,
+ (erasefunc_t *const[]){
+ block_erase_chip_1, // 1 byte
+ block_erase_chip_2, // 2 bytes
+ block_erase_chip_3, // 4 bytes
+ block_erase_chip_4, // 8 bytes
+ block_erase_chip_5, // 16 bytes
+ },
+ sizeof(g_test_erase_injector)
+ );

/* First MOCK_CHIP_SIZE bytes have a meaning and set with given values for this test case. */
memcpy(g_state.buf, current_test_case->initial_buf, MOCK_CHIP_SIZE);
@@ -271,7 +290,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #0",
.write_test_name = "Write test case #0",
@@ -293,7 +312,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f},
- .eraseblocks_expected = {{0x8, 0x8}, {0x0, 0x8}},
+ .eraseblocks_expected = {{0x8, 0x8, TEST_ERASE_INJECTOR_4}, {0x0, 0x8, TEST_ERASE_INJECTOR_4}},
.eraseblocks_expected_ind = 2,
.erase_test_name = "Erase test case #1",
.write_test_name = "Write test case #1",
@@ -315,7 +334,13 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0xff, 0xff, 0x0, 0xff, 0x0, 0xff, 0x20, 0x2f,
0x20, 0x2f, 0x0, 0xff, 0xff, 0xff, 0x2f, 0x2f},
- .eraseblocks_expected = {{0xb, 0x1}, {0xc, 0x4}, {0xa, 0x1}, {0x8, 0x2}, {0x0, 0x8}},
+ .eraseblocks_expected = {
+ {0xb, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xc, 0x4, TEST_ERASE_INJECTOR_3},
+ {0xa, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x8, 0x2, TEST_ERASE_INJECTOR_2},
+ {0x0, 0x8, TEST_ERASE_INJECTOR_4}
+ },
.eraseblocks_expected_ind = 5,
.erase_test_name = "Erase test case #2",
.write_test_name = "Write test case #2",
@@ -337,7 +362,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0xff, 0xff, 0xff, 0xff, 0x1, 0x2, 0x3, 0x4,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #3",
.write_test_name = "Write test case #3",
@@ -359,7 +384,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x11, 0x22, 0x33, 0x44, 0xff, 0xff, 0xff, 0xff,
0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #4",
.write_test_name = "Write test case #4",
@@ -381,7 +406,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0xff,
0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #5",
.write_test_name = "Write test case #5",
@@ -403,7 +428,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xdd,
0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #6",
.write_test_name = "Write test case #6",
@@ -425,8 +450,16 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f},
- .eraseblocks_expected = {{0xf, 0x1}, {0xe, 0x1}, {0xc, 0x2}, {0x8, 0x4},
- {0x3, 0x1}, {0x4, 0x4}, {0x2, 0x1}, {0x0, 0x2}},
+ .eraseblocks_expected = {
+ {0xf, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xe, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xc, 0x2, TEST_ERASE_INJECTOR_2},
+ {0x8, 0x4, TEST_ERASE_INJECTOR_3},
+ {0x3, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x4, 0x4, TEST_ERASE_INJECTOR_3},
+ {0x2, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x0, 0x2, TEST_ERASE_INJECTOR_2}
+ },
.eraseblocks_expected_ind = 8,
.erase_test_name = "Erase test case #7",
.write_test_name = "Write test case #7",
@@ -448,7 +481,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #8",
.write_test_name = "Write test case #8",
@@ -471,7 +504,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f},
- .eraseblocks_expected = {{0x8, 0x8}, {0x0, 0x8}},
+ .eraseblocks_expected = {{0x8, 0x8, TEST_ERASE_INJECTOR_4}, {0x0, 0x8, TEST_ERASE_INJECTOR_4}},
.eraseblocks_expected_ind = 2,
.erase_test_name = "Erase test case #9",
.write_test_name = "Write test case #9",
@@ -493,8 +526,17 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0xff, 0xff, 0x0, 0xff, 0x0, 0xff, 0x20, 0x2f,
0x20, 0x2f, 0x0, 0xff, 0xff, 0xff, 0x2f, 0x2f},
- .eraseblocks_expected = {{0xb, 0x1}, {0xc, 0x1}, {0xd, 0x1}, {0xe, 0x1},
- {0xf, 0x1}, {0x8, 0x1}, {0x9, 0x1}, {0xa, 0x1}, {0x0, 0x8}},
+ .eraseblocks_expected = {
+ {0xb, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xc, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xd, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xe, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xf, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x8, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x9, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xa, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x0, 0x8, TEST_ERASE_INJECTOR_4}
+ },
.eraseblocks_expected_ind = 9,
.erase_test_name = "Erase test case #10",
.write_test_name = "Write test case #10",
@@ -516,7 +558,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0xff, 0xff, 0xff, 0xff, 0x1, 0x2, 0x3, 0x4,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #11",
.write_test_name = "Write test case #11",
@@ -538,7 +580,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x11, 0x22, 0x33, 0x44, 0xff, 0xff, 0xff, 0xff,
0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #12",
.write_test_name = "Write test case #12",
@@ -560,7 +602,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0xff,
0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #13",
.write_test_name = "Write test case #13",
@@ -582,7 +624,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xdd,
0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8},
- .eraseblocks_expected = {{0x0, 0x10}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #14",
.write_test_name = "Write test case #14",
@@ -605,10 +647,24 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f},
- .eraseblocks_expected = {{0xf, 0x1}, {0x8, 0x1}, {0x9, 0x1}, {0xa, 0x1},
- {0xb, 0x1}, {0xc, 0x1}, {0xd, 0x1}, {0xe, 0x1},
- {0x3, 0x1}, {0x4, 0x1}, {0x5, 0x1}, {0x6, 0x1},
- {0x7, 0x1}, {0x0, 0x1}, {0x1, 0x1}, {0x2, 0x1}},
+ .eraseblocks_expected = {
+ {0xf, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x8, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x9, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xa, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xb, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xc, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xd, 0x1, TEST_ERASE_INJECTOR_1},
+ {0xe, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x3, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x4, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x5, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x6, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x7, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x0, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x1, 0x1, TEST_ERASE_INJECTOR_1},
+ {0x2, 0x1, TEST_ERASE_INJECTOR_1},
+ },
.eraseblocks_expected_ind = 16,
.erase_test_name = "Erase test case #15",
.write_test_name = "Write test case #15",
@@ -631,7 +687,12 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16,
0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x17},
- .eraseblocks_expected = {{0x8, 0x8}, {0x0, 0x10}, {0x0, 0x8}, {0x0, 0x8}},
+ .eraseblocks_expected = {
+ {0x8, 0x8, TEST_ERASE_INJECTOR_4},
+ {0x0, 0x10, TEST_ERASE_INJECTOR_5},
+ {0x0, 0x8, TEST_ERASE_INJECTOR_4},
+ {0x0, 0x8, TEST_ERASE_INJECTOR_4},
+ },
.eraseblocks_expected_ind = 4,
.erase_test_name = "Erase test case #16",
.write_test_name = "Write test case #16",
@@ -653,7 +714,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x14, 0x14, 0x14, 0x16, 0x16, 0x16, 0x16, 0x16,
0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16},
- .eraseblocks_expected = {{0x0, 0x10}, {0x0, 0x8}},
+ .eraseblocks_expected = {{0x0, 0x10, TEST_ERASE_INJECTOR_5}, {0x0, 0x8, TEST_ERASE_INJECTOR_4}},
.eraseblocks_expected_ind = 2,
.erase_test_name = "Erase test case #17",
.write_test_name = "Write test case #17",
@@ -675,7 +736,7 @@
ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
.written_buf = {0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
0x14, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16},
- .eraseblocks_expected = {{0x8, 0x8}, {0x0, 0x10}},
+ .eraseblocks_expected = {{0x8, 0x8, TEST_ERASE_INJECTOR_4}, {0x0, 0x10, TEST_ERASE_INJECTOR_5}},
.eraseblocks_expected_ind = 2,
.erase_test_name = "Erase test case #18",
.write_test_name = "Write test case #18",
@@ -696,7 +757,7 @@
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
.written_buf = {0x14, 0x14, 0x14, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
- .eraseblocks_expected = {{0x0, 0x8}},
+ .eraseblocks_expected = {{0x0, 0x8, TEST_ERASE_INJECTOR_4}},
.eraseblocks_expected_ind = 1,
.erase_test_name = "Erase test case #19",
.write_test_name = "Write test case #19",
diff --git a/tests/meson.build b/tests/meson.build
index e8de4b7..e788b80 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -124,6 +124,7 @@
'-ffunction-sections',
'-fdata-sections',
'-U_FORTIFY_SOURCE',
+ '-DFLASHROM_TEST',
],
export_dynamic : true,
link_args : mocks + link_args,

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

Gerrit-MessageType: merged
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: I3983fe42c2e7f06668a1bd20d2db7fafa93b8043
Gerrit-Change-Number: 82251
Gerrit-PatchSet: 9
Gerrit-Owner: Peter Marheine <pmarheine@chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Nikolai Artemiev <nartemiev@google.com>
Gerrit-Reviewer: Peter Marheine <pmarheine@chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>