]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuagenttest: Add testing of agent suspend modes
authorPeter Krempa <pkrempa@redhat.com>
Mon, 29 Jul 2013 13:24:32 +0000 (15:24 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 31 Jul 2013 12:25:43 +0000 (14:25 +0200)
tests/qemuagenttest.c

index a3b8834d78c3830d10bf042add11c2c12d022a00..d0b450ef7f18d0962374d18ccc3bdce70cb02d81 100644 (file)
@@ -161,6 +161,52 @@ cleanup:
 }
 
 
+static int
+testQemuAgentSuspend(const void *data)
+{
+    virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
+    qemuMonitorTestPtr test = qemuMonitorTestNewAgent(xmlopt);
+    int ret = -1;
+    size_t i;
+
+    if (!test)
+        return -1;
+
+    if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
+        goto cleanup;
+
+    if (qemuMonitorTestAddItem(test, "guest-suspend-ram",
+                               "{ \"return\" : {} }") < 0)
+        goto cleanup;
+
+    if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
+        goto cleanup;
+
+    if (qemuMonitorTestAddItem(test, "guest-suspend-disk",
+                               "{ \"return\" : {} }") < 0)
+        goto cleanup;
+
+    if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
+        goto cleanup;
+
+    if (qemuMonitorTestAddItem(test, "guest-suspend-hybrid",
+                               "{ \"return\" : {} }") < 0)
+        goto cleanup;
+
+    /* try the commands - fail if ordering changes */
+    for (i = 0; i < VIR_NODE_SUSPEND_TARGET_LAST; i++) {
+        if (qemuAgentSuspend(qemuMonitorTestGetAgent(test), i) < 0)
+            goto cleanup;
+    }
+
+    ret = 0;
+
+cleanup:
+    qemuMonitorTestFree(test);
+    return ret;
+}
+
+
 static int
 mymain(void)
 {
@@ -185,6 +231,7 @@ mymain(void)
     DO_TEST(FSFreeze);
     DO_TEST(FSThaw);
     DO_TEST(FSTrim);
+    DO_TEST(Suspend);
 
     virObjectUnref(xmlopt);