From: Eli Qiao <liyong.qiao(a)intel.com>
This patch add test case for qemuMonitorJSONGetMigrationParameter.
It will verify if qemu monitor json value can be parsed correctly.
Signed-off-by: ShaoHe Feng <shaohe.feng(a)intel.com>
Signed-off-by: Eli Qiao <liyong.qiao(a)intel.com>
---
tests/qemumonitorjsontest.c | 53 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index ded0423..7d5c554 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1592,6 +1592,59 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo(const void
*data)
return ret;
}
+tatic int
+testQemuMonitorJSONqemuMonitorJSONGetMigrationParameters(const void *data)
+{
+ virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
+ qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
+ int ret = -1;
+ unsigned int level;
+ unsigned int threads;
+ unsigned int dthreads;
+
+ if (!test)
+ return -1;
+
+ if (qemuMonitorTestAddItem(test, "query-migrate-parameters",
+ "{"
+ " \"return\": {"
+ " \"decompress-threads\": 2,"
+ " \"compress-threads\": 8,"
+ " \"compress-level\": 1"
+ " }"
+ "}") < 0) {
+ goto cleanup;
+ }
+
+ if (qemuMonitorJSONGetMigrationParameters(qemuMonitorTestGetMonitor(test),
+ &level, &threads, &dthreads)
< 0)
+ goto cleanup;
+ if (dthreads != 2) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "Invalid decompress-threads: %d, expected 2",
+ dthreads);
+ goto cleanup;
+ }
+ if (threads != 8) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "Invalid decompress-threads: %d, expected 8",
+ threads);
+ goto cleanup;
+ }
+ if (level != 1) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "Invalid decompress-threads: %d, expected 1",
+ level);
+ goto cleanup;
+ }
+ ret = 0;
+
+ cleanup:
+ qemuMonitorTestFree(test);
+ return ret;
+}
+
+
static int
testQemuMonitorJSONqemuMonitorJSONGetMigrationCacheSize(const void *data)
{
--
2.1.4