[PATCH v2 2/3] testQemuConfXMLCommon: Strip 'abs_srcdir' paths from '.err' files in qemuxmlconftest

Peter Krempa posted 3 patches 3 months, 2 weeks ago
[PATCH v2 2/3] testQemuConfXMLCommon: Strip 'abs_srcdir' paths from '.err' files in qemuxmlconftest
Posted by Peter Krempa 3 months, 2 weeks ago
Upcoming patch will result in having the build directory path in some of
the output files. Replace it by a constant 'ABS_SRCDIR' to avoild
breaking tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/qemuxmlconftest.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 7e47c78150..5fe69db15f 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -687,8 +687,12 @@ testQemuConfXMLCommon(testQemuInfo *info,
         }

         if (info->flags & FLAG_EXPECT_PARSE_ERROR) {
-            g_autofree char *tmperr = g_strdup_printf("%s\n", NULLSTR(err->message));
-            if (virTestCompareToFile(tmperr, info->errfile) >= 0) {
+            g_autoptr(GString) errstr = g_string_new(NULLSTR(err->message));
+
+            g_string_replace(errstr, abs_srcdir, "ABS_SRCDIR", 0);
+            g_string_append_c(errstr, '\n');
+
+            if (virTestCompareToFile(errstr->str, info->errfile) >= 0) {
                 info->prep_skip = true;
             }
         }
-- 
2.45.2