[PATCH v2 23/23] qemuxml2xmltesttest: Avoid conditions in test macro

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

 



Pass a pointer to the 'ret' variable to the test executor itself and
update it there to improve compile times of the test.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/qemuxml2xmltest.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index f6a38d7716..0413a130c3 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -50,13 +50,16 @@ testXML2XMLActive(const void *opaque)
 {
     const struct testQemuInfo *info = opaque;

-    if (testXML2XMLCommon(info) < 0)
+    if (testXML2XMLCommon(info) < 0 ||
+        testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
+                                   info->infile, info->outfile, true,
+                                   info->parseFlags,
+                                   TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS) < 0) {
+        *info->conf->retptr = -1;
         return -1;
+    }

-    return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
-                                      info->infile, info->outfile, true,
-                                      info->parseFlags,
-                                      TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS);
+    return 0;
 }


@@ -65,13 +68,16 @@ testXML2XMLInactive(const void *opaque)
 {
     const struct testQemuInfo *info = opaque;

-    if (testXML2XMLCommon(info) < 0)
+    if (testXML2XMLCommon(info) < 0 ||
+        testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
+                                   info->infile, info->outfile, false,
+                                   info->parseFlags,
+                                   TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS) < 0) {
+        *info->conf->retptr = -1;
         return -1;
+    }

-    return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
-                                      info->infile, info->outfile, false,
-                                      info->parseFlags,
-                                      TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS);
+    return 0;
 }


@@ -113,7 +119,7 @@ mymain(void)
     struct testQemuConf testConf = { .capslatest = capslatest,
                                      .capscache = capscache,
                                      .qapiSchemaCache = NULL,
-                                     .retptr = NULL };
+                                     .retptr = &ret };

     if (!capslatest)
         return EXIT_FAILURE;
@@ -162,16 +168,12 @@ mymain(void)
  \
         if (when & WHEN_INACTIVE) { \
             testInfoSetPaths(&info, suffix, WHEN_INACTIVE); \
-            if (virTestRun("QEMU XML-2-XML-inactive " _name, \
-                            testXML2XMLInactive, &info) < 0) \
-                ret = -1; \
+            virTestRun("QEMU XML-2-XML-inactive " _name, testXML2XMLInactive, &info); \
         } \
  \
         if (when & WHEN_ACTIVE) { \
             testInfoSetPaths(&info, suffix, WHEN_ACTIVE); \
-            if (virTestRun("QEMU XML-2-XML-active " _name, \
-                            testXML2XMLActive, &info) < 0) \
-                ret = -1; \
+            virTestRun("QEMU XML-2-XML-active " _name, testXML2XMLActive, &info); \
         } \
         testQemuInfoClear(&info); \
     } while (0)
-- 
2.31.1




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

  Powered by Linux