提交 d07ce216 编写于 作者: M Michal Privoznik

tests: Always put a '\n' after each debug print

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: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 38533726
......@@ -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 */
......
......@@ -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();
}
......
......@@ -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();
}
......
......@@ -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; \
......
......@@ -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()) {
......
......@@ -64,7 +64,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;
}
......@@ -74,7 +74,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;
}
......
......@@ -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;
}
......
......@@ -1004,7 +1004,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;
}
......
......@@ -87,10 +87,10 @@ unsigned int virTestGetVerbose(void);
unsigned int virTestGetExpensive(void);
unsigned int virTestGetRegenerate(void);
#define VIR_TEST_DEBUG(...) \
#define VIR_TEST_DEBUG(fmt, ...) \
do { \
if (virTestGetDebug()) \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
} while (0)
#define VIR_TEST_VERBOSE(...) \
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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");
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -329,7 +329,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();
}
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册