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

[libvirt] [PATCH] tests: don't try to mock __open_2 on non-GLibc builds



Mocking of the __open_2 function was added in

  commit 459f071cacf30af9df93b7d090b1bda71b0ef20f
  Author: Michal Privoznik <mprivozn redhat com>
  Date:   Thu Aug 15 16:37:17 2019 +0200

    virpcimock: Mock __open_2()

This function only exists in glibc, however, and the mocking code runs
on systems not using glibc, such as FreeBSD. Even Linux hosts might be
using a different libc impl, though we don't actively try to support
that.

Signed-off-by: Daniel P. Berrangé <berrange redhat com>
---

Pushed as a CI build fix for FreeBSD

 tests/virpcimock.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index ca6cc060fd..e9a3791aea 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -32,7 +32,9 @@
 
 static int (*real_access)(const char *path, int mode);
 static int (*real_open)(const char *path, int flags, ...);
+#ifdef __GLIBC__
 static int (*real___open_2)(const char *path, int flags);
+#endif /* ! __GLIBC__ */
 static int (*real_close)(int fd);
 static DIR * (*real_opendir)(const char *name);
 static char *(*real_virFileCanonicalizePath)(const char *path);
@@ -955,7 +957,9 @@ init_syms(void)
 
     VIR_MOCK_REAL_INIT(access);
     VIR_MOCK_REAL_INIT(open);
+#ifdef __GLIBC__
     VIR_MOCK_REAL_INIT(__open_2);
+#endif /* ! __GLIBC__ */
     VIR_MOCK_REAL_INIT(close);
     VIR_MOCK_REAL_INIT(opendir);
     VIR_MOCK_REAL_INIT(virFileCanonicalizePath);
@@ -1084,6 +1088,7 @@ open(const char *path, int flags, ...)
 }
 
 
+#ifdef __GLIBC__
 /* in some cases this function may not be present in headers, so we need
  * a declaration to silence the complier */
 int
@@ -1113,7 +1118,7 @@ __open_2(const char *path, int flags)
 
     return ret;
 }
-
+#endif /* ! __GLIBC__ */
 
 DIR *
 opendir(const char *path)
-- 
2.21.0


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