diff mbox

[7/9] tests: utils: Add PreFormat callback for CompareXML2XML helper

Message ID 3e8b2284bfd4bcc8349b0eea908808232283b785.1454011611.git.crobinso@redhat.com
State Superseded
Headers show

Commit Message

Cole Robinson Jan. 28, 2016, 8:30 p.m. UTC
This allows individual driver tests to hook in their own code before
the def is formatted and compared.

We will eventually use this in the qemuxml2xml
---
 tests/bhyvexml2xmltest.c   | 3 ++-
 tests/genericxml2xmltest.c | 3 ++-
 tests/lxcxml2xmltest.c     | 3 ++-
 tests/qemuxml2xmltest.c    | 6 ++++--
 tests/testutils.c          | 7 ++++++-
 tests/testutils.h          | 6 +++++-
 6 files changed, 21 insertions(+), 7 deletions(-)

-- 
2.5.0

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

Comments

Cole Robinson Feb. 9, 2016, 3:56 p.m. UTC | #1
On 02/09/2016 10:55 AM, Martin Kletzander wrote:
> On Thu, Jan 28, 2016 at 03:30:12PM -0500, Cole Robinson wrote:

>> This allows individual driver tests to hook in their own code before

>> the def is formatted and compared.

>>

>> We will eventually use this in the qemuxml2xml

>> ---

>> tests/bhyvexml2xmltest.c   | 3 ++-

>> tests/genericxml2xmltest.c | 3 ++-

>> tests/lxcxml2xmltest.c     | 3 ++-

>> tests/qemuxml2xmltest.c    | 6 ++++--

>> tests/testutils.c          | 7 ++++++-

>> tests/testutils.h          | 6 +++++-

>> 6 files changed, 21 insertions(+), 7 deletions(-)

>>

> 

> Visual ACK to 5-7/9, I can't apply them, but if the test work for you,

> then just push them so you don't need to resend them because of those

> last two patches again.  However I would like to see 8/9 applied in

> order to ACK it.  Unless someone else is will beat me to it.


I'm about to send a rebased v2, please give those a spin

Thanks,
Cole

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

Patch

diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index d860a41..2d34a00 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -32,7 +32,8 @@  testCompareXMLToXMLHelper(const void *data)
 
     ret = testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, xml_in,
                                      info->different ? xml_out : xml_in,
-                                     false);
+                                     false,
+                                     NULL, NULL);
 
  cleanup:
     VIR_FREE(xml_in);
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index 7f79896..aa3a570 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -39,7 +39,8 @@  testCompareXMLToXMLHelper(const void *data)
 
     ret = testCompareDomXML2XMLFiles(caps, xmlopt, xml_in,
                                      info->different ? xml_out : xml_in,
-                                     !info->inactive_only);
+                                     !info->inactive_only,
+                                     NULL, NULL);
  cleanup:
     VIR_FREE(xml_in);
     VIR_FREE(xml_out);
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index e460d0a..aafebb4 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -44,7 +44,8 @@  testCompareXMLToXMLHelper(const void *data)
 
     ret = testCompareDomXML2XMLFiles(caps, xmlopt, xml_in,
                                      info->different ? xml_out : xml_in,
-                                     !info->inactive_only);
+                                     !info->inactive_only,
+                                     NULL, NULL);
  cleanup:
     VIR_FREE(xml_in);
     VIR_FREE(xml_out);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 0134815..97838f3 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -42,7 +42,8 @@  testXML2XMLActive(const void *opaque)
     const struct testInfo *info = opaque;
 
     return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
-                                      info->inName, info->outActiveName, true);
+                                      info->inName, info->outActiveName, true,
+                                      NULL, NULL);
 }
 
 
@@ -52,7 +53,8 @@  testXML2XMLInactive(const void *opaque)
     const struct testInfo *info = opaque;
 
     return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, info->inName,
-                                      info->outInactiveName, false);
+                                      info->outInactiveName, false,
+                                      NULL, NULL);
 }
 
 
diff --git a/tests/testutils.c b/tests/testutils.c
index 10c26648..c282745 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -1097,7 +1097,9 @@  virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void)
 
 int
 testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt,
-                           const char *infile, const char *outfile, bool live)
+                           const char *infile, const char *outfile, bool live,
+                           testCompareDomXML2XMLPreFormatCallback cb,
+                           const void *opaque)
 {
     char *actual = NULL;
     int ret = -1;
@@ -1115,6 +1117,9 @@  testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt,
         goto fail;
     }
 
+    if (cb && cb(def, opaque) < 0)
+        goto fail;
+
     if (!(actual = virDomainDefFormat(def, format_flags)))
         goto fail;
 
diff --git a/tests/testutils.h b/tests/testutils.h
index b1d7397..df2b2a6 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -137,10 +137,14 @@  int virtTestMain(int argc,
 virCapsPtr virTestGenericCapsInit(void);
 virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void);
 
+typedef int (*testCompareDomXML2XMLPreFormatCallback)(virDomainDefPtr def,
+                                                      const void *opaque);
 int testCompareDomXML2XMLFiles(virCapsPtr caps,
                                virDomainXMLOptionPtr xmlopt,
                                const char *inxml,
                                const char *outfile,
-                               bool live);
+                               bool live,
+                               testCompareDomXML2XMLPreFormatCallback cb,
+                               const void *opaque);
 
 #endif /* __VIT_TEST_UTILS_H__ */