[libvirt] [PATCH v4 5/8] virmock.h: Introduce VIR_MOCK_CALL_STAT
Peter Krempa
pkrempa at redhat.com
Fri May 13 16:22:43 UTC 2016
On Fri, May 13, 2016 at 14:32:06 +0200, Michal Privoznik wrote:
> There is some magic going on when it comes to stat() or lstat().
> Basically, stat() can either be a regular function, an inline
> function that calls __xstat(_STAT_VER, ...) or a macro that does
> the same as the inline func. Don't ask why is that, just read the
> documentation in sys/stat.h and make sure you have a bucket next
> to you. Anyway, currently there will not be both stat and __xstat
> symbols at the same time, as one of them gets overwritten to the
> other one during compilation. But this is not true anymore once
> we start chaining our mocking libraries. Therefore we need a
> wrapper that calls desired function from glibc.
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
> tests/vircgroupmock.c | 14 +++++++-------
> tests/virmock.h | 23 +++++++++++++++++++++++
> tests/virpcimock.c | 19 +++++++++----------
> 3 files changed, 39 insertions(+), 17 deletions(-)
>
[...]
> diff --git a/tests/virmock.h b/tests/virmock.h
> index 62a7c8f..27c03ba 100644
> --- a/tests/virmock.h
> +++ b/tests/virmock.h
> @@ -254,6 +255,28 @@
> static void (*real_##name)(void); \
> void name(void)
>
> +static inline int
> +callStat(int (*realStat)(const char *, struct stat *),
> + int (*realXstat)(int, const char *, struct stat *),
This is a bit ugly, but it's in the mock code and I don't know of a
better option.
ACK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160513/9e19b9b0/attachment-0001.sig>
More information about the libvir-list
mailing list