testParseXMLDocFromFile: Validate that the replaced node is identical with parsed root

When replacing a definition node by contents of a file the root node in
the file must match the replaced node.

Enforce that by passing the original node name as the 'rootnode'
argument of virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-09-22 16:41:25 +02:00
parent b46667ac6f
commit ee3b96bcb0

View File

@ -851,7 +851,8 @@ testParseXMLDocFromFile(xmlNodePtr node,
g_autofree char *absFile = testBuildFilename(file, relFile);
xmlNodePtr newnode = NULL;
if (!(doc = virXMLParse(absFile, NULL, NULL, NULL, NULL, NULL, false)))
if (!(doc = virXMLParse(absFile, NULL, NULL, (const char *) node->name,
NULL, NULL, false)))
return NULL;
if (!(newnode = xmlCopyNode(xmlDocGetRootElement(doc), 1))) {