[PATCH 06/10] tests: skip regeneration for problematic test

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

 



While parsing qemu command line, we don't support parsing everything and
some staff cannot be parsed out of the command line.  Skip regenerating
expected output for those tests.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 tests/qemuargv2xmltest.c | 13 ++++++++++++-
 tests/testutils.c        | 36 ++++++++++++++++++++++++++++++++++++
 tests/testutils.h        |  2 ++
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index fc18b55..0fb382b 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -35,6 +35,12 @@ static int blankProblemElements(char *data)
     return 0;
 }
 
+static bool
+skipProblemTest(char *data)
+{
+    return virtTestFindLineRegex("<secret.*usage.*>", data);
+}
+
 typedef enum {
     FLAG_EXPECT_WARNING     = 1 << 0,
 } virQemuXML2ArgvTestFlags;
@@ -96,7 +102,12 @@ static int testCompareXMLToArgvFiles(const char *xml,
         goto fail;
 
     if (STRNEQ(expectxml, actualxml)) {
-        virtTestDifferenceFull(stderr, expectxml, xml, actualxml, NULL);
+        if (skipProblemTest(expectxml) || skipProblemTest(actualxml)) {
+            virtTestDifferenceFullNoRegenerate(stderr, expectxml, xml,
+                                               actualxml, NULL);
+        } else {
+            virtTestDifferenceFull(stderr, expectxml, xml, actualxml, NULL);
+        }
         goto fail;
     }
 
diff --git a/tests/testutils.c b/tests/testutils.c
index 6645d61..3477ff2 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -910,6 +910,42 @@ int virtTestMain(int argc,
 }
 
 
+bool
+virtTestFindLineRegex(const char *pattern,
+                      char *str)
+{
+    regex_t reg;
+    char *lineStart = str;
+    char *lineEnd = strchr(str, '\n');
+    bool found = false;
+
+    if (regcomp(&reg, pattern, REG_EXTENDED | REG_NOSUB) != 0)
+        return false;
+
+    while (lineStart) {
+        int ret;
+
+        ret = regexec(&reg, lineStart, 0, NULL, 0);
+        /* pattern found */
+        if (ret == 0) {
+            lineStart = NULL;
+            found = true;
+        } else {
+            if (lineEnd) {
+                lineStart = lineEnd + 1;
+                lineEnd = strchr(lineStart, '\n');
+            } else {
+                lineStart = NULL;
+            }
+        }
+    }
+
+    regfree(&reg);
+
+    return found;
+}
+
+
 int virtTestClearLineRegex(const char *pattern,
                            char *str)
 {
diff --git a/tests/testutils.h b/tests/testutils.h
index 3bd9004..d4913ab 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -54,6 +54,8 @@ int virtTestRun(const char *title,
 int virtTestLoadFile(const char *file, char **buf);
 int virtTestCaptureProgramOutput(const char *const argv[], char **buf, int maxlen);
 
+bool virtTestFindLineRegex(const char *pattern,
+                           char *string);
 int virtTestClearLineRegex(const char *pattern,
                            char *string);
 
-- 
2.7.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]