mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 14:33:18 +02:00
tests: Add tests to read from chip
Two tests cover the code which performs do_read operation. First one works with fake chip and dummy programmer. Fake chip has all operations defined, and a buffer to emulate chip memory. Second one uses the chip which is closer to the real one, because read/write/unlock/erase operations are real. The tests takes the advantage of dummyflasher's capability of emulating a W25Q128.V chip. BUG=b:181803212 TEST=builds and ninja test Change-Id: Ia57781ebc670c7bd6197e56fe8a20651a425c756 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57326 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:

committed by
Nico Huber

parent
2d538d87eb
commit
1f62b8346e
@ -154,6 +154,18 @@ int __wrap_stat64(const char *path, void *buf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __wrap_fstat(int fd, void *buf)
|
||||
{
|
||||
LOG_ME;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __wrap_fstat64(int fd, void *buf)
|
||||
{
|
||||
LOG_ME;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *__wrap_fgets(char *buf, int len, FILE *fp)
|
||||
{
|
||||
LOG_ME;
|
||||
@ -170,6 +182,30 @@ size_t __wrap_fread(void *ptr, size_t size, size_t len, FILE *fp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t __wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *fp)
|
||||
{
|
||||
LOG_ME;
|
||||
return nmemb;
|
||||
}
|
||||
|
||||
int __wrap_fflush(FILE *fp)
|
||||
{
|
||||
LOG_ME;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __wrap_fileno(FILE *fp)
|
||||
{
|
||||
LOG_ME;
|
||||
return MOCK_HANDLE;
|
||||
}
|
||||
|
||||
int __wrap_fsync(int fd)
|
||||
{
|
||||
LOG_ME;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __wrap_setvbuf(FILE *fp, char *buf, int type, size_t size)
|
||||
{
|
||||
LOG_ME;
|
||||
@ -357,6 +393,8 @@ int main(void)
|
||||
const struct CMUnitTest chip_tests[] = {
|
||||
cmocka_unit_test(erase_chip_test_success),
|
||||
cmocka_unit_test(erase_chip_with_dummyflasher_test_success),
|
||||
cmocka_unit_test(read_chip_test_success),
|
||||
cmocka_unit_test(read_chip_with_dummyflasher_test_success),
|
||||
};
|
||||
ret |= cmocka_run_group_tests_name("chip.c tests", chip_tests, NULL, NULL);
|
||||
|
||||
|
Reference in New Issue
Block a user