[PATCH v2 22/23] qemuxml2argvtest: Avoid conditions in test macro

Peter Krempa pkrempa at redhat.com
Tue Aug 17 16:25:23 UTC 2021


Pass a pointer to the 'ret' variable to the test executor itself and
update it there to improve compile times of the test.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tests/qemustatusxml2xmltest.c |  3 ++-
 tests/qemuxml2argvtest.c      | 10 ++++++----
 tests/qemuxml2xmltest.c       |  3 ++-
 tests/testutilsqemu.h         |  1 +
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/tests/qemustatusxml2xmltest.c b/tests/qemustatusxml2xmltest.c
index d58f4b69da..f6bde507a1 100644
--- a/tests/qemustatusxml2xmltest.c
+++ b/tests/qemustatusxml2xmltest.c
@@ -83,7 +83,8 @@ mymain(void)
     g_autoptr(virConnect) conn = NULL;
     struct testQemuConf testConf = { .capslatest = capslatest,
                                      .capscache = capscache,
-                                     .qapiSchemaCache = NULL };
+                                     .qapiSchemaCache = NULL,
+                                     .retptr = NULL };

     if (!capslatest)
         return EXIT_FAILURE;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 34b92c4a35..a88eb1cb90 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -826,6 +826,9 @@ testCompareXMLToArgv(const void *data)
     if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
         qemuTestSetHostArch(&driver, VIR_ARCH_NONE);

+    if (ret < 0)
+        *info->conf->retptr = ret;
+
     return ret;
 }

@@ -853,7 +856,8 @@ mymain(void)
     g_autoptr(GHashTable) capscache = virHashNew(virObjectFreeHashData);
     struct testQemuConf testConf = { .capslatest = capslatest,
                                      .capscache = capscache,
-                                     .qapiSchemaCache = qapiSchemaCache };
+                                     .qapiSchemaCache = qapiSchemaCache,
+                                     .retptr = &ret };

     if (!capslatest)
         return EXIT_FAILURE;
@@ -948,9 +952,7 @@ mymain(void)
         }; \
         testQemuInfoSetArgs(&info, &testConf, __VA_ARGS__); \
         testInfoSetPaths(&info, _suffix); \
-        if (virTestRun("QEMU XML-2-ARGV " _name _suffix, \
-                       testCompareXMLToArgv, &info) < 0) \
-            ret = -1; \
+        virTestRun("QEMU XML-2-ARGV " _name _suffix, testCompareXMLToArgv, &info); \
         testQemuInfoClear(&info); \
     } while (0)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 92fab7d169..f6a38d7716 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -112,7 +112,8 @@ mymain(void)
     g_autoptr(virConnect) conn = NULL;
     struct testQemuConf testConf = { .capslatest = capslatest,
                                      .capscache = capscache,
-                                     .qapiSchemaCache = NULL };
+                                     .qapiSchemaCache = NULL,
+                                     .retptr = NULL };

     if (!capslatest)
         return EXIT_FAILURE;
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index d59fa53239..64562cbd1c 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -58,6 +58,7 @@ struct testQemuConf {
     GHashTable *capscache;
     GHashTable *capslatest;
     GHashTable *qapiSchemaCache;
+    int *retptr;
 };

 struct testQemuArgs {
-- 
2.31.1




More information about the libvir-list mailing list