[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] qemuxml2argvtest: Append newline to tested error messages



'virTestCompareToFile' automatically fixes newline if it is not present
in the input string but is present in the file. In this case we need to
append the erorr messages with a newline so that
VIR_TEST_REGENERATE_OUTPUT produces files which will pass syntax-check.

Fixes: 9ec77eef2df
Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 tests/qemuxml2argvtest.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a3c91fd5de..2b97eb80a4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -621,9 +621,11 @@ testCompareXMLToArgv(const void *data)
             VIR_TEST_DEBUG("no error was reported for expected parse error");
             goto cleanup;
         }
-        if (flags & FLAG_EXPECT_PARSE_ERROR &&
-            virTestCompareToFile(err->message, info->errfile) >= 0)
-            goto ok;
+        if (flags & FLAG_EXPECT_PARSE_ERROR) {
+            g_autofree char *tmperr = g_strdup_printf("%s\n", NULLSTR(err->message));
+            if (virTestCompareToFile(tmperr, info->errfile) >= 0)
+                goto ok;
+        }
         goto cleanup;
     }
     if (flags & FLAG_EXPECT_PARSE_ERROR) {
@@ -663,9 +665,11 @@ testCompareXMLToArgv(const void *data)
             VIR_TEST_DEBUG("no error was reported for expected failure");
             goto cleanup;
         }
-        if (flags & FLAG_EXPECT_FAILURE &&
-            virTestCompareToFile(err->message, info->errfile) >= 0)
-            goto ok;
+        if (flags & FLAG_EXPECT_FAILURE) {
+            g_autofree char *tmperr = g_strdup_printf("%s\n", NULLSTR(err->message));
+            if (virTestCompareToFile(tmperr, info->errfile) >= 0)
+                goto ok;
+        }
         goto cleanup;
     }
     if (flags & FLAG_EXPECT_FAILURE) {
-- 
2.26.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]