]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
networkxml2xmltest: Introduce testRun()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 17 Dec 2025 08:46:59 +0000 (09:46 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 29 Jan 2026 12:39:02 +0000 (13:39 +0100)
This is a beginning of something bigger. The idea is that one
DO_TEST_FULL() macro (and its friends) will run multiple test
cases (just like qemuxmlconftest does). But in order to do that
in a readable fashion, the macro should merely just expand to a
function call. The function will then call virTestRunLog(),
multiple times possibly.

This is the first step in that direction.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/networkxml2xmltest.c

index 325a43c385956407e556b263519722d8c33e798c..552364818d52ef4c20fc82f161840996a4df3854 100644 (file)
@@ -103,6 +103,19 @@ testCompareXMLToXMLHelper(const void *data)
     return result;
 }
 
+static void
+testRun(const char *name,
+        int *ret,
+        virNetworkXMLOption *xmlopt,
+        testCompareNetXML2XMLResult expectResult,
+        unsigned int flags)
+{
+    g_autofree char *name_xml2xml = g_strdup_printf("Network XML-2-XML %s", name);
+    struct testInfo info = { .name = name, .flags = flags, .expectResult = expectResult, .xmlopt = xmlopt };
+
+    virTestRunLog(ret, name_xml2xml, testCompareXMLToXMLHelper, &info);
+}
+
 static int
 mymain(void)
 {
@@ -113,12 +126,7 @@ mymain(void)
         return -1;
 
 #define DO_TEST_FULL(name, flags, expectResult) \
-    do { \
-        const struct testInfo info = {name, flags, expectResult, xmlopt}; \
-        if (virTestRun("Network XML-2-XML " name, \
-                       testCompareXMLToXMLHelper, &info) < 0) \
-            ret = -1; \
-    } while (0)
+    testRun(name, &ret, xmlopt, expectResult, flags)
 #define DO_TEST(name) \
     DO_TEST_FULL(name, 0, TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS)
 #define DO_TEST_FLAGS(name, flags) \