]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuxml2argvtest: Append newline to tested error messages
authorPeter Krempa <pkrempa@redhat.com>
Thu, 24 Sep 2020 11:09:47 +0000 (13:09 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 24 Sep 2020 11:53:15 +0000 (13:53 +0200)
'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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/qemuxml2argvtest.c

index a3c91fd5de1208f8e1012ce570a6e22c48fe39e0..2b97eb80a42e9663cb86a2b6f0e427625846fbe6 100644 (file)
@@ -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) {