[PATCH] qemuxml2argvtest: Append newline to tested error messages

Peter Krempa posted 1 patch 3 years, 6 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/9453b9afb38ea4537598c2e8dfb8e73d94b90a2e.1600946371.git.pkrempa@redhat.com
tests/qemuxml2argvtest.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
[PATCH] qemuxml2argvtest: Append newline to tested error messages
Posted by Peter Krempa 3 years, 6 months ago
'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

Re: [PATCH] qemuxml2argvtest: Append newline to tested error messages
Posted by Ján Tomko 3 years, 6 months ago
On a Thursday in 2020, Peter Krempa wrote:
>'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(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano