[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 27/39] qtest: check that drives are really appearing and disappear
From: |
Paolo Bonzini |
Subject: |
[PULL 27/39] qtest: check that drives are really appearing and disappearing |
Date: |
Sat, 10 Oct 2020 03:57:27 -0400 |
Do not just trust the HMP commands to create and delete the drive, use
query-block to check that this is actually the case.
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tests/qtest/drive_del-test.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index 9d20a1ed8b..ff772b3671 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
@@ -14,20 +14,49 @@
#include "libqos/libqtest.h"
#include "libqos/virtio.h"
#include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qlist.h"
+
+static bool has_drive(QTestState *qts)
+{
+ QDict *response;
+ QList *ret;
+ QListEntry *entry;
+ bool found;
+
+ response = qtest_qmp(qts, "{'execute': 'query-block'}");
+ g_assert(response && qdict_haskey(response, "return"));
+ ret = qdict_get_qlist(response, "return");
+
+ found = false;
+ QLIST_FOREACH_ENTRY(ret, entry) {
+ QDict *entry_dict = qobject_to(QDict, entry->value);
+ if (!strcmp(qdict_get_str(entry_dict, "device"), "drive0")) {
+ found = true;
+ break;
+ }
+ }
+
+ qobject_unref(response);
+ return found;
+}
static void drive_add(QTestState *qts)
{
char *resp = qtest_hmp(qts, "drive_add 0 if=none,id=drive0");
g_assert_cmpstr(resp, ==, "OK\r\n");
+ g_assert(has_drive(qts));
g_free(resp);
}
static void drive_del(QTestState *qts)
{
- char *resp = qtest_hmp(qts, "drive_del drive0");
+ char *resp;
+ g_assert(has_drive(qts));
+ resp = qtest_hmp(qts, "drive_del drive0");
g_assert_cmpstr(resp, ==, "");
+ g_assert(!has_drive(qts));
g_free(resp);
}
@@ -130,6 +159,7 @@ static void test_drive_del_device_del(void)
*/
drive_del(qts);
device_del(qts);
+ g_assert(!has_drive(qts));
qtest_quit(qts);
}
--
2.26.2
- [PULL 25/39] device-plug-test: use qtest_qmp to send the device_del command, (continued)
- [PULL 25/39] device-plug-test: use qtest_qmp to send the device_del command, Paolo Bonzini, 2020/10/10
- [PULL 22/39] qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict, Paolo Bonzini, 2020/10/10
- [PULL 20/39] build-sys: fix git version from -version, Paolo Bonzini, 2020/10/10
- [PULL 18/39] qtest: unify extra_qtest_srcs and extra_qtest_deps, Paolo Bonzini, 2020/10/10
- [PULL 26/39] qtest: switch users back to qtest_qmp_receive, Paolo Bonzini, 2020/10/10
- [PULL 24/39] qtest: remove qtest_qmp_receive_success, Paolo Bonzini, 2020/10/10
- [PULL 29/39] qdev: add "check if address free" callback for buses, Paolo Bonzini, 2020/10/10
- [PULL 23/39] qtest: Reintroduce qtest_qmp_receive, Paolo Bonzini, 2020/10/10
- [PULL 21/39] meson.build: Re-enable KVM support for MIPS, Paolo Bonzini, 2020/10/10
- [PULL 30/39] scsi/scsi_bus: switch search direction in scsi_device_find, Paolo Bonzini, 2020/10/10
- [PULL 27/39] qtest: check that drives are really appearing and disappearing,
Paolo Bonzini <=
- [PULL 28/39] qemu-iotests, qtest: rewrite test 067 as a qtest, Paolo Bonzini, 2020/10/10
- [PULL 36/39] scsi/scsi_bus: Add scsi_device_get, Paolo Bonzini, 2020/10/10
- [PULL 35/39] scsi/scsi-bus: scsi_device_find: don't return unrealized devices, Paolo Bonzini, 2020/10/10
- [PULL 37/39] virtio-scsi: use scsi_device_get, Paolo Bonzini, 2020/10/10
- [PULL 32/39] device-core: use RCU for list of children of a bus, Paolo Bonzini, 2020/10/10
- [PULL 33/39] scsi: switch to bus->check_address, Paolo Bonzini, 2020/10/10
- [PULL 34/39] device-core: use atomic_set on .realized property, Paolo Bonzini, 2020/10/10
- [PULL 31/39] device_core: use drain_call_rcu in in qmp_device_add, Paolo Bonzini, 2020/10/10
- [PULL 38/39] scsi/scsi_bus: fix races in REPORT LUNS, Paolo Bonzini, 2020/10/10
- [PULL 39/39] meson: identify more sections of meson.build, Paolo Bonzini, 2020/10/10