[libvirt] [PATCH v3 2/4] tests: Introduce global mock library

Michal Privoznik mprivozn at redhat.com
Thu May 12 15:30:55 UTC 2016


On 12.05.2016 16:34, Peter Krempa wrote:
> On Thu, May 12, 2016 at 14:36:22 +0200, Michal Privoznik wrote:
>> The intent is that this library is going to be called every time
>> to check if we are not touching anything outside srcdir or
>> builddir.
>>
>> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>> ---
>>  cfg.mk                |   2 +-
>>  tests/Makefile.am     |  13 +++-
>>  tests/testutils.c     |   9 +++
>>  tests/testutils.h     |  10 +--
>>  tests/vircgroupmock.c |  15 ++---
>>  tests/virpcimock.c    |  14 ++--
>>  tests/virtestmock.c   | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>  7 files changed, 210 insertions(+), 28 deletions(-)
>>  create mode 100644 tests/virtestmock.c
>>
> 
> [...]
> 
>> diff --git a/tests/testutils.c b/tests/testutils.c
>> index 79d0763..595b64d 100644
>> --- a/tests/testutils.c
>> +++ b/tests/testutils.c
> 
> [...]
> 
>> @@ -842,6 +845,12 @@ int virtTestMain(int argc,
>>      char *oomstr;
>>  #endif
>>  
>> +#ifdef __linux__
>> +    VIRT_TEST_PRELOAD(TEST_MOCK);
> 
> So I was thinking about it a bit. I think we should pre-load this only
> conditionally on a ENV var which will enable it.

Yeah, I was thinking the same when implementing this. Problem with that
approach would be that nobody would do that. But I guess for now it's a
fair trade and once we get the whitelist rules complete we can make
'make check' to actually set the variable and possibly die on an error
if the perl script founds one. Got any good idea about the var name?
What if I reuse VIR_TEST_FILE_ACCESS (introduced in 3/4) just for this
purpose, to enable this whole feature; and then introduce
VIR_TEST_FILE_ACCESS_OUTPUT to redirect output into a different file
than the default one.
If so, do you want me to send another version of these patches?

Michal




More information about the libvir-list mailing list