From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 12/36] libqtest: rename qmp() to qmp_discard_response()
Date: Thu, 7 Nov 2013 14:12:20 +0100 [thread overview]
Message-ID: <1383829964-32364-13-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1383829964-32364-1-git-send-email-stefanha@redhat.com>
Existing qmp() callers do not expect a response object. In order to
implement real QMP test cases it will be necessary to inspect the
response object.
Rename qmp() to qmp_discard_response(). Later patches will introduce a
qmp() function that returns the response object and tests that use it.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
---
tests/boot-order-test.c | 4 ++--
tests/fdc-test.c | 15 +++++++++------
tests/ide-test.c | 10 ++++++----
tests/libqtest.c | 10 +++++-----
tests/libqtest.h | 20 ++++++++++----------
5 files changed, 32 insertions(+), 27 deletions(-)
diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 4b233d0..da158c3 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -41,12 +41,12 @@ static void test_a_boot_order(const char *machine,
qtest_start(args);
actual = read_boot_order();
g_assert_cmphex(actual, ==, expected_boot);
- qmp("{ 'execute': 'system_reset' }");
+ qmp_discard_response("{ 'execute': 'system_reset' }");
/*
* system_reset only requests reset. We get a RESET event after
* the actual reset completes. Need to wait for that.
*/
- qmp(""); /* HACK: wait for event */
+ qmp_discard_response(""); /* HACK: wait for event */
actual = read_boot_order();
g_assert_cmphex(actual, ==, expected_reboot);
qtest_quit(global_qtest);
diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index fd198dc..38b5b17 100644
--- a/tests/fdc-test.c
+++ b/tests/fdc-test.c
@@ -290,10 +290,12 @@ static void test_media_insert(void)
/* Insert media in drive. DSKCHK should not be reset until a step pulse
* is sent. */
- qmp("{'execute':'change', 'arguments':{ 'device':'floppy0', "
- "'target': '%s' }}", test_image);
- qmp(""); /* ignore event (FIXME open -> open transition?!) */
- qmp(""); /* ignore event */
+ qmp_discard_response("{'execute':'change', 'arguments':{"
+ " 'device':'floppy0', 'target': '%s' }}",
+ test_image);
+ qmp_discard_response(""); /* ignore event
+ (FIXME open -> open transition?!) */
+ qmp_discard_response(""); /* ignore event */
dir = inb(FLOPPY_BASE + reg_dir);
assert_bit_set(dir, DSKCHG);
@@ -322,8 +324,9 @@ static void test_media_change(void)
/* Eject the floppy and check that DSKCHG is set. Reading it out doesn't
* reset the bit. */
- qmp("{'execute':'eject', 'arguments':{ 'device':'floppy0' }}");
- qmp(""); /* ignore event */
+ qmp_discard_response("{'execute':'eject', 'arguments':{"
+ " 'device':'floppy0' }}");
+ qmp_discard_response(""); /* ignore event */
dir = inb(FLOPPY_BASE + reg_dir);
assert_bit_set(dir, DSKCHG);
diff --git a/tests/ide-test.c b/tests/ide-test.c
index bc824a8..d5cec5a 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -460,8 +460,9 @@ static void test_flush(void)
tmp_path);
/* Delay the completion of the flush request until we explicitly do it */
- qmp("{'execute':'human-monitor-command', 'arguments': { "
- "'command-line': 'qemu-io ide0-hd0 \"break flush_to_os A\"'} }");
+ qmp_discard_response("{'execute':'human-monitor-command', 'arguments': {"
+ " 'command-line':"
+ " 'qemu-io ide0-hd0 \"break flush_to_os A\"'} }");
/* FLUSH CACHE command on device 0*/
outb(IDE_BASE + reg_device, 0);
@@ -473,8 +474,9 @@ static void test_flush(void)
assert_bit_clear(data, DF | ERR | DRQ);
/* Complete the command */
- qmp("{'execute':'human-monitor-command', 'arguments': { "
- "'command-line': 'qemu-io ide0-hd0 \"resume A\"'} }");
+ qmp_discard_response("{'execute':'human-monitor-command', 'arguments': {"
+ " 'command-line':"
+ " 'qemu-io ide0-hd0 \"resume A\"'} }");
/* Check registers */
data = inb(IDE_BASE + reg_device);
diff --git a/tests/libqtest.c b/tests/libqtest.c
index bb82069..dc4c983 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -151,8 +151,8 @@ QTestState *qtest_init(const char *extra_args)
}
/* Read the QMP greeting and then do the handshake */
- qtest_qmp(s, "");
- qtest_qmp(s, "{ 'execute': 'qmp_capabilities' }");
+ qtest_qmp_discard_response(s, "");
+ qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }");
if (getenv("QTEST_STOP")) {
kill(qtest_qemu_pid(s), SIGSTOP);
@@ -291,7 +291,7 @@ redo:
return words;
}
-void qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
+void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap)
{
bool has_reply = false;
int nesting = 0;
@@ -326,12 +326,12 @@ void qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
}
}
-void qtest_qmp(QTestState *s, const char *fmt, ...)
+void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- qtest_qmpv(s, fmt, ap);
+ qtest_qmpv_discard_response(s, fmt, ap);
va_end(ap);
}
diff --git a/tests/libqtest.h b/tests/libqtest.h
index a6e99bd..4f1b060 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -44,23 +44,23 @@ QTestState *qtest_init(const char *extra_args);
void qtest_quit(QTestState *s);
/**
- * qtest_qmp:
+ * qtest_qmp_discard_response:
* @s: #QTestState instance to operate on.
* @fmt...: QMP message to send to qemu
*
- * Sends a QMP message to QEMU
+ * Sends a QMP message to QEMU and consumes the response.
*/
-void qtest_qmp(QTestState *s, const char *fmt, ...);
+void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...);
/**
- * qtest_qmpv:
+ * 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.
+ * Sends a QMP message to QEMU and consumes the response.
*/
-void qtest_qmpv(QTestState *s, const char *fmt, va_list ap);
+void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap);
/**
* qtest_get_irq:
@@ -331,17 +331,17 @@ static inline void qtest_end(void)
}
/**
- * qmp:
+ * qmp_discard_response:
* @fmt...: QMP message to send to qemu
*
- * Sends a QMP message to QEMU
+ * Sends a QMP message to QEMU and consumes the response.
*/
-static inline void qmp(const char *fmt, ...)
+static inline void qmp_discard_response(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- qtest_qmpv(global_qtest, fmt, ap);
+ qtest_qmpv_discard_response(global_qtest, fmt, ap);
va_end(ap);
}
--
1.8.3.1
next prev parent reply other threads:[~2013-11-07 13:13 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-07 13:12 [Qemu-devel] [PULL for-1.7 00/36] Block patches Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 01/36] qapi: Fix comment for create-type to match code Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 02/36] qemu-iotests: Filter out actual image size in 067 Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 03/36] block/raw-posix: fix FreeBSD compilation Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 04/36] block: qemu-iotests, add quotes to $TEST_IMG usage io pattern tests Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 05/36] block: qemu-iotests, fix _make_test_img() to work with spaced pathnames Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 06/36] block: qemu-iotests, add quotes to $TEST_IMG.base usage in 017 Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 07/36] block: qemu-iotests, add quotes to $TEST_IMG usage in 019 Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 08/36] block: qemu-iotests, removes duplicate double quotes in 039 Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 09/36] block: qemu-iotests, add quotes to $TEST_IMG usage for 051 Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 10/36] block: qemu-iotests, add quotes to $TEST_IMG usage in 061 Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 11/36] blockdev: fix drive_init() opts and bs_opts leaks Stefan Hajnoczi
2013-11-07 13:12 ` Stefan Hajnoczi [this message]
2013-11-07 13:12 ` [Qemu-devel] [PULL 13/36] libqtest: add qmp(fmt, ...) -> QDict* function Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 14/36] blockdev-test: add test case for drive_add duplicate IDs Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 15/36] qdev-monitor-test: add device_add leak test cases Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 16/36] block: Save errno before error_setg_errno Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 17/36] block/vpc: fix virtual size for images created with disk2vhd Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 18/36] block: vhdx - minor comments and typo correction Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 19/36] block: vhdx - add header update capability Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 20/36] block: vhdx code movement - VHDXMetadataEntries and BDRVVHDXState to header Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 21/36] block: vhdx - log support struct and defines Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 22/36] block: vhdx - break endian translation functions out Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 23/36] block: vhdx - update log guid in header, and first write tracker Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 24/36] block: vhdx code movement - move vhdx_close() above vhdx_open() Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 25/36] block: vhdx - log parsing, replay, and flush support Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 26/36] block: vhdx - add region overlap detection for image files Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 27/36] block: vhdx - add log write support Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 28/36] block: vhdx " Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 29/36] block: vhdx - remove BAT file offset bit shifting Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 30/36] block: vhdx - move more endian translations to vhdx-endian.c Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 31/36] block: vhdx - break out code operations to functions Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 32/36] block: vhdx - fix comment typos in header, fix incorrect struct fields Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 33/36] block: vhdx - add .bdrv_create() support Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 34/36] block: vhdx - update _make_test_img() to filter out vhdx options Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 35/36] block: qemu-iotests for vhdx, add write test support Stefan Hajnoczi
2013-11-07 13:12 ` [Qemu-devel] [PULL 36/36] block: vhdx qemu-iotest - log replay of data sector Stefan Hajnoczi
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=1383829964-32364-13-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@amazon.com \
--cc=qemu-devel@nongnu.org \
/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).