]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemumonitorjsontest: Test qemuMonitorJSONGetTargetArch
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 2 Oct 2013 16:55:42 +0000 (18:55 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Oct 2013 09:33:07 +0000 (11:33 +0200)
tests/qemumonitorjsontest.c

index 77e21147df0a0807bb41f4ffba05b7ffa99e7e1d..1977bd999ee2f83a273133fcf85bbc2e60669476 100644 (file)
@@ -1660,6 +1660,43 @@ cleanup:
     return ret;
 }
 
+static int
+testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *data)
+{
+    virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
+    qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
+    int ret = -1;
+    char *arch;
+
+    if (!test)
+        return -1;
+
+    if (qemuMonitorTestAddItem(test, "query-target",
+                               "{"
+                               "    \"return\": {"
+                               "        \"arch\": \"x86_64\""
+                               "    },"
+                               "    \"id\": \"libvirt-21\""
+                               "}") < 0)
+        goto cleanup;
+
+    if (!(arch = qemuMonitorJSONGetTargetArch(qemuMonitorTestGetMonitor(test))))
+        goto cleanup;
+
+    if (STRNEQ(arch, "x86_64")) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "Unexpected architecture %s, expecting x86_64",
+                       arch);
+        goto cleanup;
+    }
+
+    ret = 0;
+cleanup:
+    VIR_FREE(arch);
+    qemuMonitorTestFree(test);
+    return ret;
+}
+
 static int
 mymain(void)
 {
@@ -1717,6 +1754,7 @@ mymain(void)
     DO_TEST(qemuMonitorJSONGetSpiceMigrationStatus);
     DO_TEST(qemuMonitorJSONGetPtyPaths);
     DO_TEST(qemuMonitorJSONSetBlockIoThrottle);
+    DO_TEST(qemuMonitorJSONGetTargetArch);
 
     virObjectUnref(xmlopt);