tests: Split macOS stat() mocking logic

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>
This commit is contained in:
Andrea Bolognani 2021-02-03 12:32:13 +01:00
parent 02ffd9909c
commit 7314546f73

View File

@ -74,42 +74,47 @@
* The same all applies to lstat()
*/
#if !defined(WITH___XSTAT_DECL)
#if !defined(__APPLE__)
# if !defined(WITH___XSTAT_DECL)
# if defined(WITH_STAT)
# if !defined(WITH___XSTAT) && !defined(WITH_STAT64) || defined(__APPLE__)
# if !defined(WITH___XSTAT) && !defined(WITH_STAT64)
# define MOCK_STAT
# endif
# endif
# if defined(WITH_STAT64)
# define MOCK_STAT64
# endif
#else /* WITH___XSTAT_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)
# endif /* WITH___XSTAT_DECL */
# if !defined(WITH___LXSTAT_DECL)
# if defined(WITH_LSTAT)
# if !defined(WITH___LXSTAT) && !defined(WITH_LSTAT64) || defined(__APPLE__)
# if !defined(WITH___LXSTAT) && !defined(WITH_LSTAT64)
# define MOCK_LSTAT
# endif
# endif
# if defined(WITH_LSTAT64)
# define MOCK_LSTAT64
# endif
#else /* WITH___LXSTAT_DECL */
# 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 */
# 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);