Edward O'Callaghan submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Edward O'Callaghan: Looks good to me, approved
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>
---
M tests/chip.c
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tests/chip.c b/tests/chip.c
index 962321f..5d646eb 100644
--- a/tests/chip.c
+++ b/tests/chip.c
@@ -293,12 +293,17 @@
* 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 @@

/* 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);
}

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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I965598cfa74e3fb7d0780ad34491f4057617691e
Gerrit-Change-Number: 61139
Gerrit-PatchSet: 2
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged