Anastasia Klimchuk submitted this change.
5 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
tests: Add fwrite and fdopen to io_mock
BUG=None
BRANCH=None
TEST=None
Change-Id: I4dff96c264b3ada354538b434b2808fb66c7ef59
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/69538
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M tests/io_mock.h
M tests/tests.c
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/tests/io_mock.h b/tests/io_mock.h
index 020794a..9798066 100644
--- a/tests/io_mock.h
+++ b/tests/io_mock.h
@@ -111,8 +111,10 @@
FILE* (*iom_fopen)(void *state, const char *pathname, const char *mode);
char* (*iom_fgets)(void *state, char *buf, int len, FILE *fp);
size_t (*iom_fread)(void *state, void *buf, size_t size, size_t len, FILE *fp);
+ size_t (*iom_fwrite)(void *state, const void *buf, size_t size, size_t len, FILE *fp);
int (*iom_fprintf)(void *state, FILE *fp, const char *fmt, va_list args);
int (*iom_fclose)(void *state, FILE *fp);
+ FILE *(*iom_fdopen)(void *state, int fd, const char *mode);
/*
* An alternative to custom open mock. A test can either register its
diff --git a/tests/tests.c b/tests/tests.c
index b517898..41972ba 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -184,6 +184,8 @@
FILE *__wrap_fdopen(int fd, const char *mode)
{
LOG_ME;
+ if (get_io() && get_io()->iom_fdopen)
+ return get_io()->iom_fdopen(get_io()->state, fd, mode);
return not_null();
}
@@ -254,6 +256,8 @@
size_t __wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *fp)
{
LOG_ME;
+ if (get_io() && get_io()->iom_fwrite)
+ return get_io()->iom_fwrite(get_io()->state, ptr, size, nmemb, fp);
return nmemb;
}
To view, visit change 69538. To unsubscribe, or for help writing mail filters, visit settings.