* src/Makefile.am: add a tst target to ease building test progs

* src/xend_internal.c: fix the reconnection problem to xend pointed
  by Philippe Berthault
* tests/Makefile.am tests/reconnect.c: add a specific test case
Daniel
This commit is contained in:
Daniel Veillard
2006-09-21 09:15:33 +00:00
parent 29182e995e
commit 546026a5be
5 changed files with 76 additions and 23 deletions

View File

@@ -19,9 +19,10 @@ LDADDS = \
EXTRA_DIST = xmlrpcserver.py test_conf.sh
noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest
noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \
reconnect
TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh
TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh reconnect
valgrind:
$(MAKE) check TESTS_ENVIRONMENT="valgrind --quiet"
@@ -59,5 +60,10 @@ conftest_SOURCES = \
conftest_LDFLAGS =
conftest_LDADD = $(LDADDS)
reconnect_SOURCES = \
reconnect.c
reconnect_LDFLAGS =
reconnect_LDADD = $(LDADDS)
$(LIBVIRT):
-@(cd $(top_builddir)/src && $(MAKE) MAKEFLAGS+=--silent)

38
tests/reconnect.c Normal file
View File

@@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <libvirt/libvirt.h>
int main(void) {
int id = 0;
virConnectPtr conn;
virDomainPtr dom;
conn = virConnectOpen("");
if (conn == NULL) {
fprintf(stderr, "First virConnectOpen() failed\n");
exit(1);
}
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "First lookup for domain %d failed\n", id);
exit(1);
}
virDomainFree(dom);
virConnectClose(conn);
conn = virConnectOpen("");
if (conn == NULL) {
fprintf(stderr, "Second virConnectOpen() failed\n");
exit(1);
}
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "Second lookup for domain %d failed\n", id);
exit(1);
}
virDomainFree(dom);
virConnectClose(conn);
printf("OK\n");
exit(0);
}