From: Michal Privoznik <mprivozn@redhat.com>
Soon, the testRun() will run more than one test case. The input
network XML, however, stays the same. Instead of parsing it and
throwing away immediately, store it temporarily.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
tests/networkxml2xmltest.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index e90b38088a..4a4cf329e4 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -27,6 +27,7 @@ struct _testInfo {
unsigned int flags;
testCompareNetXML2XMLResult expectResult;
virNetworkXMLOption *xmlopt; /* borrowed, immutable */
+ virNetworkDef *def;
char *inxml;
char *outxml;
};
@@ -40,6 +41,7 @@ void testInfoFree(testInfo *info)
if (!info)
return;
+ virNetworkDefFree(info->def);
VIR_FREE(info->inxml);
VIR_FREE(info->outxml);
VIR_FREE(info);
@@ -52,23 +54,23 @@ testCompareXMLToXMLFiles(const void *data)
g_autofree char *actual = NULL;
int ret;
testCompareNetXML2XMLResult result = TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS;
- g_autoptr(virNetworkDef) dev = NULL;
+ g_autoptr(virNetworkDef) def = NULL;
- if (!(dev = virNetworkDefParse(NULL, info->inxml, info->xmlopt, false))) {
+ if (!(def = virNetworkDefParse(NULL, info->inxml, info->xmlopt, false))) {
result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE;
goto cleanup;
}
if (info->expectResult == TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE)
goto cleanup;
- if (networkValidateTests(dev) < 0) {
+ if (networkValidateTests(def) < 0) {
result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_VALIDATE;
goto cleanup;
}
if (info->expectResult == TEST_COMPARE_NET_XML2XML_RESULT_FAIL_VALIDATE)
goto cleanup;
- if (!(actual = virNetworkDefFormat(dev, info->xmlopt, info->flags))) {
+ if (!(actual = virNetworkDefFormat(def, info->xmlopt, info->flags))) {
result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_FORMAT;
goto cleanup;
}
@@ -88,6 +90,8 @@ testCompareXMLToXMLFiles(const void *data)
if (info->expectResult != TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS) {
VIR_TEST_DEBUG("Got expected failure code=%d msg=%s",
result, virGetLastErrorMessage());
+ } else {
+ info->def = g_steal_pointer(&def);
}
} else {
ret = -1;
--
2.52.0