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: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2019-05-03 10:31:02 +02:00
parent 3853372659
commit d07ce21610
19 changed files with 54 additions and 54 deletions

View File

@ -41,13 +41,13 @@ testCompareXMLToArgvFiles(const char *xmlfile,
driver.xmlopt))) { driver.xmlopt))) {
if ((flags & FLAG_EXPECT_FAILURE) && !virTestOOMActive()) { if ((flags & FLAG_EXPECT_FAILURE) && !virTestOOMActive()) {
VIR_TEST_DEBUG("Got expected failure from " VIR_TEST_DEBUG("Got expected failure from "
"bhyveParseCommandLineString.\n"); "bhyveParseCommandLineString.");
} else { } else {
goto fail; goto fail;
} }
} else if ((flags & FLAG_EXPECT_FAILURE) && !virTestOOMActive()) { } else if ((flags & FLAG_EXPECT_FAILURE) && !virTestOOMActive()) {
VIR_TEST_DEBUG("Did not get expected failure from " VIR_TEST_DEBUG("Did not get expected failure from "
"bhyveParseCommandLineString.\n"); "bhyveParseCommandLineString.");
goto fail; goto fail;
} }
@ -61,7 +61,7 @@ testCompareXMLToArgvFiles(const char *xmlfile,
log); log);
} else { } else {
VIR_TEST_DEBUG("bhyveParseCommandLineString " VIR_TEST_DEBUG("bhyveParseCommandLineString "
"should have logged a warning\n"); "should have logged a warning");
goto fail; goto fail;
} }
} else { /* didn't expect a warning */ } else { /* didn't expect a warning */

View File

@ -41,7 +41,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0; ret = 0;
} else if (flags & FLAG_EXPECT_FAILURE) { } else if (flags & FLAG_EXPECT_FAILURE) {
ret = 0; ret = 0;
VIR_TEST_DEBUG("Got expected error: %s\n", VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage()); virGetLastErrorMessage());
virResetLastError(); virResetLastError();
} }
@ -61,7 +61,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
if ((cmd == NULL) || (ldcmd == NULL)) { if ((cmd == NULL) || (ldcmd == NULL)) {
if (flags & FLAG_EXPECT_FAILURE) { if (flags & FLAG_EXPECT_FAILURE) {
ret = 0; ret = 0;
VIR_TEST_DEBUG("Got expected error: %s\n", VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage()); virGetLastErrorMessage());
virResetLastError(); virResetLastError();
} }

View File

@ -44,7 +44,7 @@ testCompareXMLToXMLHelper(const void *data)
if ((ret != 0) && (info->flags & FLAG_EXPECT_FAILURE)) { if ((ret != 0) && (info->flags & FLAG_EXPECT_FAILURE)) {
ret = 0; ret = 0;
VIR_TEST_DEBUG("Got expected error: %s\n", VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage()); virGetLastErrorMessage());
virResetLastError(); virResetLastError();
} }

View File

@ -1028,7 +1028,7 @@ mymain(void)
char *log; \ char *log; \
if ((log = virTestLogContentAndReset()) && \ if ((log = virTestLogContentAndReset()) && \
strlen(log) > 0) \ strlen(log) > 0) \
VIR_TEST_DEBUG("\n%s\n", log); \ VIR_TEST_DEBUG("\n%s", log); \
VIR_FREE(log); \ VIR_FREE(log); \
} \ } \
ret = -1; \ ret = -1; \

View File

@ -549,7 +549,7 @@ testCompareXMLToArgv(const void *data)
ok: ok:
if (ret == 0 && flags & FLAG_EXPECT_FAILURE) { if (ret == 0 && flags & FLAG_EXPECT_FAILURE) {
ret = -1; 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; goto cleanup;
} }
if (!virTestOOMActive()) { if (!virTestOOMActive()) {

View File

@ -64,7 +64,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES | VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES |
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE |
VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL))) { 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; goto cleanup;
} }
@ -74,7 +74,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET | VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET |
VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES | VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES |
VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST))) { 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; goto cleanup;
} }

View File

@ -38,13 +38,13 @@ testCompareXMLToArgvFiles(bool shouldFail,
case VIR_STORAGE_POOL_FS: case VIR_STORAGE_POOL_FS:
case VIR_STORAGE_POOL_NETFS: case VIR_STORAGE_POOL_NETFS:
if (!(pool = virStoragePoolObjNew())) { 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; goto cleanup;
} }
virStoragePoolObjSetDef(pool, def); virStoragePoolObjSetDef(pool, def);
if (!(src = virStorageBackendFileSystemGetPoolSource(pool))) { 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; def = NULL;
goto cleanup; goto cleanup;
} }
@ -70,12 +70,12 @@ testCompareXMLToArgvFiles(bool shouldFail,
case VIR_STORAGE_POOL_VSTORAGE: case VIR_STORAGE_POOL_VSTORAGE:
case VIR_STORAGE_POOL_LAST: case VIR_STORAGE_POOL_LAST:
default: 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; goto cleanup;
}; };
if (!(actualCmdline = virCommandToString(cmd, false))) { 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; goto cleanup;
} }

View File

@ -1004,7 +1004,7 @@ int virTestMain(int argc,
fprintf(stderr, "Usage: %s\n", argv[0]); fprintf(stderr, "Usage: %s\n", argv[0]);
fputs("effective environment variables:\n" fputs("effective environment variables:\n"
"VIR_TEST_VERBOSE set to show names of individual tests\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); stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -87,10 +87,10 @@ unsigned int virTestGetVerbose(void);
unsigned int virTestGetExpensive(void); unsigned int virTestGetExpensive(void);
unsigned int virTestGetRegenerate(void); unsigned int virTestGetRegenerate(void);
#define VIR_TEST_DEBUG(...) \ #define VIR_TEST_DEBUG(fmt, ...) \
do { \ do { \
if (virTestGetDebug()) \ if (virTestGetDebug()) \
fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
} while (0) } while (0)
#define VIR_TEST_VERBOSE(...) \ #define VIR_TEST_VERBOSE(...) \

View File

@ -837,7 +837,7 @@ testQemuGetLatestCapsForArch(const char *arch,
continue; continue;
if (virParseVersionString(tmp, &ver, false) < 0) { 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; continue;
} }

View File

@ -538,7 +538,7 @@ testQEMUSchemaGetLatest(void)
return NULL; return NULL;
} }
VIR_TEST_DEBUG("replies file: '%s'\n", capsLatestFile); VIR_TEST_DEBUG("replies file: '%s'", capsLatestFile);
if (virTestLoadFile(capsLatestFile, &capsLatest) < 0) if (virTestLoadFile(capsLatestFile, &capsLatest) < 0)
goto cleanup; goto cleanup;

View File

@ -78,8 +78,8 @@ testDiskNameToIndex(const void *data ATTRIBUTE_UNUSED)
idx = virDiskNameToIndex(diskName); idx = virDiskNameToIndex(diskName);
if (idx < 0 || idx != i) { if (idx < 0 || idx != i) {
VIR_TEST_DEBUG("\nExpect [%zu]\n", i); VIR_TEST_DEBUG("\nExpect [%zu]", i);
VIR_TEST_DEBUG("Actual [%d]\n", idx); VIR_TEST_DEBUG("Actual [%d]", idx);
VIR_FREE(diskName); VIR_FREE(diskName);
@ -108,21 +108,21 @@ testDiskNameParse(const void *data ATTRIBUTE_UNUSED)
return -1; return -1;
if (disk->idx != idx) { if (disk->idx != idx) {
VIR_TEST_DEBUG("\nExpect [%d]\n", disk->idx); VIR_TEST_DEBUG("\nExpect [%d]", disk->idx);
VIR_TEST_DEBUG("Actual [%d]\n", idx); VIR_TEST_DEBUG("Actual [%d]", idx);
return -1; return -1;
} }
if (disk->partition != partition) { if (disk->partition != partition) {
VIR_TEST_DEBUG("\nExpect [%d]\n", disk->partition); VIR_TEST_DEBUG("\nExpect [%d]", disk->partition);
VIR_TEST_DEBUG("Actual [%d]\n", partition); VIR_TEST_DEBUG("Actual [%d]", partition);
return -1; return -1;
} }
} }
for (i = 0; i < ARRAY_CARDINALITY(diskNamesInvalid); ++i) { for (i = 0; i < ARRAY_CARDINALITY(diskNamesInvalid); ++i) {
if (!virDiskNameParse(diskNamesInvalid[i], &idx, &partition)) { 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; return -1;
} }
} }
@ -166,9 +166,9 @@ testParseVersionString(const void *data ATTRIBUTE_UNUSED)
versions[i].allowMissing); versions[i].allowMissing);
if (result != versions[i].result) { if (result != versions[i].result) {
VIR_TEST_DEBUG("\nVersion string [%s]\n", versions[i].string); VIR_TEST_DEBUG("\nVersion string [%s]", versions[i].string);
VIR_TEST_DEBUG("Expect result [%d]\n", versions[i].result); VIR_TEST_DEBUG("Expect result [%d]", versions[i].result);
VIR_TEST_DEBUG("Actual result [%d]\n", result); VIR_TEST_DEBUG("Actual result [%d]", result);
return -1; return -1;
} }
@ -177,9 +177,9 @@ testParseVersionString(const void *data ATTRIBUTE_UNUSED)
continue; continue;
if (version != versions[i].version) { if (version != versions[i].version) {
VIR_TEST_DEBUG("\nVersion string [%s]\n", versions[i].string); VIR_TEST_DEBUG("\nVersion string [%s]", versions[i].string);
VIR_TEST_DEBUG("Expect version [%lu]\n", versions[i].version); VIR_TEST_DEBUG("Expect version [%lu]", versions[i].version);
VIR_TEST_DEBUG("Actual version [%lu]\n", version); VIR_TEST_DEBUG("Actual version [%lu]", version);
return -1; return -1;
} }
@ -213,9 +213,9 @@ testRoundValueToPowerOfTwo(const void *data ATTRIBUTE_UNUSED)
for (i = 0; i < ARRAY_CARDINALITY(roundData); i++) { for (i = 0; i < ARRAY_CARDINALITY(roundData); i++) {
result = VIR_ROUND_UP_POWER_OF_TWO(roundData[i].input); result = VIR_ROUND_UP_POWER_OF_TWO(roundData[i].input);
if (roundData[i].output != result) { if (roundData[i].output != result) {
VIR_TEST_DEBUG("\nInput number [%u]\n", roundData[i].input); VIR_TEST_DEBUG("\nInput number [%u]", roundData[i].input);
VIR_TEST_DEBUG("Expected number [%u]\n", roundData[i].output); VIR_TEST_DEBUG("Expected number [%u]", roundData[i].output);
VIR_TEST_DEBUG("Actual number [%u]\n", result); VIR_TEST_DEBUG("Actual number [%u]", result);
return -1; return -1;
} }

View File

@ -354,7 +354,7 @@ testBufAddStr(const void *opaque ATTRIBUTE_UNUSED)
} }
if (STRNEQ_NULLABLE(actual, data->expect)) { 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); virTestDifference(stderr, data->expect, actual);
goto cleanup; goto cleanup;
} }
@ -387,7 +387,7 @@ testBufEscapeStr(const void *opaque ATTRIBUTE_UNUSED)
} }
if (STRNEQ_NULLABLE(actual, data->expect)) { 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); virTestDifference(stderr, data->expect, actual);
goto cleanup; goto cleanup;
} }
@ -416,7 +416,7 @@ testBufEscapeRegex(const void *opaque)
} }
if (STRNEQ_NULLABLE(actual, data->expect)) { 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); virTestDifference(stderr, data->expect, actual);
goto cleanup; goto cleanup;
} }
@ -445,7 +445,7 @@ testBufSetIndent(const void *opaque ATTRIBUTE_UNUSED)
goto cleanup; goto cleanup;
if (STRNEQ(actual, " test\n test2\n")) { 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; goto cleanup;
} }

View File

@ -48,7 +48,7 @@ linuxTestCompareFiles(const char *cpuinfofile,
&nodeinfo.cores, &nodeinfo.threads) < 0) { &nodeinfo.cores, &nodeinfo.threads) < 0) {
if (virTestGetDebug()) { if (virTestGetDebug()) {
if (virGetLastErrorCode()) if (virGetLastErrorCode())
VIR_TEST_DEBUG("\n%s\n", virGetLastErrorMessage()); VIR_TEST_DEBUG("\n%s", virGetLastErrorMessage());
} }
VIR_FORCE_FCLOSE(cpuinfo); VIR_FORCE_FCLOSE(cpuinfo);
goto fail; goto fail;

View File

@ -42,7 +42,7 @@ testJSONFromFile(const void *data)
VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc); VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
return -1; return -1;
} else { } 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; return 0;
} }
} else { } else {
@ -77,7 +77,7 @@ testJSONFromString(const void *data)
VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc); VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
return -1; return -1;
} else { } 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; return 0;
} }
} else { } 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))) { if (!(formatted = virJSONValueToString(json, false))) {
VIR_TEST_VERBOSE("Failed to format json data\n"); VIR_TEST_VERBOSE("Failed to format json data\n");

View File

@ -36,7 +36,7 @@ testLogMatch(const void *opaque)
bool got = virLogProbablyLogMessage(data->str); bool got = virLogProbablyLogMessage(data->str);
if (got != data->pass) { 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); data->pass, got, data->str);
return -1; return -1;
} }
@ -54,7 +54,7 @@ testLogParseOutputs(const void *opaque)
noutputs = virLogParseOutputs(data->str, &outputs); noutputs = virLogParseOutputs(data->str, &outputs);
if (noutputs < 0) { if (noutputs < 0) {
if (!data->pass) { if (!data->pass) {
VIR_TEST_DEBUG("Got expected error: %s\n", VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage()); virGetLastErrorMessage());
virResetLastError(); virResetLastError();
ret = 0; ret = 0;
@ -62,10 +62,10 @@ testLogParseOutputs(const void *opaque)
} }
} else if (noutputs != data->count) { } else if (noutputs != data->count) {
VIR_TEST_DEBUG("Expected number of parsed outputs is %d, " 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; goto cleanup;
} else if (!data->pass) { } else if (!data->pass) {
VIR_TEST_DEBUG("Test should have failed\n"); VIR_TEST_DEBUG("Test should have failed");
goto cleanup; goto cleanup;
} }
@ -86,7 +86,7 @@ testLogParseFilters(const void *opaque)
nfilters = virLogParseFilters(data->str, &filters); nfilters = virLogParseFilters(data->str, &filters);
if (nfilters < 0) { if (nfilters < 0) {
if (!data->pass) { if (!data->pass) {
VIR_TEST_DEBUG("Got expected error: %s\n", VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage()); virGetLastErrorMessage());
virResetLastError(); virResetLastError();
ret = 0; ret = 0;
@ -94,10 +94,10 @@ testLogParseFilters(const void *opaque)
} }
} else if (nfilters != data->count) { } else if (nfilters != data->count) {
VIR_TEST_DEBUG("Expected number of parsed outputs is %d, " 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; goto cleanup;
} else if (!data->pass) { } else if (!data->pass) {
VIR_TEST_DEBUG("Test should have failed\n"); VIR_TEST_DEBUG("Test should have failed");
goto cleanup; goto cleanup;
} }

View File

@ -338,13 +338,13 @@ static int testExecRestart(const void *opaque)
cleanup: cleanup:
if (ret < 0) { if (ret < 0) {
if (!data->pass) { if (!data->pass) {
VIR_TEST_DEBUG("Got expected error: %s\n", VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage()); virGetLastErrorMessage());
virResetLastError(); virResetLastError();
ret = 0; ret = 0;
} }
} else if (!data->pass) { } else if (!data->pass) {
VIR_TEST_DEBUG("Test should have failed\n"); VIR_TEST_DEBUG("Test should have failed");
ret = -1; ret = -1;
} }
VIR_FREE(infile); VIR_FREE(infile);

View File

@ -329,7 +329,7 @@ mymain(void)
char *fakerootdir; char *fakerootdir;
if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
VIR_TEST_DEBUG("Out of memory\n"); VIR_TEST_DEBUG("Out of memory");
abort(); abort();
} }

View File

@ -56,7 +56,7 @@ test_virResctrlGetUnused(const void *opaque)
ret = 0; ret = 0;
goto cleanup; goto cleanup;
} else if (data->fail) { } 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; ret = -1;
goto cleanup; goto cleanup;
} }