[libvirt] testsuite formatting bugs [was: [PATCH] Skip some xen tests if xend is not running]

Eric Blake eblake at redhat.com
Sat Jul 9 02:05:41 UTC 2011


On 07/08/2011 05:28 PM, Matthias Bolte wrote:
>> TEST: virsh-all
>>      ........................................ 40
>>      ........................................ 80
>>      ........................................ 120
>>      ....................................... 159 OK
>> PASS: virsh-all
>>
>> We're obviously getting the logic wrong when there are 0 or when
>> tests%40 == 39.
> 
> Here are two patches for this, plus one to use EXIT_AM_SKIP more.

An even better patch for the SKIP logic.  Why do a for loop of
one space at a time, when printf can do it for us?

From fbaee4f7df0bd04520948228de125ce0c6112130 Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake at redhat.com>
Date: Fri, 8 Jul 2011 19:55:02 -0600
Subject: [PATCH] tests: handle skipped tests better

Without this, running statstest withtout xen wasn't formatted well:

TEST: statstest
       0   FAIL
SKIP: statstest

* tests/testutils.c (virtTestMain): Special case skipped test.
---
 tests/testutils.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index b433204..fe04caa 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -689,10 +689,10 @@ cleanup:
         VIR_FREE(abs_srcdir);
     virResetLastError();
     if (!virTestGetVerbose()) {
-        int i;
-        for (i = (testCounter % 40) ; i > 0 && i < 40 ; i++)
-            fprintf(stderr, " ");
-        fprintf(stderr, " %-3d %s\n", testCounter, ret == 0 ? "OK" :
"FAIL");
+        if (testCounter == 0 || testCounter % 40)
+            fprintf(stderr, "%*s", 40 - (testCounter % 40), "");
+        fprintf(stderr, " %-3d %s\n", testCounter,
+                ret == 0 ? "OK" : ret == EXIT_AM_SKIP ? "SKIP" : "FAIL");
     }
     return ret;
 }
-- 
1.7.4.4



-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110708/634a762a/attachment-0001.sig>


More information about the libvir-list mailing list