提交 af75de30 编写于 作者: P Peter Krempa

domainsnapshotxml2xmltest: Clean up labels and use bool instead of int

The 'internal' variable holds only two states; convert it to a boolean
and the 'fail' label should be called 'cleanup'. This patch also fixes a
minor memory leak of driver capabilities in case the XML config object
can't be allocated.
上级 62774afb
......@@ -23,7 +23,7 @@
static virQEMUDriver driver;
static int
testCompareXMLToXMLFiles(const char *inxml, const char *uuid, int internal)
testCompareXMLToXMLFiles(const char *inxml, const char *uuid, bool internal)
{
char *inXmlData = NULL;
char *actual = NULL;
......@@ -33,7 +33,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *uuid, int internal)
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS);
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
goto cleanup;
if (internal)
flags |= VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL;
......@@ -41,21 +41,22 @@ testCompareXMLToXMLFiles(const char *inxml, const char *uuid, int internal)
driver.xmlopt,
QEMU_EXPECTED_VIRT_TYPES,
flags)))
goto fail;
goto cleanup;
if (!(actual = virDomainSnapshotDefFormat(uuid, def,
VIR_DOMAIN_XML_SECURE,
internal)))
goto fail;
goto cleanup;
if (STRNEQ(inXmlData, actual)) {
virtTestDifference(stderr, inXmlData, actual);
goto fail;
goto cleanup;
}
ret = 0;
fail:
cleanup:
VIR_FREE(inXmlData);
VIR_FREE(actual);
virDomainSnapshotDefFree(def);
......@@ -65,9 +66,10 @@ testCompareXMLToXMLFiles(const char *inxml, const char *uuid, int internal)
struct testInfo {
const char *name;
const char *uuid;
int internal;
bool internal;
};
static int
testCompareXMLToXMLHelper(const void *data)
{
......@@ -95,8 +97,10 @@ mymain(void)
if ((driver.caps = testQemuCapsInit()) == NULL)
return EXIT_FAILURE;
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver)))
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) {
virObjectUnref(driver.caps);
return EXIT_FAILURE;
}
# define DO_TEST(name, uuid, internal) \
do { \
......@@ -111,14 +115,14 @@ mymain(void)
* values for these envvars */
setenv("PATH", "/bin", 1);
DO_TEST("all_parameters", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", 1);
DO_TEST("disk_snapshot", "c7a5fdbd-edaf-9455-926a-d65c16db1809", 1);
DO_TEST("full_domain", "c7a5fdbd-edaf-9455-926a-d65c16db1809", 1);
DO_TEST("noparent_nodescription_noactive", NULL, 0);
DO_TEST("noparent_nodescription", NULL, 1);
DO_TEST("noparent", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", 0);
DO_TEST("metadata", "c7a5fdbd-edaf-9455-926a-d65c16db1809", 0);
DO_TEST("external_vm", "c7a5fdbd-edaf-9455-926a-d65c16db1809", 0);
DO_TEST("all_parameters", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", true);
DO_TEST("disk_snapshot", "c7a5fdbd-edaf-9455-926a-d65c16db1809", true);
DO_TEST("full_domain", "c7a5fdbd-edaf-9455-926a-d65c16db1809", true);
DO_TEST("noparent_nodescription_noactive", NULL, false);
DO_TEST("noparent_nodescription", NULL, true);
DO_TEST("noparent", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", false);
DO_TEST("metadata", "c7a5fdbd-edaf-9455-926a-d65c16db1809", false);
DO_TEST("external_vm", "c7a5fdbd-edaf-9455-926a-d65c16db1809", false);
virObjectUnref(driver.caps);
virObjectUnref(driver.xmlopt);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册