Re: [PATCH 3/4] tests: xml2xml: Refactor the qemu xml 2 xml test

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

 



On Tue, Mar 24, 2015 at 03:03:22PM +0100, Peter Krempa wrote:
To allow adding more tests, refactor the XML-2-XML test so that the
files are not reloaded always and clarify the control flow.

Result of this changes is that the active and inactive portions of the
XML are tested in separate steps rather than one test step.
---
tests/qemuxml2xmltest.c | 214 +++++++++++++++++++++++++++++++-----------------
1 file changed, 140 insertions(+), 74 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 0f16d5e..627edca 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -22,11 +22,30 @@

static virQEMUDriver driver;

+enum {
+    WHEN_INACTIVE = 1,
+    WHEN_ACTIVE = 2,
+    WHEN_EITHER = 3,

Pre-existing, but reading the code, I guess this "either" means
"both", doesn't it?

@@ -148,12 +201,25 @@ mymain(void)
    if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver)))
        return EXIT_FAILURE;

-# define DO_TEST_FULL(name, is_different, when)                         \
-    do {                                                                \
-        const struct testInfo info = {name, is_different, when};        \
-        if (virtTestRun("QEMU XML-2-XML " name,                         \
-                        testCompareXMLToXMLHelper, &info) < 0)          \
-            ret = -1;                                                   \
+# define DO_TEST_FULL(name, is_different, when)                                \
+    do {                                                                       \
+        if (testInfoSet(&info, name, is_different, when) < 0) {                \
+            fprintf(stderr, "Failed to generate test data for '%s'", name);    \
+            return -1;                                                         \
+        }                                                                      \
+                                                                               \
+        if (info.outInactiveName) {                                            \
+            if (virtTestRun("QEMU XML-2-XML-inactive " name,                   \
+                            testXML2XMLInactive, &info) < 0)                   \
+                ret = -1;                                                      \
+        }                                                                      \
+                                                                               \
+        if (info.outActiveName) {                                              \
+            if (virtTestRun("QEMU XML-2-XML-active " name,                     \
+                            testXML2XMLActive, &info) < 0)                     \
+                ret = -1;                                                      \
+        }                                                                      \
+         testInfoFree(&info);                                                  \

s/ // (indentation's off)

Attachment: pgpAUCc09b2FR.pgp
Description: PGP signature

--
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]