[libvirt] [PATCH] Fix statstest when driver modules are enabled

Daniel P. Berrange berrange at redhat.com
Thu Oct 14 12:23:53 UTC 2010


The statstest is xen specific. Instead of filling the code with
a huge number of #ifdef WITH_XEN, just make its entire compilation
conditional in the Makefile.am. Also ensure it links to the Xen
driver so that it builds when driver modules are enabled

* tests/Makefile.am: Make statstest xen conditional. Link to
  xen driver
* tests/Makefile.am: Remove all conditionals
---
 tests/Makefile.am |    8 ++++----
 tests/statstest.c |    7 -------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 64fac75..44fe579 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -238,6 +238,10 @@ reconnect_SOURCES = \
 	reconnect.c
 reconnect_LDADD = $(LDADDS)
 
+statstest_SOURCES = \
+	statstest.c testutils.h testutils.c
+statstest_LDADD = ../src/libvirt_driver_xen.la $(LDADDS)
+
 else
 EXTRA_DIST += xml2sexprtest.c sexpr2xmltest.c xmconfigtest.c \
 	xencapstest.c reconnect.c \
@@ -328,10 +332,6 @@ nodeinfotest_SOURCES = \
 	nodeinfotest.c testutils.h testutils.c
 nodeinfotest_LDADD = $(LDADDS)
 
-statstest_SOURCES = \
-	statstest.c testutils.h testutils.c
-statstest_LDADD = $(LDADDS)
-
 if WITH_SECDRIVER_SELINUX
 seclabeltest_SOURCES = \
 	seclabeltest.c
diff --git a/tests/statstest.c b/tests/statstest.c
index 5fad190..551615b 100644
--- a/tests/statstest.c
+++ b/tests/statstest.c
@@ -9,15 +9,12 @@
 #include "xen/block_stats.h"
 #include "testutils.h"
 
-#if WITH_XEN
 static void testQuietError(void *userData ATTRIBUTE_UNUSED,
                            virErrorPtr error ATTRIBUTE_UNUSED)
 {
     /* nada */
 }
-#endif
 
-#if __linux__ && WITH_XEN
 static int testDevice(const char *path, int expect)
 {
     int actual = xenLinuxDomainDeviceID(NULL, 1, path);
@@ -43,14 +40,11 @@ static int testDeviceHelper(const void *data)
     return testDevice(info->dev, info->num);
 }
 
-#endif
-
 static int
 mymain(int argc ATTRIBUTE_UNUSED,
        char **argv ATTRIBUTE_UNUSED)
 {
     int ret = 0;
-#if __linux__ && WITH_XEN
     /* Some of our tests delibrately test failure cases, so
      * register a handler to stop error messages cluttering
      * up display
@@ -201,7 +195,6 @@ mymain(int argc ATTRIBUTE_UNUSED,
     DO_TEST("/dev/xvda1", 51713);
     DO_TEST("/dev/xvda15", 51727);
 
-#endif
     return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
-- 
1.7.2.3




More information about the libvir-list mailing list