]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: utils: Add PreFormat callback for CompareXML2XML helper
authorCole Robinson <crobinso@redhat.com>
Wed, 27 Jan 2016 20:55:01 +0000 (15:55 -0500)
committerCole Robinson <crobinso@redhat.com>
Tue, 9 Feb 2016 21:09:01 +0000 (16:09 -0500)
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
tests/genericxml2xmltest.c
tests/lxcxml2xmltest.c
tests/qemuxml2xmltest.c
tests/testutils.c
tests/testutils.h

index d860a41dd31f131efcc4d28c5ba44b37cb15b65f..2d34a00fec9aa1f46e4dd0502ab098faa56c6aca 100644 (file)
@@ -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);
index 7f7989686fd5db371de827fdea374341ad0889a4..aa3a5708544a29c92dec9d0e7179a36080a1ac11 100644 (file)
@@ -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);
index e460d0af21d238e137a13df4b376e64e15297250..aafebb4da85e01b836668f37c93609925e4bd633 100644 (file)
@@ -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);
index d4e94f0cfe2c8f37c62308feec8ea756c7bd8f7d..e3b61c0dffdfda06cd55afeb310b5ee24122fc83 100644 (file)
@@ -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);
 }
 
 
index 506eee7743a511ee90c8a3444caad1993b921ad6..c4f16165ac3ea3b99c3fcab9aaf864b50271f3e7 100644 (file)
@@ -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, caps, format_flags)))
         goto fail;
 
index b1d7397c8aac01352ebcfab2aa6f5c56649c2849..df2b2a6667641525858e0a1203b255c32041cf11 100644 (file)
@@ -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__ */