From 41828514bb91953e9a47453d5d4e667ccfd74b71 Mon Sep 17 00:00:00 2001 From: Jim Fehlig Date: Thu, 7 Jul 2011 15:53:41 -0600 Subject: [PATCH] Skip some xen tests if xend is not running 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 | 12 ++++++++++++ tests/statstest.c | 14 +++++++++++++- 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/configure.ac b/configure.ac index aa589d646a..ae747fb248 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 48f9faabfa..528b88e2c6 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 63877fc6b6..e5553b549b 100644 --- a/tests/reconnect.c +++ b/tests/reconnect.c @@ -4,6 +4,8 @@ #include #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); diff --git a/tests/statstest.c b/tests/statstest.c index c9899922aa..18cdc5c515 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,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 */