static int
testCompareXMLToXMLFiles(const char *inxml,
                         const char *outxml,
                         const char *uuid,
                         bool internal,
                         bool redefine)
{
    char *inXmlData = NULL;
    char *outXmlData = NULL;
    char *actual = NULL;
    int ret = -1;
    virDomainSnapshotDefPtr def = NULL;
    unsigned int flags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;

    if (internal)
        flags |= VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL;

    if (redefine)
        flags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;

    if (virtTestLoadFile(inxml, &inXmlData) < 0)
        goto cleanup;

    if (virtTestLoadFile(outxml, &outXmlData) < 0)
        goto cleanup;

    if (!(def = virDomainSnapshotDefParseString(inXmlData, driver.caps,
                                                driver.xmlopt,
                                                QEMU_EXPECTED_VIRT_TYPES,
                                                flags)))
        goto cleanup;

    if (!(actual = virDomainSnapshotDefFormat(uuid, def,
                                              VIR_DOMAIN_XML_SECURE,
                                              internal)))
        goto cleanup;

    if (!redefine) {
        if (!(actual = testFilterXML(actual)))
            goto cleanup;

        if (!(outXmlData = testFilterXML(outXmlData)))
            goto cleanup;
    }

    if (STRNEQ(outXmlData, actual)) {
        virtTestDifference(stderr, outXmlData, actual);
        goto cleanup;
    }

    ret = 0;

 cleanup:
    VIR_FREE(inXmlData);
    VIR_FREE(outXmlData);
    VIR_FREE(actual);
    virDomainSnapshotDefFree(def);
    return ret;
}
static int
testCompareXMLtoXMLFiles(const char *xml)
{
    char *xmlData = NULL;
    char *actual = NULL;
    char *pathResult = NULL;
    int ret = -1;
    virVBoxSnapshotConfMachinePtr machine = NULL;

    if (VIR_STRDUP(pathResult,
                   abs_builddir "/vboxsnapshotxmldata/testResult.vbox") < 0)
        return -1;

    if (virFileMakePath(abs_builddir "/vboxsnapshotxmldata") < 0)
        goto cleanup;

    if (virTestLoadFile(xml, &xmlData) < 0)
        goto cleanup;

    if (!(machine = virVBoxSnapshotConfLoadVboxFile(xml, (char*)"")))
        goto cleanup;

    if (virVBoxSnapshotConfSaveVboxFile(machine, pathResult) < 0)
        goto cleanup;

    if (virTestLoadFile(pathResult, &actual) < 0)
        goto cleanup;

    if (!(actual = testFilterXML(actual)))
        goto cleanup;
    if (!(xmlData = testFilterXML(xmlData)))
        goto cleanup;

    if (STRNEQ(actual, xmlData)) {
        virTestDifference(stderr, xmlData, actual);
        goto cleanup;
    }

    ret = 0;

 cleanup:
    unlink(pathResult);
    rmdir(abs_builddir "/vboxsnapshotxmldata");
    VIR_FREE(xmlData);
    VIR_FREE(actual);
    virVBoxSnapshotConfMachineFree(machine);
    VIR_FREE(pathResult);

    return ret;
}