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.
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
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;