[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [libvirt] 1/3 testsuite formatting bugs [was: [PATCH] Skip some xen tests if xend is not running]
- From: Matthias Bolte <matthias bolte googlemail com>
- To: Eric Blake <eblake redhat com>
- Cc: libvir-list redhat com
- Subject: Re: [libvirt] 1/3 testsuite formatting bugs [was: [PATCH] Skip some xen tests if xend is not running]
- Date: Sat, 9 Jul 2011 10:44:37 +0200
2011/7/9 Eric Blake <eblake redhat com>:
> On 07/08/2011 07:40 PM, Eric Blake wrote:
>>>
>>> Instead count from 0 to 39 to fix this.
>>> ---
>>> tests/test-lib.sh | 6 +++---
>>> 1 files changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/tests/test-lib.sh b/tests/test-lib.sh
>>> index 768f96b..9eb6864 100644
>>> --- a/tests/test-lib.sh
>>> +++ b/tests/test-lib.sh
>>> @@ -54,9 +54,9 @@ 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`
>>> + mod=`expr $counter % 40`
>>> + if test "$mod" != "0" ; then
>>> + for i in `seq $mod 39`
>>
>> seq is a GNU-ism, but this is no less portable than what it was before.
>> (To be portable to platforms that lack seq, this should really be
>> written as:
>>
>> for i in 0 1 2 3 4 ... 39
>
> Why iterate in the first place?
>
> + if test "$mod" != "0" ; then
> + for i in `seq $mod 39`
> do
> printf " "
>
> can portably be replaced by:
>
> printf "%${len}s" ""
>
> with len computed via expr.
Yes, that approach is nicer and also the logic it a bit simpler. Here's a v2.
--
Matthias Bolte
http://photron.blogspot.com
From ed10abe21a27b2fddce50b0caf3273cbb40dfafd Mon Sep 17 00:00:00 2001
From: Matthias Bolte <matthias bolte googlemail com>
Date: Sat, 9 Jul 2011 10:40:37 +0200
Subject: [PATCH] tests: Fix compressed test output padding logic
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 | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 768f96b..527dfda 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -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
--
1.7.4.1
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]