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(a)redhat.com>
---
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(®, pattern, REG_EXTENDED | REG_NOSUB) != 0)
+ return false;
+
+ while (lineStart) {
+ int ret;
+
+ ret = regexec(®, 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(®);
+
+ 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.6.3