Message ID | c13711ec2c045b00342236fe4497e43d22c185ea.1455032128.git.crobinso@redhat.com |
---|---|
State | Accepted |
Commit | 8e0fd243f8801efcae071b460e65b8241879e0c9 |
Headers | show |
On 02/09/2016 03:13 PM, Laine Stump wrote: > On 02/09/2016 10:59 AM, 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 >> --- > > Oops. I ACKed 5/6 before this one (after looking ahead to see how this would > be used). > > This looks okay, although I'm wondering why you call just the PCI address > assignment rather than a full postparse callback. Other things can happen in > there, e.g. auto-adding controllers. We may as well test the whole thing. > PostParse is automatically called by DomainDefParse (I said DomainDefFormat in a previously mail, that's incorrect), so we don't need to call it explicitly. The qemu specific controller additions are triggered via that. The generic domain_conf AddImplicitControllers though isn't tested here, but I have previously posted patches that move that call into the generic PostParse function, so it will be tested after that. I'll be reposting those as part of another series after this is merged. The other series also puts AssignAddresses into qemu's PostParse callback, so the immediate need for this patch will be gone. But there are other bits like AssignAliases we should be testing here as well > Still this is a good start at that, so ACK. > > Thanks, pushed now - Cole -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
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 d4e94f0..e3b61c0 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 506eee7..c4f1616 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, caps, 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__ */