summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2023-05-15 11:56:51 +0200
committerMichal Privoznik <mprivozn@redhat.com>2023-05-16 08:48:17 +0200
commita091edf9db5d6e949190d9ea6ad384570c30def0 (patch)
treeba616bda4862b96c5bf6c501fe31142a63a45869
parent4a681995bc9f0ba5df779c392b7bebf3470a3f9a (diff)
downloadlibvirt-a091edf9db5d6e949190d9ea6ad384570c30def0.tar.gz
virmockstathelpers: Adapt to musl-1.2.4
With musl-1.2.3: I get the following macros defined (from $builddir/meson-config.h): #define WITH_LSTAT 1 #define WITH_LSTAT64 1 #define WITH_LSTAT_DECL 1 #define WITH_STAT 1 #define WITH_STAT64 1 #define WITH_STAT_DECL 1 #define WITH___LXSTAT 1 #define WITH___LXSTAT64 1 #define WITH___XSTAT 1 #define WITH___XSTAT64 1 which in turn means the virmockstathelpers.c ends up defining: MOCK_STAT64 MOCK_LSTAT64 But with musl-1.2.4 everything changes and the set of defined macros gets simplified to: #define WITH_LSTAT 1 #define WITH_LSTAT_DECL 1 #define WITH_STAT 1 #define WITH_STAT_DECL 1 #define WITH___LXSTAT 1 #define WITH___XSTAT 1 which results in no MOCK_* macros defined in virmockstathelpers.c, i.e. no stat() mocking, nada. The reason for this simplification are these musl commits [1][2] which removed all 64 bit aliases. And that's not what our logic for deciding what flavor of stat() to mock counted with. Nevertheless, we do build with Alpine Linux in our CI, so how come we don't see this problem there? Well, simply because Alpine Linux maintainers decided to revert the commits [3][4]. But on distributions that use vanilla musl, this problem can be seen easily. 1: https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4 2: https://git.musl-libc.org/cgit/musl/commit/?id=25e6fee27f4a293728dd15b659170e7b9c7db9bc 3: https://git.alpinelinux.org/aports/commit/main/musl?id=6a5563fbb45b3d9d60678d7bbf60dbb312a2d481 4: https://git.alpinelinux.org/aports/commit/main/musl?id=a089bd852f8983623fa85e0f5755a3e25bf53c72 Resolves: https://bugs.gentoo.org/906167 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
-rw-r--r--tests/virmockstathelpers.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c
index 5b1f3b08a7..8a76c5e369 100644
--- a/tests/virmockstathelpers.c
+++ b/tests/virmockstathelpers.c
@@ -125,6 +125,16 @@
# endif
#endif
+#if !defined(MOCK_STAT) && !defined(MOCK_STAT64) && \
+ !defined(MOCK___XSTAT) && !defined(MOCK___XSTAT64)
+# define MOCK_STAT
+#endif
+
+#if !defined(MOCK_LSTAT) && !defined(MOCK_LSTAT64) && \
+ !defined(MOCK___LXSTAT) && !defined(MOCK___LXSTAT64)
+# define MOCK_LSTAT
+#endif
+
#ifdef MOCK_STAT
static int (*real_stat)(const char *path, struct stat *sb);
#endif