Re: [PATCH v3 7/9] tests: Build virpcimock on non-Linux

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

 



On Thu, 2018-05-03 at 12:54 +0200, Andrea Bolognani wrote:
> There are only a couple issues preventing it from working on
> other platform such as FreeBSD. Let's fix them.
> 
> With the mocking in place, qemumemlocktest and qemuxml2xmltest
> can finally succeed on FreeBSD.

Too bad it also happens to break compilation on macOS

  duplicate symbol _rpl_lstat in:
      .libs/virpcimock.o
      ../gnulib/lib/.libs/libgnu.a(lstat.o)
  duplicate symbol _rpl_open in:
      .libs/virpcimock.o
      ../gnulib/lib/.libs/libgnu.a(open.o)
  duplicate symbol _rpl_stat in:
      .libs/virpcimock.o
      ../gnulib/lib/.libs/libgnu.a(stat.o)
  ld: 3 duplicate symbols for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[2]: *** [virpcimock.la] Error 1

and on MinGW

  ../../tests/virpcimock.c: In function 'make_symlink':
  ../../tests/virpcimock.c:203:9: error: implicit declaration of function 'symlink'; did you mean 'unlink'? [-Werror=implicit-function-declaration]
       if (symlink(target, filepath) < 0)
           ^~~~~~~
           unlink
  ../../tests/virpcimock.c:203:9: error: nested extern declaration of 'symlink' [-Werror=nested-externs]
  ../../tests/virpcimock.c: In function 'pci_read_file':
  ../../tests/virpcimock.c:228:5: error: implicit declaration of function 'bzero' [-Werror=implicit-function-declaration]
       bzero(buf, buf_size);
       ^~~~~
  ../../tests/virpcimock.c:228:5: error: incompatible implicit declaration of built-in function 'bzero' [-Werror]
  In file included from ../gnulib/lib/fcntl.h:58:0,
                   from ../../tests/virpcimock.c:27:
  ../../tests/virpcimock.c: At top level:
  ../../tests/virpcimock.c:964:1: error: redefinition of 'rpl_stat'
   stat(const char *path, struct stat *sb)
   ^
  ../../tests/virpcimock.c:924:1: note: previous definition of 'rpl_stat' was here
   lstat(const char *path, struct stat *sb)
   ^
  cc1: all warnings being treated as errors
  gmake[2]: *** [Makefile:5505: virpcimock.lo] Error 1

I'll look into solving the latter, but I have no intention of
spending time on the former because I don't have access to macOS
machines and debugging this kind of failure through Travis would
be just too painful and time consuming.

In the meantime, and for the purpose of reviewing the series,
consider the attached patch, which merely adds FreeBSD to the list
of platforms virpcimock should be compiled on, rather than getting
rid of such a list altogether, squashed in.

-- 
Andrea Bolognani / Red Hat / Virtualization
From 597a9aaadfb8ac5c828f91c125236ec5e7bad884 Mon Sep 17 00:00:00 2001
From: Andrea Bolognani <abologna@xxxxxxxxxx>
Date: Thu, 3 May 2018 13:38:23 +0200
Subject: [PATCH] tests: Build virpcimock on Linux and FreeBSD

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 tests/virpcimock.c | 46 +++++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 09cb26567c..643e2ee0bc 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -20,18 +20,19 @@
 
 #include <config.h>
 
-#include "virmock.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <stdarg.h>
-#include <dirent.h>
-#include "viralloc.h"
-#include "virstring.h"
-#include "virfile.h"
-#include "dirname.h"
+#if defined(__linux__) || defined(__FreeBSD__)
+# include "virmock.h"
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <fcntl.h>
+# include <sys/stat.h>
+# include <stdarg.h>
+# include <dirent.h>
+# include "viralloc.h"
+# include "virstring.h"
+# include "virfile.h"
+# include "dirname.h"
 
 static int (*real_access)(const char *path, int mode);
 static int (*real_lstat)(const char *path, struct stat *sb);
@@ -50,20 +51,20 @@ static char *(*real_virFileCanonicalizePath)(const char *path);
 char *fakerootdir;
 char *fakesysfspcidir;
 
-#define SYSFS_PCI_PREFIX "/sys/bus/pci/"
+# define SYSFS_PCI_PREFIX "/sys/bus/pci/"
 
-#define STDERR(...) \
+# define STDERR(...) \
     fprintf(stderr, "%s %zu: ", __FUNCTION__, (size_t) __LINE__); \
     fprintf(stderr, __VA_ARGS__); \
     fprintf(stderr, "\n"); \
 
-#define ABORT(...) \
+# define ABORT(...) \
     do { \
         STDERR(__VA_ARGS__); \
         abort(); \
     } while (0)
 
-#define ABORT_OOM() \
+# define ABORT_OOM() \
     ABORT("Out of memory")
 /*
  * The plan:
@@ -371,11 +372,11 @@ pci_device_new_from_stub(const struct pciDevice *data)
     if (real_stat && real_stat(configSrc, &sb) == 0)
         configSrcExists = true;
 
-#ifdef HAVE___XSTAT
+# ifdef HAVE___XSTAT
     if (!configSrcExists &&
         real___xstat && real___xstat(_STAT_VER, configSrc, &sb) == 0)
         configSrcExists = true;
-#endif
+# endif
 
     /* If there is a config file for the device within virpcitestdata dir,
      * symlink it. Otherwise create a dummy config file. */
@@ -842,7 +843,7 @@ init_env(void)
 
     make_file(fakesysfspcidir, "drivers_probe", NULL, -1);
 
-#define MAKE_PCI_DRIVER(name, ...) \
+# define MAKE_PCI_DRIVER(name, ...) \
     pci_driver_new(name, 0, __VA_ARGS__, -1, -1)
 
     MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044);
@@ -850,7 +851,7 @@ init_env(void)
     MAKE_PCI_DRIVER("pci-stub", -1, -1);
     pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1);
 
-#define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \
+# define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \
     do { \
         struct pciDevice dev = {.id = (char *)Id, .vendor = Vendor, \
                                 .device = Device, __VA_ARGS__}; \
@@ -939,7 +940,7 @@ lstat(const char *path, struct stat *sb)
     return ret;
 }
 
-#ifdef HAVE___XSTAT
+# ifdef HAVE___XSTAT
 int
 __xstat(int ver, const char *path, struct stat *sb)
 {
@@ -1061,3 +1062,6 @@ virFileCanonicalizePath(const char *path)
 
     return ret;
 }
+#else
+/* Nothing to override on this platform */
+#endif
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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