]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemumonitorjsontest: Introduce GetNonExistingCPUData test
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 19 Nov 2013 15:30:28 +0000 (16:30 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 19 Nov 2013 15:30:28 +0000 (16:30 +0100)
In the 730af8f2cd commit we are fixing broken qemu startup on systems
with ancient qemu. This commit introduces the regression test for that
specific case to make sure we don't break it again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemumonitorjsontest.c

index 4cdb938611ec1c42d6a9cb982b18c7122036bad8..2152e4a42151cc27e36617633aa1f8fdca6c9509 100644 (file)
@@ -2038,6 +2038,49 @@ cleanup:
     return ret;
 }
 
+static int
+testQemuMonitorJSONGetNonExistingCPUData(const void *opaque)
+{
+    virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr) opaque;
+    qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
+    virCPUDataPtr cpuData = NULL;
+    int rv, ret = -1;
+
+    if (!test)
+        return -1;
+
+    if (qemuMonitorTestAddItem(test, "qom-list",
+                               "{"
+                               "    \"id\": \"libvirt-7\","
+                               "    \"error\": {"
+                               "        \"class\": \"CommandNotFound\","
+                               "        \"desc\": \"The command qom-list has not been found\""
+                               "    }"
+                               "}") < 0)
+        goto cleanup;
+
+    rv = qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test),
+                                   VIR_ARCH_X86_64,
+                                   &cpuData);
+    if (rv != -2) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "Unexpected return value %d, expecting -2", rv);
+        goto cleanup;
+    }
+
+    if (cpuData) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "Unexpected allocation of data = %p, expecting NULL",
+                       cpuData);
+        goto cleanup;
+    }
+
+    ret = 0;
+cleanup:
+    qemuMonitorTestFree(test);
+    cpuDataFree(cpuData);
+    return ret;
+}
 
 static int
 mymain(void)
@@ -2094,6 +2137,7 @@ mymain(void)
     DO_TEST(SetObjectProperty);
     DO_TEST(GetDeviceAliases);
     DO_TEST(CPU);
+    DO_TEST(GetNonExistingCPUData);
     DO_TEST_SIMPLE("qmp_capabilities", qemuMonitorJSONSetCapabilities);
     DO_TEST_SIMPLE("system_powerdown", qemuMonitorJSONSystemPowerdown);
     DO_TEST_SIMPLE("system_reset", qemuMonitorJSONSystemReset);