summaryrefslogtreecommitdiffstats
path: root/tests/chip.c
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2022-01-17 15:40:18 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2022-01-19 22:57:27 +0000
commit9aaa66cc7fd6a93fd90b5cc061f82c87365b0caa (patch)
tree3ecad19318fd77e3833a0950c3f7fa1f5dcf347f /tests/chip.c
parentdf9aada04e0e24e1f368861a90997f15ca2de2c4 (diff)
downloadflashrom-9aaa66cc7fd6a93fd90b5cc061f82c87365b0caa.tar.gz
flashrom-9aaa66cc7fd6a93fd90b5cc061f82c87365b0caa.tar.bz2
flashrom-9aaa66cc7fd6a93fd90b5cc061f82c87365b0caa.zip
tests: Convert write chip tests to libflashrom API
As a part of effort to convert command line (and everything else) to be libflashrom users, chip tests need to be converted as well. TEST=ninja test Change-Id: I965598cfa74e3fb7d0780ad34491f4057617691e Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/61139 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'tests/chip.c')
-rw-r--r--tests/chip.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/chip.c b/tests/chip.c
index 962321ff6..5d646ebe0 100644
--- a/tests/chip.c
+++ b/tests/chip.c
@@ -293,12 +293,17 @@ void write_chip_test_success(void **state)
* needs to be provided and image_stat.st_size needs to be mocked.
*/
const char *const filename = "-";
+ unsigned long size = mock_chip.total_size * 1024;
+ uint8_t *const newcontents = malloc(size);
printf("Write chip operation started.\n");
- assert_int_equal(0, do_write(&flashctx, filename, NULL));
+ assert_int_equal(0, read_buf_from_file(newcontents, size, filename));
+ assert_int_equal(0, flashrom_image_write(&flashctx, newcontents, size, NULL));
printf("Write chip operation done.\n");
teardown(&layout);
+
+ free(newcontents);
}
void write_chip_with_dummyflasher_test_success(void **state)
@@ -318,12 +323,16 @@ void write_chip_with_dummyflasher_test_success(void **state)
/* See comment in write_chip_test_success */
const char *const filename = "-";
+ unsigned long size = mock_chip.total_size * 1024;
+ uint8_t *const newcontents = malloc(size);
printf("Write chip operation started.\n");
- assert_int_equal(0, do_write(&flashctx, filename, NULL));
+ assert_int_equal(0, read_buf_from_file(newcontents, size, filename));
+ assert_int_equal(0, flashrom_image_write(&flashctx, newcontents, size, NULL));
printf("Write chip operation done.\n");
teardown(&layout);
free(param_dup);
+ free(newcontents);
}