virbuftest: Cleanup code around virTestDifference()

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>
This commit is contained in:
Michal Privoznik 2022-11-30 09:39:46 +01:00
parent f3b049e878
commit 69bb187e82

View 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;
}