From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: thuth@redhat.com, f4bug@amsat.org, eblake@redhat.com
Subject: [Qemu-devel] [PATCH v3 04/23] libqtest: Remove qtest_qmp_discard_response() & friends
Date: Mon, 6 Aug 2018 08:53:25 +0200 [thread overview]
Message-ID: <20180806065344.7103-5-armbru@redhat.com> (raw)
In-Reply-To: <20180806065344.7103-1-armbru@redhat.com>
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 <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
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"
+/* 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"
+/* 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"
+/* 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 = hmp("drive_add 0 if=none,id=drive0");
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 @@
#include "libqtest.h"
+#include "qapi/qmp/qdict.h"
#include "qemu-common.h"
+/* 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
#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"
+/* 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 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 = qtest_qmp_receive(s);
qobject_unref(greeting);
- qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }");
+ qobject_unref(qtest_qmp(s, "{ 'execute': 'qmp_capabilities' }"));
return s;
}
@@ -591,23 +591,6 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ...)
va_end(ap);
}
-void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap)
-{
- QDict *response = 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 = 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);
}
-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_oob,
*/
void qtest_quit(QTestState *s);
-/**
- * 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, ...);
-/**
- * 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 ap);
-
/**
* qtest_qmpv:
* @s: #QTestState instance to operate on.
@@ -575,14 +556,6 @@ QDict *qmp(const char *fmt, ...);
*/
void qmp_send(const char *fmt, ...);
-/**
- * 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"
+/* 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 = 1024 * 1024;
const unsigned end_address = 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 @@
#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"
+/* 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 @@
#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"
+/* 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"
+/* 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
--
2.17.1
next prev parent reply other threads:[~2018-08-06 6:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-06 6:53 [Qemu-devel] [PATCH v3 00/23] tests: Compile-time format string checking for libqtest.h Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 01/23] libqtest: Rename functions to send QMP messages Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 02/23] libqtest: Clean up how we read device_del messages Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 03/23] libqtest: Clean up how we read the QMP greeting Markus Armbruster
2018-08-06 6:53 ` Markus Armbruster [this message]
2018-08-06 7:02 ` [Qemu-devel] [PATCH v3 04/23] libqtest: Remove qtest_qmp_discard_response() & friends Thomas Huth
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 05/23] libqtest: Document calling conventions Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 06/23] qobject: Replace qobject_from_jsonf() by qobject_from_jsonf_nofail() Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 07/23] qobject: New qobject_from_vjsonf_nofail(), qdict_from_vjsonf_nofail() Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 08/23] libqtest: Simplify qmp_fd_vsend() a bit Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 09/23] test-qobject-input-visitor: Avoid format string ambiguity Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 10/23] qobject: qobject_from_jsonv() is dangerous, hide it away Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 11/23] tests: Pass literal format strings directly to qmp_FOO() Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 12/23] tests: Clean up string interpolation into QMP input (simple cases) Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 13/23] cpu-plug-test: Don't pass integers as strings to device_add Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 14/23] tests: Clean up string interpolation around qtest_qmp_device_add() Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 15/23] migration-test: Make wait_command() return the "return" member Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 16/23] tests: New helper qtest_qmp_receive_success() Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 17/23] migration-test: Make wait_command() cope with '%' Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 18/23] migration-test: Clean up string interpolation into QMP, part 1 Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 19/23] migration-test: Clean up string interpolation into QMP, part 2 Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 20/23] migration-test: Clean up string interpolation into QMP, part 3 Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 21/23] libqtest: Enable compile-time format string checking Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 22/23] libqtest: Replace qtest_startf() by qtest_initf() Markus Armbruster
2018-08-06 6:53 ` [Qemu-devel] [PATCH v3 23/23] libqtest: Rename qtest_FOOv() to qtest_vFOO() for consistency Markus Armbruster
2018-08-12 10:02 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180806065344.7103-5-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=f4bug@amsat.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).