]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
qemuagenttest: Check invalid response in shutdown test
authorPeter Krempa <pkrempa@redhat.com>
Thu, 1 Aug 2013 14:28:29 +0000 (16:28 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 2 Aug 2013 10:28:58 +0000 (12:28 +0200)
The shutdown test utilizes waiting for condition to exit the test. This
addition will return an error for the shutdown command to see if the
condition waiting code will not hang.

tests/qemuagenttest.c

index 91ea4e11f37abc85e21527698ec9e7ae2127e64f..7d6773c3e88ddca6747139808a5d72aff3dddd91 100644 (file)
@@ -324,6 +324,29 @@ testQemuAgentShutdown(const void *data)
                           QEMU_AGENT_SHUTDOWN_REBOOT) < 0)
         goto cleanup;
 
+    /* check negative response, so that we can verify that the agent breaks
+     * out from sleep */
+
+    if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
+        goto cleanup;
+
+    if (qemuMonitorTestAddItem(test, "guest-shutdown",
+                               "{\"error\":"
+                               "    {\"class\":\"CommandDisabled\","
+                               "     \"desc\":\"The command guest-shutdown has "
+                                               "been disabled for this instance\","
+                               "     \"data\":{\"name\":\"guest-shutdown\"}"
+                               "    }"
+                               "}") < 0)
+        goto cleanup;
+
+    if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
+                          QEMU_AGENT_SHUTDOWN_REBOOT) != -1) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       "agent shutdown command should have failed");
+        goto cleanup;
+    }
+
     ret = 0;
 
 cleanup: