mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
tests: lxcconf2xml: Drop XML blanking
Hardcode a UUID like we did for qemuargv2xml, so we can use standard comparison helpers, which gives us VIR_TEST_REGENERATE_OUTPUT support
This commit is contained in:
parent
2fc011fe04
commit
1064fb3314
@ -13,22 +13,21 @@
|
|||||||
static virCapsPtr caps;
|
static virCapsPtr caps;
|
||||||
static virDomainXMLOptionPtr xmlopt;
|
static virDomainXMLOptionPtr xmlopt;
|
||||||
|
|
||||||
static int
|
static int testSanitizeDef(virDomainDefPtr vmdef)
|
||||||
blankProblemElements(char *data)
|
|
||||||
{
|
{
|
||||||
if (virtTestClearLineRegex("<uuid>([[:alnum:]]|-)+</uuid>", data) < 0)
|
/* Remove UUID randomness */
|
||||||
|
if (virUUIDParse("c7a5fdbd-edaf-9455-926a-d65c16db1809", vmdef->uuid) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testCompareXMLToConfigFiles(const char *xml,
|
testCompareXMLToConfigFiles(const char *xmlfile,
|
||||||
const char *configfile,
|
const char *configfile,
|
||||||
bool expectError)
|
bool expectError)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *config = NULL;
|
char *config = NULL;
|
||||||
char *expectxml = NULL;
|
|
||||||
char *actualxml = NULL;
|
char *actualxml = NULL;
|
||||||
virDomainDefPtr vmdef = NULL;
|
virDomainDefPtr vmdef = NULL;
|
||||||
|
|
||||||
@ -40,26 +39,19 @@ testCompareXMLToConfigFiles(const char *xml,
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (vmdef) {
|
if (vmdef) {
|
||||||
|
if (testSanitizeDef(vmdef) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
if (!(actualxml = virDomainDefFormat(vmdef, caps, 0)))
|
if (!(actualxml = virDomainDefFormat(vmdef, caps, 0)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (virtTestLoadFile(xml, &expectxml) < 0)
|
if (virtTestCompareToFile(actualxml, xmlfile) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (blankProblemElements(expectxml) < 0 ||
|
|
||||||
blankProblemElements(actualxml) < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (STRNEQ(expectxml, actualxml)) {
|
|
||||||
virtTestDifferenceFull(stderr, expectxml, xml, actualxml, NULL);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
VIR_FREE(expectxml);
|
|
||||||
VIR_FREE(actualxml);
|
VIR_FREE(actualxml);
|
||||||
VIR_FREE(config);
|
VIR_FREE(config);
|
||||||
virDomainDefFree(vmdef);
|
virDomainDefFree(vmdef);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user