[libvirt] [PATCHv3 22/36] tests: virstoragetest: Fix output when hitting errors

Peter Krempa pkrempa at redhat.com
Fri May 30 08:37:44 UTC 2014


When the test is failing but the debug output isn't enabled the
resulting line would look ugly like and would not contain the actual
difference.

TEST: virstoragetest
      .................chain member 1!chain member 1!chain member 1!

Store the member index in the actual checked string to hide this problem
---
 tests/virstoragetest.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 03f8552..e1adce9 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -313,6 +313,7 @@ struct testChainData


 static const char testStorageChainFormat[] =
+    "chain member: %zu\n"
     "path:%s\n"
     "backingStoreRaw: %s\n"
     "capacity: %lld\n"
@@ -383,7 +384,7 @@ testStorageChain(const void *args)
         expRelDir = isAbs ? data->files[i]->relDirAbs
             : data->files[i]->relDirRel;
         if (virAsprintf(&expect,
-                        testStorageChainFormat,
+                        testStorageChainFormat, i,
                         NULLSTR(data->files[i]->path),
                         NULLSTR(data->files[i]->expBackingStoreRaw),
                         data->files[i]->expCapacity,
@@ -393,7 +394,7 @@ testStorageChain(const void *args)
                         data->files[i]->type,
                         data->files[i]->format) < 0 ||
             virAsprintf(&actual,
-                        testStorageChainFormat,
+                        testStorageChainFormat, i,
                         NULLSTR(elt->path),
                         NULLSTR(elt->backingStoreRaw),
                         elt->capacity,
@@ -407,7 +408,6 @@ testStorageChain(const void *args)
             goto cleanup;
         }
         if (STRNEQ(expect, actual)) {
-            fprintf(stderr, "chain member %zu", i);
             virtTestDifference(stderr, expect, actual);
             VIR_FREE(expect);
             VIR_FREE(actual);
-- 
1.9.3




More information about the libvir-list mailing list