[libvirt] [PATCH] tests: Don't add extra padding if counter mod 40 is 0

--- tests/test-lib.sh | 10 ++++++---- tests/testutils.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 43265f3..57fd438 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -55,10 +55,12 @@ test_final() if test "$verbose" = "0" ; then mod=`eval "expr \( $counter + 1 \) % 40"` - for i in `seq $mod 40` - do - echo -n " " - done + if test "$mod" != "0" -a "$mod" != "1" ; then + for i in `seq $mod 40` + do + echo -n " " + done + fi if test "$status" = "0" ; then printf " %-3d OK\n" $counter else diff --git a/tests/testutils.c b/tests/testutils.c index 8764673..99bd9df 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -531,7 +531,7 @@ cleanup: virResetLastError(); if (!virTestGetVerbose()) { int i; - for (i = (testCounter % 40) ; i < 40 ; i++) + for (i = (testCounter % 40) ; i > 0 && i < 40 ; i++) fprintf(stderr, " "); fprintf(stderr, " %-3d %s\n", testCounter, ret == 0 ? "OK" : "FAIL"); } -- 1.6.3.3

On Sat, Mar 20, 2010 at 06:14:44PM +0100, Matthias Bolte wrote:
--- tests/test-lib.sh | 10 ++++++---- tests/testutils.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 43265f3..57fd438 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -55,10 +55,12 @@ test_final()
if test "$verbose" = "0" ; then mod=`eval "expr \( $counter + 1 \) % 40"` - for i in `seq $mod 40` - do - echo -n " " - done + if test "$mod" != "0" -a "$mod" != "1" ; then + for i in `seq $mod 40` + do + echo -n " " + done + fi if test "$status" = "0" ; then printf " %-3d OK\n" $counter else diff --git a/tests/testutils.c b/tests/testutils.c index 8764673..99bd9df 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -531,7 +531,7 @@ cleanup: virResetLastError(); if (!virTestGetVerbose()) { int i; - for (i = (testCounter % 40) ; i < 40 ; i++) + for (i = (testCounter % 40) ; i > 0 && i < 40 ; i++) fprintf(stderr, " "); fprintf(stderr, " %-3d %s\n", testCounter, ret == 0 ? "OK" : "FAIL"); }
I'm not entirely understanding what this is changing ? This is what I currently see: $ ./qemuxml2argvtest TEST: qemuxml2argvtest ........................................ 40 ........................................ 80 ....... 87 OK And this change doesn't appear to alter that - what am I missing ? Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

2010/3/22 Daniel P. Berrange <berrange@redhat.com>:
On Sat, Mar 20, 2010 at 06:14:44PM +0100, Matthias Bolte wrote:
--- tests/test-lib.sh | 10 ++++++---- tests/testutils.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 43265f3..57fd438 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -55,10 +55,12 @@ test_final()
if test "$verbose" = "0" ; then mod=`eval "expr \( $counter + 1 \) % 40"` - for i in `seq $mod 40` - do - echo -n " " - done + if test "$mod" != "0" -a "$mod" != "1" ; then + for i in `seq $mod 40` + do + echo -n " " + done + fi if test "$status" = "0" ; then printf " %-3d OK\n" $counter else diff --git a/tests/testutils.c b/tests/testutils.c index 8764673..99bd9df 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -531,7 +531,7 @@ cleanup: virResetLastError(); if (!virTestGetVerbose()) { int i; - for (i = (testCounter % 40) ; i < 40 ; i++) + for (i = (testCounter % 40) ; i > 0 && i < 40 ; i++) fprintf(stderr, " "); fprintf(stderr, " %-3d %s\n", testCounter, ret == 0 ? "OK" : "FAIL"); }
I'm not entirely understanding what this is changing ?
This is what I currently see:
$ ./qemuxml2argvtest TEST: qemuxml2argvtest ........................................ 40 ........................................ 80 ....... 87 OK
And this change doesn't appear to alter that - what am I missing ?
Regards, Daniel
This change only affects the output of tests that have an exact multiple of 40 test cases. For example the domainschematest currently: TEST: domainschematest ........................................ 40 ........................................ 80 ........................................ 120 ........................................ 160 ........................................ 200 OK PASS: domainschematest It outputs additional 40 spaces on the last line. The domainschematest output is fixed by the change in test-lib.sh. The change in testutils.c fixes this for tests written in C. Currently no C test has an exact multiple of 40 test cases, but I checked it and the same problem exists there. This patch stops that in both cases. Matthias

On Mon, Mar 22, 2010 at 09:17:21PM +0100, Matthias Bolte wrote:
2010/3/22 Daniel P. Berrange <berrange@redhat.com>:
On Sat, Mar 20, 2010 at 06:14:44PM +0100, Matthias Bolte wrote:
--- tests/test-lib.sh | 10 ++++++---- tests/testutils.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 43265f3..57fd438 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -55,10 +55,12 @@ test_final()
if test "$verbose" = "0" ; then mod=`eval "expr \( $counter + 1 \) % 40"` - for i in `seq $mod 40` - do - echo -n " " - done + if test "$mod" != "0" -a "$mod" != "1" ; then + for i in `seq $mod 40` + do + echo -n " " + done + fi if test "$status" = "0" ; then printf " %-3d OK\n" $counter else diff --git a/tests/testutils.c b/tests/testutils.c index 8764673..99bd9df 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -531,7 +531,7 @@ cleanup: virResetLastError(); if (!virTestGetVerbose()) { int i; - for (i = (testCounter % 40) ; i < 40 ; i++) + for (i = (testCounter % 40) ; i > 0 && i < 40 ; i++) fprintf(stderr, " "); fprintf(stderr, " %-3d %s\n", testCounter, ret == 0 ? "OK" : "FAIL"); }
I'm not entirely understanding what this is changing ?
This is what I currently see:
$ ./qemuxml2argvtest TEST: qemuxml2argvtest ........................................ 40 ........................................ 80 ....... 87 OK
And this change doesn't appear to alter that - what am I missing ?
Regards, Daniel
This change only affects the output of tests that have an exact multiple of 40 test cases. For example the domainschematest currently:
TEST: domainschematest ........................................ 40 ........................................ 80 ........................................ 120 ........................................ 160 ........................................ 200 OK PASS: domainschematest
It outputs additional 40 spaces on the last line.
The domainschematest output is fixed by the change in test-lib.sh. The change in testutils.c fixes this for tests written in C. Currently no C test has an exact multiple of 40 test cases, but I checked it and the same problem exists there.
ACK, can you put this note in the commit message too. Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

2010/3/22 Daniel P. Berrange <berrange@redhat.com>:
On Mon, Mar 22, 2010 at 09:17:21PM +0100, Matthias Bolte wrote:
2010/3/22 Daniel P. Berrange <berrange@redhat.com>:
On Sat, Mar 20, 2010 at 06:14:44PM +0100, Matthias Bolte wrote:
--- átests/test-lib.sh | á 10 ++++++---- átests/testutils.c | á á2 +- á2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 43265f3..57fd438 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -55,10 +55,12 @@ test_final()
á áif test "$verbose" = "0" ; then á á ámod=`eval "expr \( $counter + 1 \) % 40"` - á áfor i in `seq $mod 40` - á ádo - á á áecho -n " " - á ádone + á áif test "$mod" != "0" -a "$mod" != "1" ; then + á á áfor i in `seq $mod 40` + á á ádo + á á á áecho -n " " + á á ádone + á áfi á á áif test "$status" = "0" ; then á á á áprintf " %-3d OK\n" $counter á á áelse diff --git a/tests/testutils.c b/tests/testutils.c index 8764673..99bd9df 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -531,7 +531,7 @@ cleanup: á á ávirResetLastError(); á á áif (!virTestGetVerbose()) { á á á á áint i; - á á á áfor (i = (testCounter % 40) ; i < 40 ; i++) + á á á áfor (i = (testCounter % 40) ; i > 0 && i < 40 ; i++) á á á á á á áfprintf(stderr, " "); á á á á áfprintf(stderr, " %-3d %s\n", testCounter, ret == 0 ? "OK" : "FAIL"); á á á}
I'm not entirely understanding what this is changing ?
This is what I currently see:
$ ./qemuxml2argvtest TEST: qemuxml2argvtest á á á........................................ 40 á á á........................................ 80 á á á....... á á á á á á á á á á á á á á á á á87 áOK
And this change doesn't appear to alter that - what am I missing ?
Regards, Daniel
This change only affects the output of tests that have an exact multiple of 40 test cases. For example the domainschematest currently:
TEST: domainschematest ........................................ 40 ........................................ 80 ........................................ 120 ........................................ 160 ........................................ 200 OK PASS: domainschematest
It outputs additional 40 spaces on the last line.
The domainschematest output is fixed by the change in test-lib.sh. The change in testutils.c fixes this for tests written in C. Currently no C test has an exact multiple of 40 test cases, but I checked it and the same problem exists there.
ACK, can you put this note in the commit message too.
Regards, Daniel
Okay, extended the commit message and pushed the patch. Matthias

On 03/20/2010 11:14 AM, Matthias Bolte wrote:
if test "$verbose" = "0" ; then mod=`eval "expr \( $counter + 1 \) % 40"` - for i in `seq $mod 40` - do - echo -n " " - done + if test "$mod" != "0" -a "$mod" != "1" ; then
test cond1 -a cond2 is not portable. Use test cond1 && test cond2.
+ for i in `seq $mod 40` + do + echo -n " "
echo -n is not portable (although you didn't introduce its use). Use printf ' ' instead. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Matthias Bolte