Anastasia Klimchuk has uploaded this change for review.
tests: Add test cases for erasing/writing unaligned layout regions
The test cases from #16 onwards cover the case when layout region is
not aligned with eraseblock region, and therefore either layout start
boundary or end boundary needs to be extended to align with
eraseblock.
Ticket: https://ticket.coreboot.org/issues/494
Change-Id: I726a30b0e47a966e8093ddc19abf4a65fb1d70ce
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
---
M tests/erase_func_algo.c
1 file changed, 91 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/85/78985/1
diff --git a/tests/erase_func_algo.c b/tests/erase_func_algo.c
index 824a03a..029f4a8 100644
--- a/tests/erase_func_algo.c
+++ b/tests/erase_func_algo.c
@@ -28,7 +28,7 @@
#define ERASE_VALUE 0xff
#define MOCK_CHIP_SIZE 16
/* How many small chip test cases. */
-#define TEST_CASES_NUM 16
+#define TEST_CASES_NUM 19
#define MIN_BUF_SIZE 1024 /* Minimum buffer size flashrom operates for chip operations. */
#define MIN_REAL_CHIP_SIZE 1024 /* Minimum chip size that can be defined for real chip in flashchips */
@@ -169,6 +169,26 @@
},
};
+static struct flashchip chip_8_16 = {
+ .vendor = "aklm",
+ /* See comment on previous chip. */
+ .total_size = 1,
+ .tested = TEST_OK_PREW,
+ .gran = WRITE_GRAN_1BYTE,
+ .read = TEST_READ_INJECTOR,
+ .write = TEST_WRITE_INJECTOR,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {8, MIN_REAL_CHIP_SIZE / 8} },
+ .block_erase = TEST_ERASE_INJECTOR,
+ }, {
+ .eraseblocks = { {16, MIN_REAL_CHIP_SIZE / 16} },
+ .block_erase = TEST_ERASE_INJECTOR,
+ }
+ },
+};
+
static void setup_chip(struct flashrom_flashctx *flashctx, struct flashrom_layout **layout,
const char *programmer_param, struct test_case *current_test_case)
{
@@ -230,8 +250,9 @@
/*
* Setup all test cases.
*
- * First half of test cases (0 - (size(testcases)/2-1)) set up for a chip with erasers: 1, 2, 4, 8, 16 bytes.
- * Second half (size(testcases)/2 - size(testcases)) repeates the same test cases for a chip with erasers: 1, 8, 16 bytes.
+ * First half of test cases is set up for a chip with erasers: 1, 2, 4, 8, 16 bytes.
+ * Second half repeates the same test cases for a chip with erasers: 1, 8, 16 bytes.
+ * Last three test cases use the chip with erasers: 8, 16 bytes, to test unaligned layout regions.
*/
static struct test_case test_cases[] = {
{
@@ -593,6 +614,73 @@
.eraseblocks_expected_ind = 16,
.erase_test_name = "Erase test case #15",
.write_test_name = "Write test case #15",
+ }, {
+ /*
+ * Test case #16
+ *
+ * Initial vs written: all 16 bytes are different.
+ * Layout with unaligned regions 8+4+4b which are smaller than the smallest eraseblock.
+ * Chip with eraseblocks 8, 16.
+ */
+ .chip = &chip_8_16,
+ .regions = {{0, 7, "reg8"}, {8, 11, "reg4_a"},
+ {12, MIN_REAL_CHIP_SIZE - 1, "reg4_b"}},
+ .initial_buf = {0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4,
+ 0x5, 0x5, 0x5, 0x5, 0x6, 0x6, 0x6, 0x6},
+ .erased_buf = {ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE,
+ ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE,
+ ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE,
+ ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE},
+ .written_buf = {0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
+ 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16},
+ .eraseblocks_expected = {{0x8, 0x8}, {0x8, 0x8}, {0x0, 0x8}}, // TODO setup correct ones! these are temporary
+ .eraseblocks_expected_ind = 3, // TODO setup correct ones! these are temporary
+ .erase_test_name = "Erase test case #16",
+ .write_test_name = "Write test case #16",
+ }, {
+ /*
+ * Test case #17
+ *
+ * Initial vs written: all 16 bytes are different.
+ * Layout with unaligned region 3+13b which are smaller than the smallest eraseblock.
+ * Chip with eraseblocks 8, 16.
+ */
+ .chip = &chip_8_16,
+ .regions = {{0, 2, "reg3"}, {3, MIN_REAL_CHIP_SIZE - 1, "tail"}},
+ .initial_buf = {0x4, 0x4, 0x4, 0x6, 0x6, 0x6, 0x6, 0x6,
+ 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6},
+ .erased_buf = {ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE,
+ ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE,
+ ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE,
+ 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}}, // TODO setup correct ones! these are temporary
+ .eraseblocks_expected_ind = 2, // TODO setup correct ones! these are temporary
+ .erase_test_name = "Erase test case #17",
+ .write_test_name = "Write test case #17",
+ }, {
+ /*
+ * Test case #18
+ *
+ * Initial vs written: all 16 bytes are different.
+ * Layout with unaligned region 9+7b.
+ * Chip with eraseblocks 8, 16.
+ */
+ .chip = &chip_8_16,
+ .regions = {{0, 8, "reg9"}, {9, MIN_REAL_CHIP_SIZE - 1, "tail"}},
+ .initial_buf = {0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4,
+ 0x4, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6},
+ .erased_buf = {ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE,
+ ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE,
+ ERASE_VALUE, ERASE_VALUE, ERASE_VALUE, ERASE_VALUE,
+ 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}}, // TODO setup correct ones! these are temporary
+ .eraseblocks_expected_ind = 2, // TODO setup correct ones! these are temporary
+ .erase_test_name = "Erase test case #18",
+ .write_test_name = "Write test case #18",
},
};
To view, visit change 78985. To unsubscribe, or for help writing mail filters, visit settings.