Daniel Campello has uploaded this change for review.

View Change

tests: add more mock wrappers

This change allows for tests to run when the compiler is inlining some
other interfaces.

BUG=b:224828279
TEST=FEATURES=test emerge-volteer flashrom

Signed-off-by: Daniel Campello <campello@chromium.org>
Change-Id: I9776104d655c37891093da08789d37e5e27700de
---
M tests/meson.build
M tests/tests.c
2 files changed, 27 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/44/62844/1
diff --git a/tests/meson.build b/tests/meson.build
index 610d1c6..90e0df1 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -36,6 +36,7 @@
'-Wl,--wrap=sio_read',
'-Wl,--wrap=open',
'-Wl,--wrap=open64',
+ '-Wl,--wrap=__open64_2',
'-Wl,--wrap=ioctl',
'-Wl,--wrap=read',
'-Wl,--wrap=write',
@@ -56,7 +57,9 @@
'-Wl,--wrap=fsync',
'-Wl,--wrap=fread',
'-Wl,--wrap=fgets',
+ '-Wl,--wrap=__fgets_chk',
'-Wl,--wrap=fprintf',
+ '-Wl,--wrap=__vfprintf_chk',
'-Wl,--wrap=fclose',
'-Wl,--wrap=feof',
'-Wl,--wrap=ferror',
diff --git a/tests/tests.c b/tests/tests.c
index 21cc1ed..9be0ca7 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -90,6 +90,14 @@
return NON_ZERO;
}

+int __wrap___open64_2(const char *pathname, int flags)
+{
+ LOG_ME;
+ if (get_io() && get_io()->open)
+ return get_io()->open(get_io()->state, pathname, flags);
+ return NON_ZERO;
+}
+
int __wrap_ioctl(int fd, unsigned long int request, ...)
{
LOG_ME;
@@ -198,6 +206,14 @@
return NULL;
}

+char *__wrap___fgets_chk(char *buf, int len, FILE *fp)
+{
+ LOG_ME;
+ if (get_io() && get_io()->fgets)
+ return get_io()->fgets(get_io()->state, buf, len, fp);
+ return NULL;
+}
+
size_t __wrap_fread(void *ptr, size_t size, size_t nmemb, FILE *fp)
{
LOG_ME;
@@ -250,6 +266,14 @@
return 0;
}

+int __wrap___vfprintf_chk(FILE *fp, const char *fmt, va_list args)
+{
+ LOG_ME;
+ if (get_io() && get_io()->fprintf)
+ return get_io()->fprintf(get_io()->state, fp, fmt, args);
+ return 0;
+}
+
int __wrap_fclose(FILE *fp)
{
LOG_ME;

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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I9776104d655c37891093da08789d37e5e27700de
Gerrit-Change-Number: 62844
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Campello <campello@chromium.org>
Gerrit-MessageType: newchange