From: Andrea Bolognani Date: Wed, 3 Feb 2021 11:32:46 +0000 (+0100) Subject: tests: Improve macOS stat() mocking logic X-Git-Tag: v7.1.0-rc1~278 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=879edc697bfde5371628a83fb56446bb88a008c4;p=thirdparty%2Flibvirt.git tests: Improve macOS stat() mocking logic We should not mock stat64() when building on Apple Silicon, because the declaration is not present in the header file. Detect this situation and handle it gracefully. https://gitlab.com/libvirt/libvirt/-/issues/121 Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c index 97f628368d..830dfe1085 100644 --- a/tests/virmockstathelpers.c +++ b/tests/virmockstathelpers.c @@ -57,7 +57,9 @@ * * On macOS stat() and lstat() are resolved to _stat$INODE64 and * _lstat$INODE64, respectively. stat(2) man page also declares that - * stat64(), lstat64() and fstat64() are deprecated. + * stat64(), lstat64() and fstat64() are deprecated, and when + * building on Apple Silicon (aarch64) those functions are missing + * from the header altogether and should not be mocked. * * With all this in mind the list of functions we have to mock will depend * on several factors @@ -111,9 +113,13 @@ # endif /* WITH___LXSTAT_DECL */ #else /* __APPLE__ */ # define MOCK_STAT -# define MOCK_STAT64 +# if defined(WITH_STAT64_DECL) +# define MOCK_STAT64 +# endif # define MOCK_LSTAT -# define MOCK_LSTAT64 +# if defined(WITH_LSTAT64_DECL) +# define MOCK_LSTAT64 +# endif #endif #ifdef MOCK_STAT