Re: [PATCH 2/2] tests: mock __open_2()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/14/24 13:10, Pavel Hrdina wrote:
> On Thu, Mar 14, 2024 at 10:34:28AM +0100, Michal Privoznik wrote:
>> As of commit [1] glibc may overwrite a call to open() with call
>> to __open_2() (if only two arguments are provided and the code is
>> compiled with clang). But since we are not mocking the latter our
>> test suite is broken as tests try to access paths outside of our
>> repo.
>>
>> 1: https://sourceware.org/git/?p=glibc.git;a=commit;h=86889e22db329abac618c6a41f86c84657a15324
>> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
>> ---
>>  meson.build              | 13 +++++++++++++
>>  tests/nssmock.c          | 26 +++++++++++++++++++++++++
>>  tests/qemusecuritymock.c | 24 +++++++++++++++++++++++
>>  tests/vircgroupmock.c    | 42 ++++++++++++++++++++++++++++++++++++++++
>>  tests/virfilewrapper.c   | 18 +++++++++++++++++
>>  tests/virmock.h          |  4 ++++
>>  tests/virpcimock.c       | 17 ++++++----------
>>  tests/virtestmock.c      | 20 +++++++++++++++++++
>>  tests/virusbmock.c       | 22 +++++++++++++++++++++
>>  9 files changed, 175 insertions(+), 11 deletions(-)
>>
>> diff --git a/meson.build b/meson.build
>> index 9842886bbb..b1b55b0d25 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -604,6 +604,12 @@ stat_functions = [
>>  
>>  functions += stat_functions
>>  
>> +open_functions = [
>> +  '__open_2',
>> +]
>> +
>> +functions += open_functions
>> +
>>  foreach function : functions
>>    if cc.has_function(function)
>>      conf.set('WITH_@0@'.format(function.to_upper()), 1)
>> @@ -618,6 +624,13 @@ foreach function : stat_functions
>>  endforeach
>>  
>>  
>> +foreach function : open_functions
>> +  if cc.has_header_symbol('fcntl.h', function)
>> +    conf.set('WITH_@0@_DECL'.format(function.to_upper()), 1)
>> +  endif
>> +endforeach
>> +
>> +
>>  # various header checks
>>  
>>  headers = [
> 
> [...]
> 
>> diff --git a/tests/virmock.h b/tests/virmock.h
>> index 300ba17174..178d0a15f0 100644
>> --- a/tests/virmock.h
>> +++ b/tests/virmock.h
>> @@ -27,6 +27,10 @@
>>  
>>  #include "internal.h"
>>  
>> +#ifndef WITH___OPEN_2_DECL
>> +int __open_2 (const char *__path, int __oflag);
>> +#endif
> 
> Do we really need this bit? Every single use of __open_2 is already
> guarded by WITH__OPEN_2.

We do. We are not guaranteed that the conditions line up right
everywhere for fcntl.h header file to provide that declaration. Yet, the
symbol is available in the libc.so. For instance, ubuntu 22.04 with
clang fails:

https://gitlab.com/MichalPrivoznik/libvirt/-/jobs/6394162037

Maybe we can switch all those WITH___OPEN_2 to WITH___OPEN_2_DECL? IOW -
provide the mock only if conditions align just right for the declaration
to exist. Let me see what our pipeline would think about that.

Michal
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux