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
This commit is contained in:
Jim Fehlig 2011-07-07 15:53:41 -06:00
parent 17da0669e0
commit 41828514bb
4 changed files with 29 additions and 33 deletions

View 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

View 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

View 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);

View 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
*/