summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2018-03-09 17:00:05 +0800
committerEric Blake <eblake@redhat.com>2018-03-19 14:58:37 -0500
commit91ad45061af0fe44ac5dadb5bedaf4d7a08077c8 (patch)
tree8a1cf15080b37e19239e0091b9649e02a9a6d33e /tests
parent469638f9cb3fde767fbc207f62fc3735eea96ef1 (diff)
downloadqemu-91ad45061af0fe44ac5dadb5bedaf4d7a08077c8.tar.gz
tests: qmp-test: verify command batching
OOB introduced DROP event for flow control. This should not affect old QMP clients. Add a command batching check to make sure of it. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20180309090006.10018-23-peterx@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qmp-test.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/qmp-test.c b/tests/qmp-test.c
index d1fa1cb217..2e4b599a4c 100644
--- a/tests/qmp-test.c
+++ b/tests/qmp-test.c
@@ -82,6 +82,7 @@ static void test_qmp_protocol(void)
QTestState *qts;
const QListEntry *entry;
QString *qstr;
+ int i;
qts = qtest_init_without_qmp_handshake(common_args);
@@ -139,6 +140,27 @@ static void test_qmp_protocol(void)
g_assert_cmpint(qdict_get_int(resp, "id"), ==, 2);
QDECREF(resp);
+ /*
+ * Test command batching. In current test OOB is not enabled, we
+ * should be able to run as many commands in batch as we like.
+ * Using 16 (>8, which is OOB queue length) to make sure OOB won't
+ * break existing clients. Note: this test does not control the
+ * scheduling of QEMU's QMP command processing threads so it may
+ * not really trigger batching inside QEMU. This is just a
+ * best-effort test.
+ */
+ for (i = 0; i < 16; i++) {
+ qtest_async_qmp(qts, "{ 'execute': 'query-version' }");
+ }
+ /* Verify the replies to make sure no command is dropped. */
+ for (i = 0; i < 16; i++) {
+ resp = qtest_qmp_receive(qts);
+ /* It should never be dropped. Each of them should be a reply. */
+ g_assert(qdict_haskey(resp, "return"));
+ g_assert(!qdict_haskey(resp, "event"));
+ QDECREF(resp);
+ }
+
qtest_quit(qts);
}