[libvirt PATCH 1/2] tests: Split macOS stat() mocking logic

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

 



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@xxxxxxxxxx>
---
 tests/virmockstathelpers.c | 73 ++++++++++++++++++++------------------
 1 file changed, 39 insertions(+), 34 deletions(-)

diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c
index 3bd2437ffe..97f628368d 100644
--- a/tests/virmockstathelpers.c
+++ b/tests/virmockstathelpers.c
@@ -74,42 +74,47 @@
  * 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);
-- 
2.26.2




[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