mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
tests: Improve output of tests that decide to skip at runtime
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.
This commit is contained in:
parent
b1c9bf27cb
commit
c3ab6b2b53
@ -300,7 +300,7 @@ xencapstest_SOURCES = \
|
||||
xencapstest_LDADD = ../src/libvirt_driver_xen.la $(LDADDS)
|
||||
|
||||
reconnect_SOURCES = \
|
||||
reconnect.c
|
||||
reconnect.c testutils.h testutils.c
|
||||
reconnect_LDADD = $(LDADDS)
|
||||
|
||||
statstest_SOURCES = \
|
||||
|
@ -11,7 +11,9 @@ static void errorHandler(void *userData ATTRIBUTE_UNUSED,
|
||||
virErrorPtr error ATTRIBUTE_UNUSED) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
static int
|
||||
mymain(void)
|
||||
{
|
||||
int id = 0;
|
||||
int ro = 0;
|
||||
virConnectPtr conn;
|
||||
@ -36,12 +38,12 @@ int main(void) {
|
||||
}
|
||||
if (conn == NULL) {
|
||||
fprintf(stderr, "First virConnectOpen() failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
dom = virDomainLookupByID(conn, id);
|
||||
if (dom == NULL) {
|
||||
fprintf(stderr, "First lookup for domain %d failed\n", id);
|
||||
exit(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
virDomainFree(dom);
|
||||
virConnectClose(conn);
|
||||
@ -51,16 +53,17 @@ int main(void) {
|
||||
conn = virConnectOpen(NULL);
|
||||
if (conn == NULL) {
|
||||
fprintf(stderr, "Second virConnectOpen() failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
dom = virDomainLookupByID(conn, id);
|
||||
if (dom == NULL) {
|
||||
fprintf(stderr, "Second lookup for domain %d failed\n", id);
|
||||
exit(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
virDomainFree(dom);
|
||||
virConnectClose(conn);
|
||||
printf("OK\n");
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
VIRT_TEST_MAIN(mymain)
|
||||
|
@ -76,6 +76,9 @@ void virtTestResult(const char *name, int ret, const char *msg, ...)
|
||||
va_list vargs;
|
||||
va_start(vargs, msg);
|
||||
|
||||
if (testCounter == 0 && !virTestGetVerbose())
|
||||
fprintf(stderr, " ");
|
||||
|
||||
testCounter++;
|
||||
if (virTestGetVerbose()) {
|
||||
fprintf(stderr, "%3d) %-60s ", testCounter, name);
|
||||
@ -113,6 +116,9 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const
|
||||
int i, ret = 0;
|
||||
double *ts = NULL;
|
||||
|
||||
if (testCounter == 0 && !virTestGetVerbose())
|
||||
fprintf(stderr, " ");
|
||||
|
||||
testCounter++;
|
||||
|
||||
if (testOOM < 2) {
|
||||
@ -562,8 +568,6 @@ int virtTestMain(int argc,
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
fprintf(stderr, "TEST: %s\n", progname);
|
||||
if (!virTestGetVerbose())
|
||||
fprintf(stderr, " ");
|
||||
|
||||
if (virThreadInitialize() < 0 ||
|
||||
virErrorInitialize() < 0 ||
|
||||
@ -688,7 +692,7 @@ cleanup:
|
||||
if (abs_srcdir_cleanup)
|
||||
VIR_FREE(abs_srcdir);
|
||||
virResetLastError();
|
||||
if (!virTestGetVerbose()) {
|
||||
if (!virTestGetVerbose() && ret != EXIT_AM_SKIP) {
|
||||
int i;
|
||||
for (i = (testCounter % 40) ; i > 0 && i < 40 ; i++)
|
||||
fprintf(stderr, " ");
|
||||
|
Loading…
Reference in New Issue
Block a user