mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
tests: Share domain XML2XML compare helper
This creates a shared function in testutils.c that consolidates all the slightly different implementations.
This commit is contained in:
@@ -1072,6 +1072,40 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt,
|
||||
const char *infile, const char *outfile, bool live)
|
||||
{
|
||||
char *actual = NULL;
|
||||
int ret = -1;
|
||||
virDomainDefPtr def = NULL;
|
||||
unsigned int parse_flags = live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
|
||||
if (!live)
|
||||
format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
|
||||
|
||||
if (!(def = virDomainDefParseFile(infile, caps, xmlopt, parse_flags)))
|
||||
goto fail;
|
||||
|
||||
if (!virDomainDefCheckABIStability(def, def)) {
|
||||
VIR_TEST_DEBUG("ABI stability check failed on %s", infile);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(actual = virDomainDefFormat(def, format_flags)))
|
||||
goto fail;
|
||||
|
||||
if (virtTestCompareToFile(actual, outfile) < 0)
|
||||
goto fail;
|
||||
|
||||
ret = 0;
|
||||
fail:
|
||||
VIR_FREE(actual);
|
||||
virDomainDefFree(def);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int virtTestCounter;
|
||||
static char virtTestCounterStr[128];
|
||||
static char *virtTestCounterPrefixEndOffset;
|
||||
|
||||
Reference in New Issue
Block a user