From: Matthias Bolte Date: Sat, 9 Jul 2011 09:50:38 +0000 (+0200) Subject: tests: Improve output of tests that decide to skip at runtime X-Git-Tag: v0.9.4-rc1~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3ab6b2b53bd05750634ba595e1b920a3afd0b7e;p=thirdparty%2Flibvirt.git 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. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 528b88e2c6..e9a445ed75 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 = \ diff --git a/tests/reconnect.c b/tests/reconnect.c index e5553b549b..d4aa9f398d 100644 --- a/tests/reconnect.c +++ b/tests/reconnect.c @@ -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) diff --git a/tests/testutils.c b/tests/testutils.c index b4332041d7..c89f70f417 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -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, " ");