mirror of https://gitee.com/openkylin/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.
This commit is contained in:
parent
eb3143154e
commit
9693e29395
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue