提交 8e0fd243 编写于 作者: C Cole Robinson

tests: utils: Add PreFormat callback for CompareXML2XML helper

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
上级 d1a71023
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册