diff options
author | Thomas Huth <thuth@redhat.com> | 2017-03-30 09:50:05 +0200 |
---|---|---|
committer | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2017-04-26 14:42:31 +0100 |
commit | 6bb87be8938691fa5cf989b7517d7d2084b8c141 (patch) | |
tree | 1d828438e53ab425ca86cc8e7ed14d5635fa1f68 /tests/libqtest.c | |
parent | b7da97eef74bf834be244de0796ccb01db3985c9 (diff) |
libqtest: Ignore QMP events when parsing the response for HMP commands
When running certain HMP commands (like "device_del") via QMP, we
can sometimes get a QMP event in the response first, so that the
"g_assert(ret)" statement in qtest_hmp() triggers and the test
fails. Fix this by ignoring such QMP events while looking for the
real return value from QMP.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1490860207-8302-2-git-send-email-thuth@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Added note to qtest_hmp/qtest_hmpv's header description to say
it discards events
Diffstat (limited to 'tests/libqtest.c')
-rw-r--r-- | tests/libqtest.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/libqtest.c b/tests/libqtest.c index 99b1195355..0b0bf1d460 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -588,6 +588,12 @@ char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap) " 'arguments': {'command-line': %s}}", cmd); ret = g_strdup(qdict_get_try_str(resp, "return")); + while (ret == NULL && qdict_get_try_str(resp, "event")) { + /* Ignore asynchronous QMP events */ + QDECREF(resp); + resp = qtest_qmp_receive(s); + ret = g_strdup(qdict_get_try_str(resp, "return")); + } g_assert(ret); QDECREF(resp); g_free(cmd); |