[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/3] tests: more strict command batching test
From: |
Peter Xu |
Subject: |
[Qemu-devel] [PATCH 3/3] tests: more strict command batching test |
Date: |
Wed, 21 Mar 2018 14:55:06 +0800 |
Add "id" fields to the commands, and check that the command returns are
in order.
Signed-off-by: Peter Xu <address@hidden>
---
tests/qmp-test.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tests/qmp-test.c b/tests/qmp-test.c
index 07c0b87e27..c861c3b550 100644
--- a/tests/qmp-test.c
+++ b/tests/qmp-test.c
@@ -83,6 +83,7 @@ static void test_qmp_protocol(void)
const QListEntry *entry;
QString *qstr;
int i;
+ char buf[128];
qts = qtest_init_without_qmp_handshake(common_args);
@@ -150,7 +151,10 @@ static void test_qmp_protocol(void)
* best-effort test.
*/
for (i = 0; i < 16; i++) {
- qtest_async_qmp(qts, "{ 'execute': 'query-version' }");
+ snprintf(buf, sizeof(buf) - 1, "{ 'execute': 'query-version', "
+ "'id': %d }", i);
+ buf[sizeof(buf) - 1] = '\0';
+ qtest_async_qmp(qts, buf);
}
/* Verify the replies to make sure no command is dropped. */
for (i = 0; i < 16; i++) {
@@ -158,6 +162,8 @@ static void test_qmp_protocol(void)
/* It should never be dropped. Each of them should be a reply. */
g_assert(qdict_haskey(resp, "return"));
g_assert(!qdict_haskey(resp, "event"));
+ g_assert(qdict_haskey(resp, "id"));
+ g_assert(qdict_get_int(resp, "id") == i);
QDECREF(resp);
}
--
2.14.3