There is an inconsistency with VIR_TEST_DEBUG() calls. One half
(roughly) of calls does have the newline character the other one
doesn't. Well, it doesn't have it because it assumed blindly that
new line will be printed, which is not the case.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/bhyveargv2xmltest.c | 6 +++---
tests/bhyvexml2argvtest.c | 4 ++--
tests/bhyvexml2xmltest.c | 2 +-
tests/cputest.c | 2 +-
tests/qemuxml2argvtest.c | 2 +-
tests/qemuxml2xmltest.c | 4 ++--
tests/storagepoolxml2argvtest.c | 8 ++++----
tests/testutils.c | 2 +-
tests/testutils.h | 4 +++-
tests/testutilsqemu.c | 2 +-
tests/testutilsqemuschema.c | 2 +-
tests/utiltest.c | 32 ++++++++++++++++----------------
tests/virbuftest.c | 8 ++++----
tests/virhostcputest.c | 2 +-
tests/virjsontest.c | 6 +++---
tests/virlogtest.c | 14 +++++++-------
tests/virnetdaemontest.c | 4 ++--
tests/virpcitest.c | 2 +-
tests/virresctrltest.c | 2 +-
19 files changed, 55 insertions(+), 53 deletions(-)
diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c
index d552364846..49acb74759 100644
--- a/tests/bhyveargv2xmltest.c
+++ b/tests/bhyveargv2xmltest.c
@@ -41,13 +41,13 @@ testCompareXMLToArgvFiles(const char *xmlfile,
driver.xmlopt))) {
if ((flags & FLAG_EXPECT_FAILURE) && !virTestOOMActive()) {
VIR_TEST_DEBUG("Got expected failure from "
- "bhyveParseCommandLineString.\n");
+ "bhyveParseCommandLineString.");
} else {
goto fail;
}
} else if ((flags & FLAG_EXPECT_FAILURE) && !virTestOOMActive()) {
VIR_TEST_DEBUG("Did not get expected failure from "
- "bhyveParseCommandLineString.\n");
+ "bhyveParseCommandLineString.");
goto fail;
}
@@ -61,7 +61,7 @@ testCompareXMLToArgvFiles(const char *xmlfile,
log);
} else {
VIR_TEST_DEBUG("bhyveParseCommandLineString "
- "should have logged a warning\n");
+ "should have logged a warning");
goto fail;
}
} else { /* didn't expect a warning */
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index c84925c57b..72374d74ba 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -41,7 +41,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
} else if (flags & FLAG_EXPECT_FAILURE) {
ret = 0;
- VIR_TEST_DEBUG("Got expected error: %s\n",
+ VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage());
virResetLastError();
}
@@ -61,7 +61,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
if ((cmd == NULL) || (ldcmd == NULL)) {
if (flags & FLAG_EXPECT_FAILURE) {
ret = 0;
- VIR_TEST_DEBUG("Got expected error: %s\n",
+ VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage());
virResetLastError();
}
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index e8a6867fcd..a02d16cb9e 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -44,7 +44,7 @@ testCompareXMLToXMLHelper(const void *data)
if ((ret != 0) && (info->flags & FLAG_EXPECT_FAILURE)) {
ret = 0;
- VIR_TEST_DEBUG("Got expected error: %s\n",
+ VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage());
virResetLastError();
}
diff --git a/tests/cputest.c b/tests/cputest.c
index 6e28e05756..dfc01f7e75 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -1028,7 +1028,7 @@ mymain(void)
char *log; \
if ((log = virTestLogContentAndReset()) && \
strlen(log) > 0) \
- VIR_TEST_DEBUG("\n%s\n", log); \
+ VIR_TEST_DEBUG("\n%s", log); \
VIR_FREE(log); \
} \
ret = -1; \
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c166fd18d6..1f4d4ed09a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -549,7 +549,7 @@ testCompareXMLToArgv(const void *data)
ok:
if (ret == 0 && flags & FLAG_EXPECT_FAILURE) {
ret = -1;
- VIR_TEST_DEBUG("Error expected but there wasn't any.\n");
+ VIR_TEST_DEBUG("Error expected but there wasn't any.");
goto cleanup;
}
if (!virTestOOMActive()) {
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 525eb9a740..07bcc29c1e 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -62,7 +62,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES |
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE |
VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL))) {
- VIR_TEST_DEBUG("\nfailed to parse '%s'\n", data->infile);
+ VIR_TEST_DEBUG("\nfailed to parse '%s'", data->infile);
goto cleanup;
}
@@ -72,7 +72,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET |
VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES |
VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST))) {
- VIR_TEST_DEBUG("\nfailed to format back '%s'\n",
data->infile);
+ VIR_TEST_DEBUG("\nfailed to format back '%s'",
data->infile);
goto cleanup;
}
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
index 0c01931946..8e09149906 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -38,13 +38,13 @@ testCompareXMLToArgvFiles(bool shouldFail,
case VIR_STORAGE_POOL_FS:
case VIR_STORAGE_POOL_NETFS:
if (!(pool = virStoragePoolObjNew())) {
- VIR_TEST_DEBUG("pool type '%s' alloc pool obj fails\n",
defTypeStr);
+ VIR_TEST_DEBUG("pool type '%s' alloc pool obj fails",
defTypeStr);
goto cleanup;
}
virStoragePoolObjSetDef(pool, def);
if (!(src = virStorageBackendFileSystemGetPoolSource(pool))) {
- VIR_TEST_DEBUG("pool type '%s' has no pool source\n",
defTypeStr);
+ VIR_TEST_DEBUG("pool type '%s' has no pool source",
defTypeStr);
def = NULL;
goto cleanup;
}
@@ -70,12 +70,12 @@ testCompareXMLToArgvFiles(bool shouldFail,
case VIR_STORAGE_POOL_VSTORAGE:
case VIR_STORAGE_POOL_LAST:
default:
- VIR_TEST_DEBUG("pool type '%s' has no xml2argv test\n",
defTypeStr);
+ VIR_TEST_DEBUG("pool type '%s' has no xml2argv test",
defTypeStr);
goto cleanup;
};
if (!(actualCmdline = virCommandToString(cmd, false))) {
- VIR_TEST_DEBUG("pool type '%s' failed to get commandline\n",
defTypeStr);
+ VIR_TEST_DEBUG("pool type '%s' failed to get commandline",
defTypeStr);
goto cleanup;
}
diff --git a/tests/testutils.c b/tests/testutils.c
index 245b1832f6..d6a6742e10 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -1006,7 +1006,7 @@ int virTestMain(int argc,
fprintf(stderr, "Usage: %s\n", argv[0]);
fputs("effective environment variables:\n"
"VIR_TEST_VERBOSE set to show names of individual tests\n"
- "VIR_TEST_DEBUG set to show information for debugging
failures\n",
+ "VIR_TEST_DEBUG set to show information for debugging failures",
stderr);
return EXIT_FAILURE;
}
diff --git a/tests/testutils.h b/tests/testutils.h
index 8c12fd7c12..cfc60084b2 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -89,8 +89,10 @@ unsigned int virTestGetRegenerate(void);
#define VIR_TEST_DEBUG(...) \
do { \
- if (virTestGetDebug()) \
+ if (virTestGetDebug()) { \
fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ } \
} while (0)
#define VIR_TEST_VERBOSE(...) \
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 9ac9f9bd39..cd04606cf0 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -837,7 +837,7 @@ testQemuGetLatestCapsForArch(const char *arch,
continue;
if (virParseVersionString(tmp, &ver, false) < 0) {
- VIR_TEST_DEBUG("skipping caps file '%s'\n",
ent->d_name);
+ VIR_TEST_DEBUG("skipping caps file '%s'", ent->d_name);
continue;
}
diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c
index f1365e8846..0728771bfe 100644
--- a/tests/testutilsqemuschema.c
+++ b/tests/testutilsqemuschema.c
@@ -538,7 +538,7 @@ testQEMUSchemaGetLatest(void)
return NULL;
}
- VIR_TEST_DEBUG("replies file: '%s'\n", capsLatestFile);
+ VIR_TEST_DEBUG("replies file: '%s'", capsLatestFile);
if (virTestLoadFile(capsLatestFile, &capsLatest) < 0)
goto cleanup;
diff --git a/tests/utiltest.c b/tests/utiltest.c
index 5e4920e3ca..71b8d869bd 100644
--- a/tests/utiltest.c
+++ b/tests/utiltest.c
@@ -78,8 +78,8 @@ testDiskNameToIndex(const void *data ATTRIBUTE_UNUSED)
idx = virDiskNameToIndex(diskName);
if (idx < 0 || idx != i) {
- VIR_TEST_DEBUG("\nExpect [%zu]\n", i);
- VIR_TEST_DEBUG("Actual [%d]\n", idx);
+ VIR_TEST_DEBUG("\nExpect [%zu]", i);
+ VIR_TEST_DEBUG("Actual [%d]", idx);
VIR_FREE(diskName);
@@ -108,21 +108,21 @@ testDiskNameParse(const void *data ATTRIBUTE_UNUSED)
return -1;
if (disk->idx != idx) {
- VIR_TEST_DEBUG("\nExpect [%d]\n", disk->idx);
- VIR_TEST_DEBUG("Actual [%d]\n", idx);
+ VIR_TEST_DEBUG("\nExpect [%d]", disk->idx);
+ VIR_TEST_DEBUG("Actual [%d]", idx);
return -1;
}
if (disk->partition != partition) {
- VIR_TEST_DEBUG("\nExpect [%d]\n", disk->partition);
- VIR_TEST_DEBUG("Actual [%d]\n", partition);
+ VIR_TEST_DEBUG("\nExpect [%d]", disk->partition);
+ VIR_TEST_DEBUG("Actual [%d]", partition);
return -1;
}
}
for (i = 0; i < ARRAY_CARDINALITY(diskNamesInvalid); ++i) {
if (!virDiskNameParse(diskNamesInvalid[i], &idx, &partition)) {
- VIR_TEST_DEBUG("Should Fail [%s]\n", diskNamesInvalid[i]);
+ VIR_TEST_DEBUG("Should Fail [%s]", diskNamesInvalid[i]);
return -1;
}
}
@@ -166,9 +166,9 @@ testParseVersionString(const void *data ATTRIBUTE_UNUSED)
versions[i].allowMissing);
if (result != versions[i].result) {
- VIR_TEST_DEBUG("\nVersion string [%s]\n", versions[i].string);
- VIR_TEST_DEBUG("Expect result [%d]\n", versions[i].result);
- VIR_TEST_DEBUG("Actual result [%d]\n", result);
+ VIR_TEST_DEBUG("\nVersion string [%s]", versions[i].string);
+ VIR_TEST_DEBUG("Expect result [%d]", versions[i].result);
+ VIR_TEST_DEBUG("Actual result [%d]", result);
return -1;
}
@@ -177,9 +177,9 @@ testParseVersionString(const void *data ATTRIBUTE_UNUSED)
continue;
if (version != versions[i].version) {
- VIR_TEST_DEBUG("\nVersion string [%s]\n", versions[i].string);
- VIR_TEST_DEBUG("Expect version [%lu]\n", versions[i].version);
- VIR_TEST_DEBUG("Actual version [%lu]\n", version);
+ VIR_TEST_DEBUG("\nVersion string [%s]", versions[i].string);
+ VIR_TEST_DEBUG("Expect version [%lu]", versions[i].version);
+ VIR_TEST_DEBUG("Actual version [%lu]", version);
return -1;
}
@@ -213,9 +213,9 @@ testRoundValueToPowerOfTwo(const void *data ATTRIBUTE_UNUSED)
for (i = 0; i < ARRAY_CARDINALITY(roundData); i++) {
result = VIR_ROUND_UP_POWER_OF_TWO(roundData[i].input);
if (roundData[i].output != result) {
- VIR_TEST_DEBUG("\nInput number [%u]\n", roundData[i].input);
- VIR_TEST_DEBUG("Expected number [%u]\n", roundData[i].output);
- VIR_TEST_DEBUG("Actual number [%u]\n", result);
+ VIR_TEST_DEBUG("\nInput number [%u]", roundData[i].input);
+ VIR_TEST_DEBUG("Expected number [%u]", roundData[i].output);
+ VIR_TEST_DEBUG("Actual number [%u]", result);
return -1;
}
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index caad6f3ecb..a7eaef636d 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -354,7 +354,7 @@ testBufAddStr(const void *opaque ATTRIBUTE_UNUSED)
}
if (STRNEQ_NULLABLE(actual, data->expect)) {
- VIR_TEST_DEBUG("testBufAddStr(): Strings don't match:\n");
+ VIR_TEST_DEBUG("testBufAddStr(): Strings don't match:");
virTestDifference(stderr, data->expect, actual);
goto cleanup;
}
@@ -387,7 +387,7 @@ testBufEscapeStr(const void *opaque ATTRIBUTE_UNUSED)
}
if (STRNEQ_NULLABLE(actual, data->expect)) {
- VIR_TEST_DEBUG("testBufEscapeStr(): Strings don't match:\n");
+ VIR_TEST_DEBUG("testBufEscapeStr(): Strings don't match:");
virTestDifference(stderr, data->expect, actual);
goto cleanup;
}
@@ -416,7 +416,7 @@ testBufEscapeRegex(const void *opaque)
}
if (STRNEQ_NULLABLE(actual, data->expect)) {
- VIR_TEST_DEBUG("testBufEscapeRegex: Strings don't match:\n");
+ VIR_TEST_DEBUG("testBufEscapeRegex: Strings don't match:");
virTestDifference(stderr, data->expect, actual);
goto cleanup;
}
@@ -445,7 +445,7 @@ testBufSetIndent(const void *opaque ATTRIBUTE_UNUSED)
goto cleanup;
if (STRNEQ(actual, " test\n test2\n")) {
- VIR_TEST_DEBUG("testBufSetIndent: expected indent not set\n");
+ VIR_TEST_DEBUG("testBufSetIndent: expected indent not set");
goto cleanup;
}
diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c
index bb60dd3ffc..88e6e9dc16 100644
--- a/tests/virhostcputest.c
+++ b/tests/virhostcputest.c
@@ -48,7 +48,7 @@ linuxTestCompareFiles(const char *cpuinfofile,
&nodeinfo.cores, &nodeinfo.threads) <
0) {
if (virTestGetDebug()) {
if (virGetLastErrorCode())
- VIR_TEST_DEBUG("\n%s\n", virGetLastErrorMessage());
+ VIR_TEST_DEBUG("\n%s", virGetLastErrorMessage());
}
VIR_FORCE_FCLOSE(cpuinfo);
goto fail;
diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index 4241acd911..dbc0b41cc8 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -42,7 +42,7 @@ testJSONFromFile(const void *data)
VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
return -1;
} else {
- VIR_TEST_DEBUG("As expected, failed to parse %s\n", info->doc);
+ VIR_TEST_DEBUG("As expected, failed to parse %s", info->doc);
return 0;
}
} else {
@@ -77,7 +77,7 @@ testJSONFromString(const void *data)
VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
return -1;
} else {
- VIR_TEST_DEBUG("As expected, failed to parse %s\n", info->doc);
+ VIR_TEST_DEBUG("As expected, failed to parse %s", info->doc);
return 0;
}
} else {
@@ -87,7 +87,7 @@ testJSONFromString(const void *data)
}
}
- VIR_TEST_DEBUG("Parsed %s\n", info->doc);
+ VIR_TEST_DEBUG("Parsed %s", info->doc);
if (!(formatted = virJSONValueToString(json, false))) {
VIR_TEST_VERBOSE("Failed to format json data\n");
diff --git a/tests/virlogtest.c b/tests/virlogtest.c
index 62b4b75300..ea7fd5e2a4 100644
--- a/tests/virlogtest.c
+++ b/tests/virlogtest.c
@@ -36,7 +36,7 @@ testLogMatch(const void *opaque)
bool got = virLogProbablyLogMessage(data->str);
if (got != data->pass) {
- VIR_TEST_DEBUG("Expected '%d' but got '%d' for
'%s'\n",
+ VIR_TEST_DEBUG("Expected '%d' but got '%d' for
'%s'",
data->pass, got, data->str);
return -1;
}
@@ -54,7 +54,7 @@ testLogParseOutputs(const void *opaque)
noutputs = virLogParseOutputs(data->str, &outputs);
if (noutputs < 0) {
if (!data->pass) {
- VIR_TEST_DEBUG("Got expected error: %s\n",
+ VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage());
virResetLastError();
ret = 0;
@@ -62,10 +62,10 @@ testLogParseOutputs(const void *opaque)
}
} else if (noutputs != data->count) {
VIR_TEST_DEBUG("Expected number of parsed outputs is %d, "
- "but got %d\n", data->count, noutputs);
+ "but got %d", data->count, noutputs);
goto cleanup;
} else if (!data->pass) {
- VIR_TEST_DEBUG("Test should have failed\n");
+ VIR_TEST_DEBUG("Test should have failed");
goto cleanup;
}
@@ -86,7 +86,7 @@ testLogParseFilters(const void *opaque)
nfilters = virLogParseFilters(data->str, &filters);
if (nfilters < 0) {
if (!data->pass) {
- VIR_TEST_DEBUG("Got expected error: %s\n",
+ VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage());
virResetLastError();
ret = 0;
@@ -94,10 +94,10 @@ testLogParseFilters(const void *opaque)
}
} else if (nfilters != data->count) {
VIR_TEST_DEBUG("Expected number of parsed outputs is %d, "
- "but got %d\n", data->count, nfilters);
+ "but got %d", data->count, nfilters);
goto cleanup;
} else if (!data->pass) {
- VIR_TEST_DEBUG("Test should have failed\n");
+ VIR_TEST_DEBUG("Test should have failed");
goto cleanup;
}
diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c
index 816bfe05d4..9089428047 100644
--- a/tests/virnetdaemontest.c
+++ b/tests/virnetdaemontest.c
@@ -338,13 +338,13 @@ static int testExecRestart(const void *opaque)
cleanup:
if (ret < 0) {
if (!data->pass) {
- VIR_TEST_DEBUG("Got expected error: %s\n",
+ VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage());
virResetLastError();
ret = 0;
}
} else if (!data->pass) {
- VIR_TEST_DEBUG("Test should have failed\n");
+ VIR_TEST_DEBUG("Test should have failed");
ret = -1;
}
VIR_FREE(infile);
diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index 961a7eff1a..b4c51851d7 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -359,7 +359,7 @@ mymain(void)
char *fakerootdir;
if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
- VIR_TEST_DEBUG("Out of memory\n");
+ VIR_TEST_DEBUG("Out of memory");
abort();
}
diff --git a/tests/virresctrltest.c b/tests/virresctrltest.c
index 5abbb11e9a..34882ac127 100644
--- a/tests/virresctrltest.c
+++ b/tests/virresctrltest.c
@@ -56,7 +56,7 @@ test_virResctrlGetUnused(const void *opaque)
ret = 0;
goto cleanup;
} else if (data->fail) {
- VIR_TEST_DEBUG("Error expected but there wasn't any.\n");
+ VIR_TEST_DEBUG("Error expected but there wasn't any.");
ret = -1;
goto cleanup;
}
--
2.21.0