From 6bb87be8938691fa5cf989b7517d7d2084b8c141 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Thu, 30 Mar 2017 09:50:05 +0200 Subject: 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 Message-Id: <1490860207-8302-2-git-send-email-thuth@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Dr. David Alan Gilbert Added note to qtest_hmp/qtest_hmpv's header description to say it discards events --- tests/libqtest.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/libqtest.h') diff --git a/tests/libqtest.h b/tests/libqtest.h index 2c9962d94f..ee237448da 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -132,11 +132,12 @@ void qtest_qmp_eventwait(QTestState *s, const char *event); QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event); /** - * qtest_hmpv: + * qtest_hmp: * @s: #QTestState instance to operate on. * @fmt...: HMP command to send to QEMU * * Send HMP command to QEMU via QMP's human-monitor-command. + * QMP events are discarded. * * Returns: the command's output. The caller should g_free() it. */ @@ -149,6 +150,7 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...); * @ap: HMP command arguments * * Send HMP command to QEMU via QMP's human-monitor-command. + * QMP events are discarded. * * Returns: the command's output. The caller should g_free() it. */ -- cgit v1.2.3