[PATCH 13/43] testParseXMLDocFromFile: Validate that the replaced node is identical with parsed root

Peter Krempa pkrempa at redhat.com
Tue Oct 4 08:32:47 UTC 2022


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 at redhat.com>
---
 src/test/test_driver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 26c6c95c28..5eae22f591 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -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))) {
-- 
2.37.3



More information about the libvir-list mailing list