]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Fix compressed test output padding logic
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 9 Jul 2011 08:40:37 +0000 (10:40 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 9 Jul 2011 13:40:23 +0000 (15:40 +0200)
The current logic tries to count from 1 to 40 and ignores paddings
of 0 and 1 to 40. This doesn't work for counter + 1 mod 40 == 0
like here for counter value 159

TEST: virsh-all
      ........................................ 40
      ........................................ 80
      ........................................ 120
      ....................................... 159 OK
PASS: virsh-all

Also seq isn't portable. Therefore, calculate the correct padding
length directly and use printf to output it at once.

tests/test-lib.sh

index 768f96b2bffa39359bdfc5e14bc7ea3545934af7..527dfda3834137e967ac650ccb7dbf577b905af9 100644 (file)
@@ -54,13 +54,8 @@ test_final()
   status=$2
 
   if test "$verbose" = "0" ; then
-    mod=`expr \( $counter + 1 \) % 40`
-    if test "$mod" != "0" && test "$mod" != "1" ; then
-      for i in `seq $mod 40`
-      do
-        printf " "
-      done
-    fi
+    len=`expr 40 - \( $counter % 40 \)`
+    printf "%${len}s" ""
     if test "$status" = "0" ; then
       printf " %-3d OK\n" $counter
     else