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

Re: [libvirt] [PATCH] Skip some xen tests if xend is not running



On Thu, Jul 07, 2011 at 04:00:01PM -0600, Jim Fehlig wrote:
> 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      |   24 ------------------------
>  tests/Makefile.am |   12 ++++--------
>  tests/reconnect.c |   11 +++++++++++
>  tests/statstest.c |   12 ++++++++++++
>  4 files changed, 27 insertions(+), 32 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index aa589d6..ae747fb 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -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
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 48f9faa..528b88e 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -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
> diff --git a/tests/reconnect.c b/tests/reconnect.c
> index 63877fc..4bc092f 100644
> --- a/tests/reconnect.c
> +++ b/tests/reconnect.c
> @@ -4,6 +4,7 @@
>  #include <stdlib.h>
>  
>  #include "internal.h"
> +#include "command.h"
>  
>  static void errorHandler(void *userData ATTRIBUTE_UNUSED,
>                           virErrorPtr error ATTRIBUTE_UNUSED) {
> @@ -14,6 +15,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 77;
> +    }
> +    virCommandFree(cmd);
>  
>      virSetErrorFunc(NULL, errorHandler);
>  
> diff --git a/tests/statstest.c b/tests/statstest.c
> index c989992..7074914 100644
> --- a/tests/statstest.c
> +++ b/tests/statstest.c
> @@ -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,6 +45,17 @@ static int
>  mymain(void)
>  {
>      int ret = 0;
> +    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 77;
> +    }
> +    virCommandFree(cmd);
> +
>      /* Some of our tests delibrately test failure cases, so
>       * register a handler to stop error messages cluttering
>       * up display

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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