[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 05/17] qtest: switch users back to qtest_qmp_receive
From: |
Paolo Bonzini |
Subject: |
[PATCH v8 05/17] qtest: switch users back to qtest_qmp_receive |
Date: |
Wed, 7 Oct 2020 07:56:48 -0400 |
From: Maxim Levitsky <mlevitsk@redhat.com>
Let test use the new functionality for buffering events.
The only remaining users of qtest_qmp_receive_dict are tests
that fuzz the QMP protocol.
Tested with 'make check-qtest'.
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20201006123904.610658-4-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tests/qtest/ahci-test.c | 4 ++--
tests/qtest/drive_del-test.c | 9 +++------
tests/qtest/libqtest.c | 12 +++---------
tests/qtest/pvpanic-test.c | 4 +---
tests/qtest/tpm-util.c | 8 ++++++--
5 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index d42ebaeb4c..5e1954852e 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -1590,7 +1590,7 @@ static void test_atapi_tray(void)
qtest_qmp_send(ahci->parent->qts, "{'execute': 'blockdev-open-tray', "
"'arguments': {'id': 'cd0'}}");
atapi_wait_tray(ahci, true);
- rsp = qtest_qmp_receive_dict(ahci->parent->qts);
+ rsp = qtest_qmp_receive(ahci->parent->qts);
qobject_unref(rsp);
qmp_discard_response(ahci->parent->qts,
@@ -1620,7 +1620,7 @@ static void test_atapi_tray(void)
qtest_qmp_send(ahci->parent->qts, "{'execute': 'blockdev-close-tray', "
"'arguments': {'id': 'cd0'}}");
atapi_wait_tray(ahci, false);
- rsp = qtest_qmp_receive_dict(ahci->parent->qts);
+ rsp = qtest_qmp_receive(ahci->parent->qts);
qobject_unref(rsp);
/* Now, to convince ATAPI we understand the media has changed... */
diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index ba0cd77445..9d20a1ed8b 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
@@ -15,9 +15,6 @@
#include "libqos/virtio.h"
#include "qapi/qmp/qdict.h"
-/* TODO actually test the results and get rid of this */
-#define qmp_discard_response(q, ...) qobject_unref(qtest_qmp(q, __VA_ARGS__))
-
static void drive_add(QTestState *qts)
{
char *resp = qtest_hmp(qts, "drive_add 0 if=none,id=drive0");
@@ -38,13 +35,13 @@ static void device_del(QTestState *qts)
{
QDict *response;
- /* Complication: ignore DEVICE_DELETED event */
- qmp_discard_response(qts, "{'execute': 'device_del',"
+ response = qtest_qmp(qts, "{'execute': 'device_del',"
" 'arguments': { 'id': 'dev0' } }");
- response = qtest_qmp_receive_dict(qts);
g_assert(response);
g_assert(qdict_haskey(response, "return"));
qobject_unref(response);
+
+ qtest_qmp_eventwait(qts, "DEVICE_DELETED");
}
static void test_drive_without_dev(void)
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index baac667b8d..08929f5ff6 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -324,7 +324,7 @@ QTestState *qtest_init(const char *extra_args)
QDict *greeting;
/* Read the QMP greeting and then do the handshake */
- greeting = qtest_qmp_receive_dict(s);
+ greeting = qtest_qmp_receive(s);
qobject_unref(greeting);
qobject_unref(qtest_qmp(s, "{ 'execute': 'qmp_capabilities' }"));
@@ -700,7 +700,7 @@ QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t
fds_num,
qtest_qmp_vsend_fds(s, fds, fds_num, fmt, ap);
/* Receive reply */
- return qtest_qmp_receive_dict(s);
+ return qtest_qmp_receive(s);
}
QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
@@ -708,7 +708,7 @@ QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list
ap)
qtest_qmp_vsend(s, fmt, ap);
/* Receive reply */
- return qtest_qmp_receive_dict(s);
+ return qtest_qmp_receive(s);
}
QDict *qmp_fd(int fd, const char *fmt, ...)
@@ -850,12 +850,6 @@ char *qtest_vhmp(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 */
- qobject_unref(resp);
- resp = qtest_qmp_receive_dict(s);
- ret = g_strdup(qdict_get_try_str(resp, "return"));
- }
g_assert(ret);
qobject_unref(resp);
g_free(cmd);
diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c
index b0b20ad340..0657de797f 100644
--- a/tests/qtest/pvpanic-test.c
+++ b/tests/qtest/pvpanic-test.c
@@ -24,9 +24,7 @@ static void test_panic(void)
qtest_outb(qts, 0x505, 0x1);
- response = qtest_qmp_receive_dict(qts);
- g_assert(qdict_haskey(response, "event"));
- g_assert_cmpstr(qdict_get_str(response, "event"), ==, "GUEST_PANICKED");
+ response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED");
g_assert(qdict_haskey(response, "data"));
data = qdict_get_qdict(response, "data");
g_assert(qdict_haskey(data, "action"));
diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
index 3ed6c8548a..5a33a6ef0f 100644
--- a/tests/qtest/tpm-util.c
+++ b/tests/qtest/tpm-util.c
@@ -237,12 +237,16 @@ void tpm_util_migrate(QTestState *who, const char *uri)
void tpm_util_wait_for_migration_complete(QTestState *who)
{
while (true) {
+ QDict *rsp;
QDict *rsp_return;
bool completed;
const char *status;
- qtest_qmp_send(who, "{ 'execute': 'query-migrate' }");
- rsp_return = qtest_qmp_receive_success(who, NULL, NULL);
+ rsp = qtest_qmp(who, "{ 'execute': 'query-migrate' }");
+ g_assert(qdict_haskey(rsp, "return"));
+ rsp_return = qdict_get_qdict(rsp, "return");
+
+ g_assert(!qdict_haskey(rsp_return, "error"));
status = qdict_get_str(rsp_return, "status");
completed = strcmp(status, "completed") == 0;
g_assert_cmpstr(status, !=, "failed");
--
2.26.2
- [PATCH v8 00/17] Fix scsi devices plug/unplug races w.r.t virtio-scsi iothread, Paolo Bonzini, 2020/10/07
- [PATCH v8 04/17] device-plug-test: use qtest_qmp to send the device_del command, Paolo Bonzini, 2020/10/07
- [PATCH v8 02/17] qtest: Reintroduce qtest_qmp_receive, Paolo Bonzini, 2020/10/07
- [PATCH v8 06/17] qtest: check that drives are really appearing and disappearing, Paolo Bonzini, 2020/10/07
- [PATCH v8 01/17] qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict, Paolo Bonzini, 2020/10/07
- [PATCH v8 03/17] qtest: remove qtest_qmp_receive_success, Paolo Bonzini, 2020/10/07
- [PATCH v8 05/17] qtest: switch users back to qtest_qmp_receive,
Paolo Bonzini <=
- [PATCH v8 07/17] qemu-iotests, qtest: rewrite test 067 as a qtest, Paolo Bonzini, 2020/10/07
- [PATCH v8 09/17] scsi/scsi_bus: switch search direction in scsi_device_find, Paolo Bonzini, 2020/10/07
- [PATCH v8 08/17] qdev: add "check if address free" callback for buses, Paolo Bonzini, 2020/10/07
- [PATCH v8 12/17] scsi: switch to bus->check_address, Paolo Bonzini, 2020/10/07
- [PATCH v8 16/17] virtio-scsi: use scsi_device_get, Paolo Bonzini, 2020/10/07
- [PATCH v8 10/17] device_core: use drain_call_rcu in in qmp_device_add, Paolo Bonzini, 2020/10/07
- [PATCH v8 15/17] scsi/scsi_bus: Add scsi_device_get, Paolo Bonzini, 2020/10/07
- [PATCH v8 14/17] scsi/scsi-bus: scsi_device_find: don't return unrealized devices, Paolo Bonzini, 2020/10/07