diff options
-rw-r--r-- | Makefile.am | 5 | ||||
-rw-r--r-- | tests/conf_tests.m4 | 11 | ||||
-rw-r--r-- | tests/zbxmockfile.c | 18 |
3 files changed, 32 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index 69877008bc3..fd88bf1899d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -140,8 +140,9 @@ WRAP_IO_FUNCS = \ WRAP_FS_FUNCS = \ -Wl,--wrap=opendir \ -Wl,--wrap=readdir \ - -Wl,--wrap=stat \ - -Wl,--wrap=__xstat + -Wl,--wrap=__xstat \ + -Wl,--wrap=__fxstat \ + -Wl,--wrap=stat WRAP_EXIT = \ -Wl,--wrap=exit diff --git a/tests/conf_tests.m4 b/tests/conf_tests.m4 index 7ddc6c5d40e..9a25dc1c2b7 100644 --- a/tests/conf_tests.m4 +++ b/tests/conf_tests.m4 @@ -82,4 +82,15 @@ AC_DEFUN([CONF_TESTS], AC_CONFIG_FILES([tests/libs/zbxsysinfo/unknown/Makefile]) ;; esac + + +AC_TRY_LINK( +[ +#include <stdlib.h> +], +[ + __fxstat(0, 0, NULL); +], +AC_DEFINE([HAVE_FXSTAT], [1], [Define to 1 if fxstat function is available])) + ]) diff --git a/tests/zbxmockfile.c b/tests/zbxmockfile.c index 3d68b50a76a..2b15d2cfe2a 100644 --- a/tests/zbxmockfile.c +++ b/tests/zbxmockfile.c @@ -50,9 +50,15 @@ ssize_t __wrap_read(int fildes, void *buf, size_t nbyte); int __wrap_open(const char *path, int oflag, ...); int __wrap_stat(const char *path, struct stat *buf); int __wrap___xstat(int ver, const char *pathname, struct stat *buf); +#ifdef HAVE_FXSTAT +int __wrap___fxstat(int __ver, int __fildes, struct stat *__stat_buf); +#endif int __real_open(const char *path, int oflag, ...); int __real_stat(const char *path, struct stat *buf); +#ifdef HAVE_FXSTAT +int __real___fxstat(int __ver, int __fildes, struct stat *__stat_buf); +#endif static int is_profiler_path(const char *path) { @@ -280,3 +286,15 @@ int __wrap___xstat(int ver, const char *pathname, struct stat *buf) return __wrap_stat(pathname, buf); } + +#ifdef HAVE_FXSTAT +int __wrap___fxstat(int __ver, int __fildes, struct stat *__stat_buf) +{ + if (__fildes != INT_MAX) + return __real___fxstat(__ver, __fildes, __stat_buf); + + __stat_buf->st_size = zbx_mock_get_parameter_uint64("in.file_len"); + + return 0; +} +#endif |