[PATCH v1 2/3] qemumonitorjsontest: add tests for cpu comparison

Collin Walling walling at linux.ibm.com
Thu Feb 20 22:01:47 UTC 2020


Signed-off-by: Collin Walling <walling at linux.ibm.com>
---
 tests/qemumonitorjsontest.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index cd7fa1f..5568af5 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2981,6 +2981,48 @@ testQemuMonitorJSONTransaction(const void *opaque)
 
 
 static int
+testQemuMonitorJSONqemuMonitorJSONGetCPUModelComparison(const void *opaque)
+{
+    const testGenericData *data = opaque;
+    g_autoptr(qemuMonitorTest) test = NULL;
+    virCPUDefPtr cpu_a;
+    virCPUDefPtr cpu_b = NULL;
+    g_autofree char *result = NULL;
+    int ret = -1;
+
+    if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
+        return -1;
+
+    if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison",
+                               "{\"return\":{\"result\":\"test\"}}") < 0)
+        return -1;
+
+    if (VIR_ALLOC(cpu_a) < 0 || VIR_ALLOC(cpu_b) < 0)
+        goto cleanup;
+
+    cpu_a->model = g_strdup("cpu_a");
+    cpu_b->model = g_strdup("cpu_b");
+
+    if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(test),
+                                             cpu_a, cpu_b, &result) < 0)
+        goto cleanup;
+
+    if (!result || STRNEQ(result, "test")) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       "Compare result not set");
+        goto cleanup;
+    }
+
+    ret = 0;
+
+ cleanup:
+    virCPUDefFree(cpu_a);
+    virCPUDefFree(cpu_b);
+    return ret;
+}
+
+
+static int
 mymain(void)
 {
     int ret = 0;
@@ -3257,6 +3299,14 @@ mymain(void)
 
 #undef DO_TEST_QUERY_JOBS
 
+    if (!(qapiData.schema = testQEMUSchemaLoad("s390x"))) {
+        VIR_TEST_VERBOSE("failed to load qapi schema for s390x");
+        ret = -1;
+        goto cleanup;
+    }
+
+    DO_TEST(qemuMonitorJSONGetCPUModelComparison);
+
  cleanup:
     VIR_FREE(metaschemastr);
     virJSONValueFree(metaschema);
-- 
2.7.4





More information about the libvir-list mailing list