[libvirt] [PATCH] tests: virjson: Reuse VIR_TEST_VERBOSE in testJSONCopy

Peter Krempa posted 1 patch 6 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/a1ac4c880bc52b3cf112b76295cfd56d5ba0eea9.1499777014.git.pkrempa@redhat.com
tests/virjsontest.c | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
[libvirt] [PATCH] tests: virjson: Reuse VIR_TEST_VERBOSE in testJSONCopy
Posted by Peter Krempa 6 years, 9 months ago
Use VIR_TEST_VERBOSE instead of calling virTestGetVerbose and
conditionally fprintf. Additionally remove redundant setting of 'ret' to
-1.
---

Pushed as trivial.

 tests/virjsontest.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index b3a230a02..b9c210620 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -240,40 +240,31 @@ testJSONCopy(const void *data)

     json = virJSONValueFromString(info->doc);
     if (!json) {
-        if (virTestGetVerbose())
-            fprintf(stderr, "Failed to parse %s\n", info->doc);
-        ret = -1;
+        VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
         goto cleanup;
     }

     jsonCopy = virJSONValueCopy(json);
     if (!jsonCopy) {
-        if (virTestGetVerbose())
-            fprintf(stderr, "Failed to copy JSON data\n");
-        ret = -1;
+        VIR_TEST_VERBOSE("Failed to copy JSON data\n");
         goto cleanup;
     }

     result = virJSONValueToString(json, false);
     if (!result) {
-        if (virTestGetVerbose())
-            fprintf(stderr, "Failed to format original JSON data\n");
-        ret = -1;
+        VIR_TEST_VERBOSE("Failed to format original JSON data\n");
         goto cleanup;
     }

     resultCopy = virJSONValueToString(json, false);
     if (!resultCopy) {
-        if (virTestGetVerbose())
-            fprintf(stderr, "Failed to format copied JSON data\n");
-        ret = -1;
+        VIR_TEST_VERBOSE("Failed to format copied JSON data\n");
         goto cleanup;
     }

     if (STRNEQ(result, resultCopy)) {
         if (virTestGetVerbose())
             virTestDifference(stderr, result, resultCopy);
-        ret = -1;
         goto cleanup;
     }

@@ -282,24 +273,19 @@ testJSONCopy(const void *data)

     result = virJSONValueToString(json, true);
     if (!result) {
-        if (virTestGetVerbose())
-            fprintf(stderr, "Failed to format original JSON data\n");
-        ret = -1;
+        VIR_TEST_VERBOSE("Failed to format original JSON data\n");
         goto cleanup;
     }

     resultCopy = virJSONValueToString(json, true);
     if (!resultCopy) {
-        if (virTestGetVerbose())
-            fprintf(stderr, "Failed to format copied JSON data\n");
-        ret = -1;
+        VIR_TEST_VERBOSE("Failed to format copied JSON data\n");
         goto cleanup;
     }

     if (STRNEQ(result, resultCopy)) {
         if (virTestGetVerbose())
             virTestDifference(stderr, result, resultCopy);
-        ret = -1;
         goto cleanup;
     }

-- 
2.12.2

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