]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Improve macOS stat() mocking logic
authorAndrea Bolognani <abologna@redhat.com>
Wed, 3 Feb 2021 11:32:46 +0000 (12:32 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 4 Feb 2021 12:58:44 +0000 (13:58 +0100)
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 <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/virmockstathelpers.c

index 97f628368d863d97fc029675c413cad21d37b827..830dfe108547d3fcdbe3d259144f91c8b11c9661 100644 (file)
@@ -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
 # 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