]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Improve output of tests that decide to skip at runtime
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 9 Jul 2011 09:50:38 +0000 (11:50 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 9 Jul 2011 13:47:57 +0000 (15:47 +0200)
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.

tests/Makefile.am
tests/reconnect.c
tests/testutils.c

index 528b88e2c6dadb222e573372bff2aff8355f0d97..e9a445ed754ed95d1fd6a65323a4c2bfac33bfd9 100644 (file)
@@ -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 = \
index e5553b549bd8d7f06e464ad490a45a57c85f4784..d4aa9f398d57a87b6271ba158a53127fff4b65a3 100644 (file)
@@ -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)
index b4332041d7ffb6400e1a42295375c0a1c96423bb..c89f70f4171667babb121f62de97113faddcb186 100644 (file)
@@ -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, " ");