提交 b5d4652e 编写于 作者: A Andrea Bolognani

tests: Build virpcimock on FreeBSD too

There are only a couple remaining issues preventing it from
working on FreeBSD. Let's fix them.

With the mocking in place, qemumemlocktest and qemuxml2xmltest
can finally succeed on FreeBSD.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 530cecdb
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <config.h> #include <config.h>
#ifdef __linux__ #if defined(__linux__) || defined(__FreeBSD__)
# include "virmock.h" # include "virmock.h"
# include <stdio.h> # include <stdio.h>
# include <stdlib.h> # include <stdlib.h>
...@@ -341,6 +341,7 @@ pci_device_new_from_stub(const struct pciDevice *data) ...@@ -341,6 +341,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
char *configSrc; char *configSrc;
char tmp[256]; char tmp[256];
struct stat sb; struct stat sb;
bool configSrcExists = false;
if (VIR_STRDUP_QUIET(id, data->id) < 0) if (VIR_STRDUP_QUIET(id, data->id) < 0)
ABORT_OOM(); ABORT_OOM();
...@@ -368,10 +369,18 @@ pci_device_new_from_stub(const struct pciDevice *data) ...@@ -368,10 +369,18 @@ pci_device_new_from_stub(const struct pciDevice *data)
if (virFileMakePath(devpath) < 0) if (virFileMakePath(devpath) < 0)
ABORT("Unable to create: %s", devpath); ABORT("Unable to create: %s", devpath);
if (real_stat && real_stat(configSrc, &sb) == 0)
configSrcExists = true;
# ifdef HAVE___XSTAT
if (!configSrcExists &&
real___xstat && real___xstat(_STAT_VER, configSrc, &sb) == 0)
configSrcExists = true;
# endif
/* If there is a config file for the device within virpcitestdata dir, /* If there is a config file for the device within virpcitestdata dir,
* symlink it. Otherwise create a dummy config file. */ * symlink it. Otherwise create a dummy config file. */
if ((real_stat && real_stat(configSrc, &sb) == 0) || if (configSrcExists) {
(real___xstat && real___xstat(_STAT_VER, configSrc, &sb) == 0)) {
/* On success, copy @configSrc into the destination (a copy, /* On success, copy @configSrc into the destination (a copy,
* rather than a symlink, is required since we write into the * rather than a symlink, is required since we write into the
* file, and parallel VPATH builds must not stomp on the * file, and parallel VPATH builds must not stomp on the
...@@ -891,6 +900,7 @@ access(const char *path, int mode) ...@@ -891,6 +900,7 @@ access(const char *path, int mode)
return ret; return ret;
} }
# ifdef HAVE___LXSTAT
int int
__lxstat(int ver, const char *path, struct stat *sb) __lxstat(int ver, const char *path, struct stat *sb)
{ {
...@@ -909,6 +919,7 @@ __lxstat(int ver, const char *path, struct stat *sb) ...@@ -909,6 +919,7 @@ __lxstat(int ver, const char *path, struct stat *sb)
} }
return ret; return ret;
} }
# endif /* HAVE___LXSTAT */
int int
lstat(const char *path, struct stat *sb) lstat(const char *path, struct stat *sb)
...@@ -929,6 +940,7 @@ lstat(const char *path, struct stat *sb) ...@@ -929,6 +940,7 @@ lstat(const char *path, struct stat *sb)
return ret; return ret;
} }
# ifdef HAVE___XSTAT
int int
__xstat(int ver, const char *path, struct stat *sb) __xstat(int ver, const char *path, struct stat *sb)
{ {
...@@ -947,6 +959,7 @@ __xstat(int ver, const char *path, struct stat *sb) ...@@ -947,6 +959,7 @@ __xstat(int ver, const char *path, struct stat *sb)
} }
return ret; return ret;
} }
# endif /* HAVE___XSTAT */
int int
stat(const char *path, struct stat *sb) stat(const char *path, struct stat *sb)
...@@ -1050,5 +1063,5 @@ virFileCanonicalizePath(const char *path) ...@@ -1050,5 +1063,5 @@ virFileCanonicalizePath(const char *path)
return ret; return ret;
} }
#else #else
/* Nothing to override on non-__linux__ platforms */ /* Nothing to override on this platform */
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册