]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuagenttest: Test arbitrary command passthrough
authorPeter Krempa <pkrempa@redhat.com>
Thu, 1 Aug 2013 09:38:21 +0000 (11:38 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Aug 2013 12:53:31 +0000 (14:53 +0200)
Exercise the arbitrary command passthrough API.

tests/qemuagenttest.c

index 7d6773c3e88ddca6747139808a5d72aff3dddd91..be9995f34f605c829a71e17f655f4312a1f256dd 100644 (file)
@@ -474,6 +474,50 @@ cleanup:
 }
 
 
+static const char testQemuAgentArbitraryCommandResponse[] =
+    "{\"return\":\"bla\"}";
+
+static int
+testQemuAgentArbitraryCommand(const void *data)
+{
+    virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
+    qemuMonitorTestPtr test = qemuMonitorTestNewAgent(xmlopt);
+    int ret = -1;
+    char *reply = NULL;
+
+    if (!test)
+        return -1;
+
+    if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
+        goto cleanup;
+
+    if (qemuMonitorTestAddItem(test, "ble",
+                               testQemuAgentArbitraryCommandResponse) < 0)
+        goto cleanup;
+
+    if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test),
+                                  "{\"execute\":\"ble\"}",
+                                  &reply,
+                                  VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+        goto cleanup;
+
+    if (STRNEQ(reply, testQemuAgentArbitraryCommandResponse)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "invalid processing of guest agent reply: "
+                       "got '%s' expected '%s'",
+                       reply, testQemuAgentArbitraryCommandResponse);
+        goto cleanup;
+    }
+
+    ret = 0;
+
+cleanup:
+    VIR_FREE(reply);
+    qemuMonitorTestFree(test);
+    return ret;
+}
+
+
 static int
 mymain(void)
 {
@@ -501,6 +545,7 @@ mymain(void)
     DO_TEST(Suspend);
     DO_TEST(Shutdown);
     DO_TEST(CPU);
+    DO_TEST(ArbitraryCommand);
 
     virObjectUnref(xmlopt);