]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Always put a '\n' after each debug print
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 3 May 2019 08:31:02 +0000 (10:31 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 27 Aug 2019 13:49:48 +0000 (15:49 +0200)
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>
19 files changed:
tests/bhyveargv2xmltest.c
tests/bhyvexml2argvtest.c
tests/bhyvexml2xmltest.c
tests/cputest.c
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c
tests/storagepoolxml2argvtest.c
tests/testutils.c
tests/testutils.h
tests/testutilsqemu.c
tests/testutilsqemuschema.c
tests/utiltest.c
tests/virbuftest.c
tests/virhostcputest.c
tests/virjsontest.c
tests/virlogtest.c
tests/virnetdaemontest.c
tests/virpcitest.c
tests/virresctrltest.c

index 8e29225e3177c7e57d84489bc7b5d6894eece9c8..1684f03355cc6534b3f8fe8440f1d0909fdf4c26 100644 (file)
@@ -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 */
index 14ceac052e7c6385d1952fd867181f91640a428b..eeedd04f729982b2933077790039577be86aecbe 100644 (file)
@@ -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();
         }
index 66394e2ae4e04d1d0d4b15c461624a2afc2e3cf2..9f64df8bb2734bb8b6640e1cd80a3396e10adab2 100644 (file)
@@ -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();
     }
index 6e28e05756aca8045bb6ed618e42741be7724047..dfc01f7e7561c8fa7b1eaa2918b254ae10680d21 100644 (file)
@@ -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; \
index 1799eb33870357e21844c61eebdd8995aa26617d..e9f45775e5de5ccc408b285e0c685c1c932094eb 100644 (file)
@@ -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()) {
index 4981eca8643a88e79c1f1305a4979a2575007584..0ea4ae0342a172bbebbf17753f516875e639319a 100644 (file)
@@ -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;
     }
 
index 0c01931946407798e2bb4fca52dd3222b3ed1a95..8e0914990613b74b69b3874874337cef2e4d1821 100644 (file)
@@ -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;
     }
 
index 1fda3763f98d8f2aa29c0ad155089c4c43f4f7b6..8b2c51044e750d4c2912fa2ce26e0dd355d4c57e 100644 (file)
@@ -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;
     }
index b46bc86d84286ae5ff081a0e85e490a682ac2735..bc2e3269e51a78200ec37cdd877a3c1606f620f9 100644 (file)
@@ -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(...) \
index 9ac9f9bd39d5a8612cdf80667941ca73670fb085..cd04606cf03f79bea0af48a971f9e84fd1d8cc6c 100644 (file)
@@ -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;
         }
 
index f1365e8846bb66f26b7e9493891461fd53f6275c..0728771bfe91abb359a31dd92c946f019ef630fc 100644 (file)
@@ -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;
index 5e4920e3ca6078bfc15ff2d13614a3525e472499..71b8d869bdc487f848ad92de33b59c6cd7fd52dd 100644 (file)
@@ -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;
         }
index caad6f3ecb2b7bc4c2686901d88c316de638ca40..a7eaef636d12070be021172f046664db6941a20e 100644 (file)
@@ -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;
     }
 
index 9ee0d2f15b3cdcdfc279fec7ea42e53a4206cfe7..03ed3b16092e59043ea4224b6d416d0222b40267 100644 (file)
@@ -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;
index 4241acd9113de52747a59d57368afeb8abf99ed2..dbc0b41cc8a209682ec36299bdd49d6c587f58ae 100644 (file)
@@ -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");
index 62b4b753004813a26c465dc8efcdde486f4187bd..ea7fd5e2a44f75ad9fcf0a62585ae1e39800f0f4 100644 (file)
@@ -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;
     }
 
index 0a7556890218f6c456f0bf6fa5676e6841663ad3..255ef8064265d647fbf70544ff8bfef0cf144d15 100644 (file)
@@ -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);
index 12b142700a1a25819d8dc1ec5b9769281e7c6404..6f71c39d0300b787974620b9911ff5c03a3c4fa7 100644 (file)
@@ -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();
     }
 
index 5abbb11e9ac7322227355c6e73cac00d1345a82e..34882ac127a5e6a42cdfcd34a91f8f9942783b62 100644 (file)
@@ -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;
     }