[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 63/69] libqtest: add qmp_eventwait
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 63/69] libqtest: add qmp_eventwait |
Date: |
Fri, 27 Feb 2015 18:19:01 +0000 |
From: John Snow <address@hidden>
Allow the user to poll until a desired interrupt occurs.
Signed-off-by: John Snow <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
tests/ide-test.c | 11 +----------
tests/libqtest.c | 16 ++++++++++++++++
tests/libqtest.h | 20 ++++++++++++++++++++
3 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/tests/ide-test.c b/tests/ide-test.c
index b28a302..1dae84f 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -520,7 +520,6 @@ static void test_retry_flush(const char *machine)
{
uint8_t data;
const char *s;
- QDict *response;
prepare_blkdebug_script(debug_path, "flush_to_disk");
@@ -539,15 +538,7 @@ static void test_retry_flush(const char *machine)
assert_bit_set(data, BSY | DRDY);
assert_bit_clear(data, DF | ERR | DRQ);
- for (;; response = NULL) {
- response = qmp_receive();
- if ((qdict_haskey(response, "event")) &&
- (strcmp(qdict_get_str(response, "event"), "STOP") == 0)) {
- QDECREF(response);
- break;
- }
- QDECREF(response);
- }
+ qmp_eventwait("STOP");
/* Complete the command */
s = "{'execute':'cont' }";
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 9a92aa7..a3ee8ae 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -450,6 +450,22 @@ void qtest_qmp_discard_response(QTestState *s, const char
*fmt, ...)
QDECREF(response);
}
+void qtest_qmp_eventwait(QTestState *s, const char *event)
+{
+ QDict *response;
+
+ for (;;) {
+ response = qtest_qmp_receive(s);
+ if ((qdict_haskey(response, "event")) &&
+ (strcmp(qdict_get_str(response, "event"), event) == 0)) {
+ QDECREF(response);
+ break;
+ }
+ QDECREF(response);
+ }
+}
+
+
const char *qtest_get_arch(void)
{
const char *qemu = getenv("QTEST_QEMU_BINARY");
diff --git a/tests/libqtest.h b/tests/libqtest.h
index e7413d5..2aa2e6f 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -92,6 +92,15 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list
ap);
QDict *qtest_qmp_receive(QTestState *s);
/**
+ * qtest_qmp_eventwait:
+ * @s: #QTestState instance to operate on.
+ * @s: #event event to wait for.
+ *
+ * Continuosly polls for QMP responses until it receives the desired event.
+ */
+void qtest_qmp_eventwait(QTestState *s, const char *event);
+
+/**
* qtest_get_irq:
* @s: #QTestState instance to operate on.
* @num: Interrupt to observe.
@@ -397,6 +406,17 @@ static inline QDict *qmp_receive(void)
}
/**
+ * qmp_eventwait:
+ * @s: #event event to wait for.
+ *
+ * Continuosly polls for QMP responses until it receives the desired event.
+ */
+static inline void qmp_eventwait(const char *event)
+{
+ return qtest_qmp_eventwait(global_qtest, event);
+}
+
+/**
* get_irq:
* @num: Interrupt to observe.
*
--
2.1.0
- [Qemu-devel] [PULL 52/69] qtest/ide: Test flush / retry for ISA and PCI, (continued)
- [Qemu-devel] [PULL 52/69] qtest/ide: Test flush / retry for ISA and PCI, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 56/69] qtest/ahci: Add DMA test variants, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 54/69] qtest/ahci: Add a macro bootup routine, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 58/69] qtest/ahci: add fragmented dma test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 55/69] libqos/ahci: add ahci command helpers, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 57/69] qtest/ahci: Add PIO and LBA48 tests, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 59/69] qtest/ahci: add qcow2 support to ahci-test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 61/69] qtest/ahci: Add simple flush test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 62/69] qtest/ahci: Allow override of default CLI options, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 60/69] qtest/ahci: test different disk sectors, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 63/69] libqtest: add qmp_eventwait,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 64/69] libqtest: add qmp_async, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 65/69] libqos: add blkdebug_prepare_script, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 66/69] qtest/ahci: add flush retry test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 69/69] tests: Check QVIRTIO_F_ANY_LAYOUT flag in virtio-blk test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 68/69] libqos: Solve bug in interrupt checking when using MSIX in virtio-pci.c, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 67/69] sheepdog: fix confused return values, Stefan Hajnoczi, 2015/02/27
- Re: [Qemu-devel] [PULL 00/69] Block patches, Stefan Hajnoczi, 2015/02/27