]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: simplify formatting
authorEric Blake <eblake@redhat.com>
Mon, 11 Jul 2011 15:19:11 +0000 (09:19 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 11 Jul 2011 15:21:37 +0000 (09:21 -0600)
The shell version would output 40 extra spaces for a test with
a multiple of 40 sub-tests, and the C version can use the same
printf optimization for avoiding a loop over single space output
as the shell version.

* tests/testutils.c (virtTestMain): Avoid loop for alignment.
* tests/test-lib.sh: Fix formatting when counter is multiple of 40.

tests/test-lib.sh
tests/testutils.c

index 527dfda3834137e967ac650ccb7dbf577b905af9..918bf734318a32f4a9248d2428f354ba976d8535 100644 (file)
@@ -54,7 +54,7 @@ test_final()
   status=$2
 
   if test "$verbose" = "0" ; then
-    len=`expr 40 - \( $counter % 40 \)`
+    len=`expr 39 - \( \( $counter - 1 \) % 40 \)`
     printf "%${len}s" ""
     if test "$status" = "0" ; then
       printf " %-3d OK\n" $counter
index c89f70f4171667babb121f62de97113faddcb186..ac5d298978cf5f940048bba071be8856caaf6e44 100644 (file)
@@ -693,9 +693,8 @@ cleanup:
         VIR_FREE(abs_srcdir);
     virResetLastError();
     if (!virTestGetVerbose() && ret != EXIT_AM_SKIP) {
-        int i;
-        for (i = (testCounter % 40) ; i > 0 && i < 40 ; i++)
-            fprintf(stderr, " ");
+        if (testCounter == 0 || testCounter % 40)
+            fprintf(stderr, "%*s", 40 - (testCounter % 40), "");
         fprintf(stderr, " %-3d %s\n", testCounter, ret == 0 ? "OK" : "FAIL");
     }
     return ret;