From: Michal Privoznik Date: Wed, 17 Dec 2025 08:46:59 +0000 (+0100) Subject: networkxml2xmltest: Introduce testRun() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c24157056f3091d4d387abf765200f769572c607;p=thirdparty%2Flibvirt.git networkxml2xmltest: Introduce testRun() 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 Reviewed-by: Ján Tomko --- diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index 325a43c385..552364818d 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -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) \