]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Split macOS stat() mocking logic
authorAndrea Bolognani <abologna@redhat.com>
Wed, 3 Feb 2021 11:32:13 +0000 (12:32 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 4 Feb 2021 12:58:39 +0000 (13:58 +0100)
On macOS, most of the symbols and declarations that we look at
to determine which versions of stat() we need to mock are not
present; on the other hand, there are some specific wrinkles
that are introduced with Apple Silicon which we will need to
take care of.

To avoid making the logic even more of an opaque mess than it
currently is, move the macOS part to a separate branch.

This commit is better viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/virmockstathelpers.c

index 3bd2437ffe3783e1a9eb96810971a17eb20d284a..97f628368d863d97fc029675c413cad21d37b827 100644 (file)
  * The same all applies to lstat()
  */
 
-
-#if !defined(WITH___XSTAT_DECL)
-# if defined(WITH_STAT)
-#  if !defined(WITH___XSTAT) && !defined(WITH_STAT64) || defined(__APPLE__)
-#   define MOCK_STAT
+#if !defined(__APPLE__)
+# if !defined(WITH___XSTAT_DECL)
+#  if defined(WITH_STAT)
+#   if !defined(WITH___XSTAT) && !defined(WITH_STAT64)
+#    define MOCK_STAT
+#   endif
 #  endif
-# endif
-# if defined(WITH_STAT64)
-#  define MOCK_STAT64
-# endif
-#else /* WITH___XSTAT_DECL */
-# if defined(WITH___XSTAT) && !defined(WITH___XSTAT64)
-#  define MOCK___XSTAT
-# endif
-# if defined(WITH___XSTAT64)
-#  define MOCK___XSTAT64
-# endif
-#endif /* WITH___XSTAT_DECL */
-
-#if !defined(WITH___LXSTAT_DECL)
-# if defined(WITH_LSTAT)
-#  if !defined(WITH___LXSTAT) && !defined(WITH_LSTAT64) || defined(__APPLE__)
-#   define MOCK_LSTAT
+#  if defined(WITH_STAT64)
+#   define MOCK_STAT64
 #  endif
-# endif
-# if defined(WITH_LSTAT64)
-#  define MOCK_LSTAT64
-# endif
-#else /* WITH___LXSTAT_DECL */
-# if defined(WITH___LXSTAT) && !defined(WITH___LXSTAT64)
-#  define MOCK___LXSTAT
-# endif
-# if defined(WITH___LXSTAT64)
-#  define MOCK___LXSTAT64
-# endif
-#endif /* WITH___LXSTAT_DECL */
+# else /* WITH___XSTAT_DECL */
+#  if defined(WITH___XSTAT) && !defined(WITH___XSTAT64)
+#   define MOCK___XSTAT
+#  endif
+#  if defined(WITH___XSTAT64)
+#   define MOCK___XSTAT64
+#  endif
+# endif /* WITH___XSTAT_DECL */
+# if !defined(WITH___LXSTAT_DECL)
+#  if defined(WITH_LSTAT)
+#   if !defined(WITH___LXSTAT) && !defined(WITH_LSTAT64)
+#    define MOCK_LSTAT
+#   endif
+#  endif
+#  if defined(WITH_LSTAT64)
+#   define MOCK_LSTAT64
+#  endif
+# else /* WITH___LXSTAT_DECL */
+#  if defined(WITH___LXSTAT) && !defined(WITH___LXSTAT64)
+#   define MOCK___LXSTAT
+#  endif
+#  if defined(WITH___LXSTAT64)
+#   define MOCK___LXSTAT64
+#  endif
+# endif /* WITH___LXSTAT_DECL */
+#else /* __APPLE__ */
+# define MOCK_STAT
+# define MOCK_STAT64
+# define MOCK_LSTAT
+# define MOCK_LSTAT64
+#endif
 
 #ifdef MOCK_STAT
 static int (*real_stat)(const char *path, struct stat *sb);