提交 9693e293 编写于 作者: E Eric Blake

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.
上级 eb314315
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册