summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-08-16 11:48:40 +1000
committerFelix Singer <felixsinger@posteo.net>2022-11-01 01:15:55 +0000
commit985ad5623f8c2695ffc07d4bdbacbf2d85d4c11a (patch)
tree5daf0509a2d95fc2c9bffd77f562c2e14eb80bc0 /tests
parent10e7a0ebd74db72f00b8fc1b741f411d5a49b92d (diff)
downloadflashrom-985ad5623f8c2695ffc07d4bdbacbf2d85d4c11a.tar.gz
flashrom-985ad5623f8c2695ffc07d4bdbacbf2d85d4c11a.tar.bz2
flashrom-985ad5623f8c2695ffc07d4bdbacbf2d85d4c11a.zip
tree/: Convert flashchip write func ptr to enumerate
This forges the way for flashchips.c to be pure declarative data and lookup functions for dispatch to be pure. This means that the flashchips data could be extracted out to be agnostic data of the flashrom code and algorithms. TEST='R|W|E && --flash-name' on ARM, AMD & Intel DUT's. Change-Id: I80149de169464b204fb09f1424a86fc645b740fd Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/66782 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-by: Felix Singer <felixsinger@posteo.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/chip.c10
-rw-r--r--tests/chip_wp.c2
-rw-r--r--tests/spi25.c2
3 files changed, 10 insertions, 4 deletions
diff --git a/tests/chip.c b/tests/chip.c
index 6f0317264..284b7e400 100644
--- a/tests/chip.c
+++ b/tests/chip.c
@@ -146,12 +146,14 @@ static void teardown(struct flashrom_layout **layout)
io_mock_register(NULL);
}
+extern write_func_t *g_test_write_injector;
+
static const struct flashchip chip_8MiB = {
.vendor = "aklm",
.total_size = MOCK_CHIP_SIZE / KiB,
.tested = TEST_OK_PREW,
.read = read_chip,
- .write = write_chip,
+ .write = TEST_WRITE_INJECTOR,
.unlock = unlock_chip,
.block_erasers =
{{
@@ -167,7 +169,7 @@ static const struct flashchip chip_W25Q128_V = {
.total_size = 16 * 1024,
.tested = TEST_OK_PREW,
.read = spi_chip_read,
- .write = spi_chip_write_256,
+ .write = SPI_CHIP_WRITE256,
.unlock = spi_disable_blockprotect,
.page_size = 256,
.block_erasers =
@@ -203,6 +205,7 @@ void erase_chip_test_success(void **state)
.fallback_open_state = &data,
};
+ g_test_write_injector = write_chip;
struct flashrom_flashctx flashctx = { 0 };
struct flashrom_layout *layout;
struct flashchip mock_chip = chip_8MiB;
@@ -261,6 +264,7 @@ void read_chip_test_success(void **state)
.fallback_open_state = &data,
};
+ g_test_write_injector = write_chip;
struct flashrom_flashctx flashctx = { 0 };
struct flashrom_layout *layout;
struct flashchip mock_chip = chip_8MiB;
@@ -332,6 +336,7 @@ void write_chip_test_success(void **state)
.fallback_open_state = &data,
};
+ g_test_write_injector = write_chip;
struct flashrom_flashctx flashctx = { 0 };
struct flashrom_layout *layout;
struct flashchip mock_chip = chip_8MiB;
@@ -429,6 +434,7 @@ void verify_chip_test_success(void **state)
.fallback_open_state = &data,
};
+ g_test_write_injector = write_chip;
struct flashrom_flashctx flashctx = { 0 };
struct flashrom_layout *layout;
struct flashchip mock_chip = chip_8MiB;
diff --git a/tests/chip_wp.c b/tests/chip_wp.c
index e4eff9907..3c9be4099 100644
--- a/tests/chip_wp.c
+++ b/tests/chip_wp.c
@@ -65,7 +65,7 @@ static const struct flashchip chip_W25Q128_V = {
.total_size = 16 * 1024,
.tested = TEST_OK_PREW,
.read = spi_chip_read,
- .write = spi_chip_write_256,
+ .write = SPI_CHIP_WRITE256,
.unlock = spi_disable_blockprotect,
.feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_WRSR_EXT2 | FEATURE_WRSR2 | FEATURE_WRSR3,
.block_erasers =
diff --git a/tests/spi25.c b/tests/spi25.c
index 5cd84fb85..872959341 100644
--- a/tests/spi25.c
+++ b/tests/spi25.c
@@ -32,7 +32,7 @@ struct flashchip mock_chip = {
.page_size = 256,
.tested = TEST_BAD_PREW,
.probe = PROBE_SPI_RDID,
- .write = NULL,
+ .write = NO_WRITE_FUNC,
};
/*