[PATCHv3 20/36] tests: storagetest: Unify and reformat storage chain format string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All the fields crammed into two lines weren't easy to parse by human
eyes. Split up the format string into lines and put it into a central
variable so that changes in two places aren't necessary.
---
 tests/virstoragetest.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 771df0b..3c892d5 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -312,6 +312,18 @@ struct testChainData
     unsigned int flags;
 };

+
+static const char testStorageChainFormat[] =
+    "store: %s\n"
+    "backingStoreRaw: %s\n"
+    "capacity: %lld\n"
+    "encryption: %d\n"
+    "relPath:%s\n"
+    "path:%s\n"
+    "relDir:%s\n"
+    "type:%d\n"
+    "format:%d\n";
+
 static int
 testStorageChain(const void *args)
 {
@@ -373,8 +385,7 @@ testStorageChain(const void *args)
         expRelDir = isAbs ? data->files[i]->relDirAbs
             : data->files[i]->relDirRel;
         if (virAsprintf(&expect,
-                        "store:%s\nraw:%s\nother:%lld %d\n"
-                        "relPath:%s\npath:%s\nrelDir:%s\ntype:%d %d\n",
+                        testStorageChainFormat,
                         NULLSTR(data->files[i]->expBackingStore),
                         NULLSTR(data->files[i]->expBackingStoreRaw),
                         data->files[i]->expCapacity,
@@ -385,15 +396,16 @@ testStorageChain(const void *args)
                         data->files[i]->type,
                         data->files[i]->format) < 0 ||
             virAsprintf(&actual,
-                        "store:%s\nraw:%s\nother:%lld %d\n"
-                        "relPath:%s\npath:%s\nrelDir:%s\ntype:%d %d\n",
+                        testStorageChainFormat,
                         NULLSTR(elt->backingStore ? elt->backingStore->path : NULL),
                         NULLSTR(elt->backingStoreRaw),
-                        elt->capacity, !!elt->encryption,
+                        elt->capacity,
+                        !!elt->encryption,
                         NULLSTR(elt->relPath),
                         NULLSTR(elt->path),
                         NULLSTR(elt->relDir),
-                        elt->type, elt->format) < 0) {
+                        elt->type,
+                        elt->format) < 0) {
             VIR_FREE(expect);
             VIR_FREE(actual);
             goto cleanup;
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]