[libvirt PATCH 1/3] tests: Allow cpuTestLoadXML to fail for the guest if we expect it the test to fail

Tim Wiederhake twiederh at redhat.com
Wed Sep 16 13:33:54 UTC 2020


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 tests/cputest.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tests/cputest.c b/tests/cputest.c
index 83d63bf495..195a215b84 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -201,13 +201,18 @@ cpuTestCompare(const void *arg)
     int ret = -1;
     virCPUDefPtr host = NULL;
     virCPUDefPtr cpu = NULL;
-    virCPUCompareResult result;
+    virCPUCompareResult result = VIR_CPU_COMPARE_ERROR;
 
-    if (!(host = cpuTestLoadXML(data->arch, data->host)) ||
-        !(cpu = cpuTestLoadXML(data->arch, data->name)))
+    if (!(host = cpuTestLoadXML(data->arch, data->host)))
         goto cleanup;
 
-    result = virCPUCompare(host->arch, host, cpu, false);
+    if (!(cpu = cpuTestLoadXML(data->arch, data->name))) {
+        if (data->result != VIR_CPU_COMPARE_ERROR)
+            goto cleanup;
+    } else {
+        result = virCPUCompare(host->arch, host, cpu, false);
+    }
+
     if (data->result == VIR_CPU_COMPARE_ERROR)
         virResetLastError();
 
-- 
2.26.2




More information about the libvir-list mailing list