mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
c3ab6b2b53
Don't print OK/FAIL for tests that decide to be skipped after calling virtTestMain. Delay printing of the indentation before the first test until we know that the test didn't decide to be skipped. Also make the reconnect test use VIRT_TEST_MAIN.
70 lines
1.6 KiB
C
70 lines
1.6 KiB
C
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "internal.h"
|
|
#include "testutils.h"
|
|
#include "command.h"
|
|
|
|
static void errorHandler(void *userData ATTRIBUTE_UNUSED,
|
|
virErrorPtr error ATTRIBUTE_UNUSED) {
|
|
}
|
|
|
|
static int
|
|
mymain(void)
|
|
{
|
|
int id = 0;
|
|
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);
|
|
|
|
conn = virConnectOpen(NULL);
|
|
if (conn == NULL) {
|
|
ro = 1;
|
|
conn = virConnectOpenReadOnly(NULL);
|
|
}
|
|
if (conn == NULL) {
|
|
fprintf(stderr, "First virConnectOpen() failed\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
dom = virDomainLookupByID(conn, id);
|
|
if (dom == NULL) {
|
|
fprintf(stderr, "First lookup for domain %d failed\n", id);
|
|
return EXIT_FAILURE;
|
|
}
|
|
virDomainFree(dom);
|
|
virConnectClose(conn);
|
|
if (ro == 1)
|
|
conn = virConnectOpenReadOnly(NULL);
|
|
else
|
|
conn = virConnectOpen(NULL);
|
|
if (conn == NULL) {
|
|
fprintf(stderr, "Second virConnectOpen() failed\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
dom = virDomainLookupByID(conn, id);
|
|
if (dom == NULL) {
|
|
fprintf(stderr, "Second lookup for domain %d failed\n", id);
|
|
return EXIT_FAILURE;
|
|
}
|
|
virDomainFree(dom);
|
|
virConnectClose(conn);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
VIRT_TEST_MAIN(mymain)
|