]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virbuftest: Cleanup code around virTestDifference()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 30 Nov 2022 08:39:46 +0000 (09:39 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Dec 2022 13:22:39 +0000 (14:22 +0100)
Two things are happening here:

1) Call to virTestDifference() is guarded by '!result ||
   STRNEQ(result, _)' check. This is suboptimal since we have
   STRNEQ_NULLABLE().

2) There are couple of VIR_TEST_DEBUG() printings, which are
   useless. If debug is off they don't print anything, and if it
   is on, then much more information is printed by subsequent
   virTestDifference().

This makes the STRNEQ() + virTestDifference() combo look similar
to the rest of tests and thus can be picked up by spatch later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
tests/virbuftest.c

index 0ca7927c3fc391470ed3939de4c7fa619571d338..144df6e66bda2d9c78deb2a88f8f85f05b2c3ec8 100644 (file)
@@ -92,7 +92,7 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
     virBufferAddChar(buf, '\n');
 
     result = virBufferContentAndReset(buf);
-    if (!result || STRNEQ(result, expected)) {
+    if (STRNEQ_NULLABLE(result, expected)) {
         virTestDifference(stderr, expected, result);
         ret = -1;
     }
@@ -122,7 +122,7 @@ static int testBufTrim(const void *data G_GNUC_UNUSED)
     virBufferTrim(buf, ",,");
 
     result = virBufferContentAndReset(buf);
-    if (!result || STRNEQ(result, expected)) {
+    if (STRNEQ_NULLABLE(result, expected)) {
         virTestDifference(stderr, expected, result);
         return -1;
     }
@@ -146,7 +146,6 @@ testBufTrimChars(const void *opaque)
     }
 
     if (STRNEQ_NULLABLE(actual, data->expect)) {
-        VIR_TEST_DEBUG("testBufEscapeStr(): Strings don't match:");
         virTestDifference(stderr, data->expect, actual);
         return -1;
     }
@@ -278,7 +277,6 @@ testBufAddStr(const void *opaque)
     }
 
     if (STRNEQ_NULLABLE(actual, data->expect)) {
-        VIR_TEST_DEBUG("testBufAddStr(): Strings don't match:");
         virTestDifference(stderr, data->expect, actual);
         return -1;
     }
@@ -306,7 +304,6 @@ testBufEscapeStr(const void *opaque)
     }
 
     if (STRNEQ_NULLABLE(actual, data->expect)) {
-        VIR_TEST_DEBUG("testBufEscapeStr(): Strings don't match:");
         virTestDifference(stderr, data->expect, actual);
         return -1;
     }
@@ -330,7 +327,6 @@ testBufEscapeRegex(const void *opaque)
     }
 
     if (STRNEQ_NULLABLE(actual, data->expect)) {
-        VIR_TEST_DEBUG("testBufEscapeRegex: Strings don't match:");
         virTestDifference(stderr, data->expect, actual);
         return -1;
     }