]> xenbits.xensource.com Git - libvirt.git/commitdiff
Skip some xen tests if xend is not running
authorJim Fehlig <jfehlig@novell.com>
Thu, 7 Jul 2011 21:53:41 +0000 (15:53 -0600)
committerJim Fehlig <jfehlig@novell.com>
Thu, 7 Jul 2011 23:23:09 +0000 (17:23 -0600)
Currently, the xen statstest and reconnect tests are only compiled
if xend is running.  Compile them unconditionally if xen headers
are present, but skip the tests at runtime if xend is not running.

This is in response to Eric's suggestion here

https://www.redhat.com/archives/libvir-list/2011-July/msg00367.html

configure.ac
tests/Makefile.am
tests/reconnect.c
tests/statstest.c

index aa589d646af723e737cda101535dd18ee81b3648..ae747fb2483c88b49401547f22868cf3e57b0941 100644 (file)
@@ -1982,30 +1982,6 @@ AM_CONDITIONAL([WITH_PYTHON], [test "$with_python" = "yes"])
 AC_SUBST([PYTHON_VERSION])
 AC_SUBST([PYTHON_INCLUDES])
 
-
-
-AC_MSG_CHECKING([whether this host is running a Xen kernel])
-RUNNING_XEN=
-if test -d /proc/sys/xen
-then
-    RUNNING_XEN=yes
-else
-    RUNNING_XEN=no
-fi
-AC_MSG_RESULT($RUNNING_XEN)
-
-AC_MSG_CHECKING([If XenD UNIX socket /var/run/xend/xmlrpc.sock is accessible])
-RUNNING_XEND=
-if test -S /var/run/xend/xmlrpc.sock
-then
-    RUNNING_XEND=yes
-else
-    RUNNING_XEND=no
-fi
-AC_MSG_RESULT($RUNNING_XEND)
-
-AM_CONDITIONAL([ENABLE_XEN_TESTS], [test "$RUNNING_XEN" != "no" && test "$RUNNING_XEND" != "no"])
-
 AC_ARG_ENABLE([test-coverage],
   AC_HELP_STRING([--enable-test-coverage], [turn on code coverage instrumentation @<:@default=no@:>@]),
 [case "${enableval}" in
index 48f9faabfa3b04ffe3c46447bb79ed7d3a1125d1..528b88e2c6dadb222e573372bff2aff8355f0d97 100644 (file)
@@ -93,10 +93,7 @@ ssh_LDADD = $(COVERAGE_LDFLAGS)
 
 if WITH_XEN
 check_PROGRAMS += xml2sexprtest sexpr2xmltest \
-       xmconfigtest xencapstest
-if ENABLE_XEN_TESTS
-check_PROGRAMS += statstest reconnect
-endif
+       xmconfigtest xencapstest statstest reconnect
 endif
 if WITH_QEMU
 check_PROGRAMS += qemuxml2argvtest qemuxml2xmltest qemuargv2xmltest qemuhelptest
@@ -216,10 +213,9 @@ if WITH_XEN
 TESTS += xml2sexprtest \
        sexpr2xmltest \
        xmconfigtest \
-       xencapstest
-if ENABLE_XEN_TESTS
-TESTS += reconnect statstest
-endif
+       xencapstest \
+       reconnect \
+       statstest
 endif
 
 if WITH_QEMU
index 63877fc6b6994cfeef5cf6d615e3f533bb9e5d12..e5553b549bd8d7f06e464ad490a45a57c85f4784 100644 (file)
@@ -4,6 +4,8 @@
 #include <stdlib.h>
 
 #include "internal.h"
+#include "testutils.h"
+#include "command.h"
 
 static void errorHandler(void *userData ATTRIBUTE_UNUSED,
                          virErrorPtr error ATTRIBUTE_UNUSED) {
@@ -14,6 +16,16 @@ int main(void) {
     int ro = 0;
     virConnectPtr conn;
     virDomainPtr dom;
+    int status;
+    virCommandPtr cmd;
+
+    /* skip test if xend is not running */
+    cmd = virCommandNewArgList("/usr/sbin/xend", "status", NULL);
+    if (virCommandRun(cmd, &status) != 0 || status != 0) {
+        virCommandFree(cmd);
+        return EXIT_AM_SKIP;
+    }
+    virCommandFree(cmd);
 
     virSetErrorFunc(NULL, errorHandler);
 
index c9899922aac833e6c7f2a1a837e1b3781f069f03..18cdc5c515427bcf3425b371ba68274b25bfeb39 100644 (file)
@@ -8,6 +8,7 @@
 #include "internal.h"
 #include "xen/block_stats.h"
 #include "testutils.h"
+#include "command.h"
 
 static void testQuietError(void *userData ATTRIBUTE_UNUSED,
                            virErrorPtr error ATTRIBUTE_UNUSED)
@@ -44,7 +45,18 @@ static int
 mymain(void)
 {
     int ret = 0;
-    /* Some of our tests delibrately test failure cases, so
+    int status;
+    virCommandPtr cmd;
+
+    /* skip test if xend is not running */
+    cmd = virCommandNewArgList("/usr/sbin/xend", "status", NULL);
+    if (virCommandRun(cmd, &status) != 0 || status != 0) {
+        virCommandFree(cmd);
+        return EXIT_AM_SKIP;
+    }
+    virCommandFree(cmd);
+
+    /* Some of our tests deliberately test failure cases, so
      * register a handler to stop error messages cluttering
      * up display
      */