From nobody Wed Nov 5 00:11:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1533538800228668.0112145416002; Mon, 6 Aug 2018 00:00:00 -0700 (PDT) Received: from localhost ([::1]:60971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmZUj-0006af-T0 for importer@patchew.org; Mon, 06 Aug 2018 02:59:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmZOp-0001XP-5P for qemu-devel@nongnu.org; Mon, 06 Aug 2018 02:53:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmZOl-000878-UP for qemu-devel@nongnu.org; Mon, 06 Aug 2018 02:53:51 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35596 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fmZOl-00086H-NI for qemu-devel@nongnu.org; Mon, 06 Aug 2018 02:53:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 94FDA81663D5; Mon, 6 Aug 2018 06:53:46 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4EDBA2026D68; Mon, 6 Aug 2018 06:53:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 95AD41138659; Mon, 6 Aug 2018 08:53:44 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 6 Aug 2018 08:53:25 +0200 Message-Id: <20180806065344.7103-5-armbru@redhat.com> In-Reply-To: <20180806065344.7103-1-armbru@redhat.com> References: <20180806065344.7103-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 06 Aug 2018 06:53:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 06 Aug 2018 06:53:46 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'armbru@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v3 04/23] libqtest: Remove qtest_qmp_discard_response() & friends X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qtest_qmp_discard_response(...) is shorthand for qobject_unref(qtest_qmp(...), except it's not actually shorter. Moreover, the presence of these functions encourage sloppy testing. Remove them from libqtest. Add them as macros to the tests that use them, with a TODO comment asking for cleanup. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Thomas Huth --- tests/ahci-test.c | 3 +++ tests/boot-order-test.c | 5 ++++- tests/drive_del-test.c | 3 +++ tests/fdc-test.c | 4 ++++ tests/ide-test.c | 5 ++++- tests/libqtest.c | 27 +-------------------------- tests/libqtest.h | 27 --------------------------- tests/migration-test.c | 3 +++ tests/test-filter-mirror.c | 4 ++++ tests/test-filter-redirector.c | 4 ++++ tests/virtio-blk-test.c | 4 ++++ 11 files changed, 34 insertions(+), 55 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index 7e3491b5bd..555f02112e 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -37,6 +37,9 @@ #include "hw/pci/pci_ids.h" #include "hw/pci/pci_regs.h" =20 +/* TODO actually test the results and get rid of this */ +#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) + /* Test images sizes in MB */ #define TEST_IMAGE_SIZE_MB_LARGE (200 * 1024) #define TEST_IMAGE_SIZE_MB_SMALL 64 diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index e70f5dedba..9096a4b5df 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -13,9 +13,12 @@ #include "qemu/osdep.h" #include "libqos/fw_cfg.h" #include "libqtest.h" - +#include "qapi/qmp/qdict.h" #include "hw/nvram/fw_cfg_keys.h" =20 +/* TODO actually test the results and get rid of this */ +#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) + typedef struct { const char *args; uint64_t expected_boot; diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c index 852fefc8f3..2d0b176b36 100644 --- a/tests/drive_del-test.c +++ b/tests/drive_del-test.c @@ -15,6 +15,9 @@ #include "libqos/virtio.h" #include "qapi/qmp/qdict.h" =20 +/* TODO actually test the results and get rid of this */ +#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) + static void drive_add(void) { char *resp =3D hmp("drive_add 0 if=3Dnone,id=3Ddrive0"); diff --git a/tests/fdc-test.c b/tests/fdc-test.c index 325712e0f2..88f1abfa10 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -26,8 +26,12 @@ =20 =20 #include "libqtest.h" +#include "qapi/qmp/qdict.h" #include "qemu-common.h" =20 +/* TODO actually test the results and get rid of this */ +#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) + #define TEST_IMAGE_SIZE 1440 * 1024 =20 #define FLOPPY_BASE 0x3f0 diff --git a/tests/ide-test.c b/tests/ide-test.c index 2384c2c3e2..7ab09c3448 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -29,12 +29,15 @@ #include "libqos/libqos.h" #include "libqos/pci-pc.h" #include "libqos/malloc-pc.h" - +#include "qapi/qmp/qdict.h" #include "qemu-common.h" #include "qemu/bswap.h" #include "hw/pci/pci_ids.h" #include "hw/pci/pci_regs.h" =20 +/* TODO actually test the results and get rid of this */ +#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) + #define TEST_IMAGE_SIZE 64 * 1024 * 1024 =20 #define IDE_PCI_DEV 1 diff --git a/tests/libqtest.c b/tests/libqtest.c index c2c08a890c..2fe0f4dc29 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -254,7 +254,7 @@ QTestState *qtest_init(const char *extra_args) /* Read the QMP greeting and then do the handshake */ greeting =3D qtest_qmp_receive(s); qobject_unref(greeting); - qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }"); + qobject_unref(qtest_qmp(s, "{ 'execute': 'qmp_capabilities' }")); =20 return s; } @@ -591,23 +591,6 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ..= .) va_end(ap); } =20 -void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list a= p) -{ - QDict *response =3D qtest_qmpv(s, fmt, ap); - qobject_unref(response); -} - -void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...) -{ - va_list ap; - QDict *response; - - va_start(ap, fmt); - response =3D qtest_qmpv(s, fmt, ap); - va_end(ap); - qobject_unref(response); -} - QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event) { QDict *response; @@ -979,14 +962,6 @@ void qmp_send(const char *fmt, ...) va_end(ap); } =20 -void qmp_discard_response(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - qtest_qmpv_discard_response(global_qtest, fmt, ap); - va_end(ap); -} char *hmp(const char *fmt, ...) { va_list ap; diff --git a/tests/libqtest.h b/tests/libqtest.h index c1af40106f..3eecd5e9a7 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -73,15 +73,6 @@ QTestState *qtest_init_without_qmp_handshake(bool use_oo= b, */ void qtest_quit(QTestState *s); =20 -/** - * qtest_qmp_discard_response: - * @s: #QTestState instance to operate on. - * @fmt...: QMP message to send to qemu - * - * Sends a QMP message to QEMU and consumes the response. - */ -void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...); - /** * qtest_qmp: * @s: #QTestState instance to operate on. @@ -100,16 +91,6 @@ QDict *qtest_qmp(QTestState *s, const char *fmt, ...); */ void qtest_qmp_send(QTestState *s, const char *fmt, ...); =20 -/** - * qtest_qmpv_discard_response: - * @s: #QTestState instance to operate on. - * @fmt: QMP message to send to QEMU - * @ap: QMP message arguments - * - * Sends a QMP message to QEMU and consumes the response. - */ -void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list a= p); - /** * qtest_qmpv: * @s: #QTestState instance to operate on. @@ -575,14 +556,6 @@ QDict *qmp(const char *fmt, ...); */ void qmp_send(const char *fmt, ...); =20 -/** - * qmp_discard_response: - * @fmt...: QMP message to send to qemu - * - * Sends a QMP message to QEMU and consumes the response. - */ -void qmp_discard_response(const char *fmt, ...); - /** * qmp_receive: * diff --git a/tests/migration-test.c b/tests/migration-test.c index e079e0bdb6..bbe9c9e95d 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -20,6 +20,9 @@ #include "chardev/char.h" #include "sysemu/sysemu.h" =20 +/* TODO actually test the results and get rid of this */ +#define qtest_qmp_discard_response(...) qobject_unref(qtest_qmp(__VA_ARGS_= _)) + const unsigned start_address =3D 1024 * 1024; const unsigned end_address =3D 100 * 1024 * 1024; bool got_stop; diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c index 6c6f710dc6..de5ba155db 100644 --- a/tests/test-filter-mirror.c +++ b/tests/test-filter-mirror.c @@ -10,11 +10,15 @@ =20 #include "qemu/osdep.h" #include "libqtest.h" +#include "qapi/qmp/qdict.h" #include "qemu/iov.h" #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" =20 +/* TODO actually test the results and get rid of this */ +#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) + static void test_mirror(void) { int send_sock[2], recv_sock; diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c index fbaf19bbd8..896f900e98 100644 --- a/tests/test-filter-redirector.c +++ b/tests/test-filter-redirector.c @@ -52,11 +52,15 @@ =20 #include "qemu/osdep.h" #include "libqtest.h" +#include "qapi/qmp/qdict.h" #include "qemu/iov.h" #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" =20 +/* TODO actually test the results and get rid of this */ +#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) + static const char *get_devstr(void) { if (g_str_equal(qtest_get_arch(), "s390x")) { diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 9be9ffb378..06226b8717 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -16,6 +16,7 @@ #include "libqos/virtio-pci.h" #include "libqos/virtio-mmio.h" #include "libqos/malloc-generic.h" +#include "qapi/qmp/qdict.h" #include "qemu/bswap.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_config.h" @@ -23,6 +24,9 @@ #include "standard-headers/linux/virtio_blk.h" #include "standard-headers/linux/virtio_pci.h" =20 +/* TODO actually test the results and get rid of this */ +#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) + #define TEST_IMAGE_SIZE (64 * 1024 * 1024) #define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000) #define PCI_SLOT_HP 0x06 --=20 2.17.1