The 'internal' variable holds only two states; convert it to a boolean
and the 'fail' label should be called 'cleanup'.
---
tests/domainsnapshotxml2xmltest.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index 9225119..c787f73 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -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);
--
1.8.4.3