From: Eric Blake Date: Mon, 11 Jul 2011 15:19:11 +0000 (-0600) Subject: tests: simplify formatting X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9693e293959959dafdb8c114608141b277ba69ce;p=libvirt.git tests: simplify formatting 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. --- diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 527dfda383..918bf73431 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -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 diff --git a/tests/testutils.c b/tests/testutils.c index c89f70f417..ac5d298978 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -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;