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

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

 



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.

Pavel

>  #define VIR_MOCK_COUNT_ARGS(...) VIR_MOCK_ARG27(__VA_ARGS__, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
>  #define VIR_MOCK_ARG27(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, ...) _27
>  #define VIR_MOCK_ARG_PASTE(a, b, ...) a##b(__VA_ARGS__)

Attachment: signature.asc
Description: PGP signature

_______________________________________________
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