]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemumonitorjsontest: add tests for cpu comparison
authorCollin Walling <walling@linux.ibm.com>
Thu, 20 Feb 2020 22:01:47 +0000 (17:01 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 21 Feb 2020 09:50:21 +0000 (10:50 +0100)
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemumonitorjsontest.c

index cd7fa1f41d31f174824bdcec6e6ca764d3eae3f7..5568af5dd27c186ea682342033c84cd1a9dd3acb 100644 (file)
@@ -2980,6 +2980,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)
 {
@@ -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);