Commit Graph

7 Commits

Author SHA1 Message Date
Michal Privoznik
436397902e tests: Drop VIR_MOCK_CALL_STAT
It wasn't as great idea as I thought. Thing around stat() are
more complicated than that. Therefore we need to revert
86d1705a8a plus drop use of the macro as introduced in
later patches.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-20 17:16:21 +02:00
Michal Privoznik
86d1705a8a virmock.h: Introduce VIR_MOCK_CALL_STAT
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@redhat.com>
2016-05-14 09:25:56 +02:00
Michal Privoznik
57c484dbac virpcimock: Adapt to virmock.h
Instead of introducing our own wrapper for dlsym()
we can use the one provided by virmock.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:10:40 +02:00
Martin Kletzander
04c383ea7a tests: fix documentation for mocking methods
It looks like it was copy-pasted, so in case anyone wonders what some of
those methods do without looking at them, and for the sake of
completeness, fix them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-27 11:17:56 +01:00
Daniel P. Berrange
47ffd5e8fd tests: Add more test suite mock helpers
Rename the VIR_MOCK_IMPL* macros to VIR_MOCK_WRAP*
and add new VIR_MOCK_IMPL macros which let you directly
implement overrides in the preloaded source.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-09-11 15:40:50 -06:00
Daniel P. Berrange
2a47ff565c Conditionalize include of dlfcn.h in virmock.h
dlfcn.h does not exist on Win32 so must only be used
conditionally

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-04-25 15:48:30 +01:00
Daniel P. Berrange
442ba49351 Introduce a new set of helper macros for mocking symbols
Introduce virmock.h which provides some macros to assist in
creation of LD_PRELOAD overrides. When these are used, the
LD_PRELOAD code simply has some stubs which forward to a
wrapper function inside the main test case. This means that
logic for the test no longer has to be split between the
virXXXtest.c and virXXXmock.c files. It will also make it
possible to provide some common reusable modules for mocking
code like DBus.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-04-08 11:03:54 +01:00