Maintaining two layers of libqtest APIs, one that takes an explicit
QTestState object, and the other that uses the implicit global_qtest,
is annoying. In the interest of getting rid of global implicit
state and having less code to maintain, merge:
qtest_get_irq()
qtest_irq_intercept_in()
qtest_irq_intercept_out()
with their short counterparts. All callers that previously
used the short form now make it explicit that they are relying on
global_qtest, and later patches can then clean things up to remove
the global variable.
Signed-off-by: Eric Blake
---
tests/libqtest.h | 47 ++-
tests/libqtest.c | 6 +++---
tests/fdc-test.c | 48
tests/ide-test.c | 17 +
tests/ipmi-bt-test.c | 6 +++---
tests/ipmi-kcs-test.c| 8
tests/libqos/libqos-pc.c | 2 +-
tests/rtc-test.c | 10 +-
tests/tco-test.c | 2 +-
tests/wdt_ib700-test.c | 8
10 files changed, 60 insertions(+), 94 deletions(-)
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 26d5f37bc9..8398c0fd07 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -176,33 +176,33 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap);
/**
- * qtest_get_irq:
+ * get_irq:
* @s: #QTestState instance to operate on.
* @num: Interrupt to observe.
*
* Returns: The level of the @num interrupt.
*/
-bool qtest_get_irq(QTestState *s, int num);
+bool get_irq(QTestState *s, int num);
/**
- * qtest_irq_intercept_in:
+ * irq_intercept_in:
* @s: #QTestState instance to operate on.
* @string: QOM path of a device.
*
* Associate qtest irqs with the GPIO-in pins of the device
* whose path is specified by @string.
*/
-void qtest_irq_intercept_in(QTestState *s, const char *string);
+void irq_intercept_in(QTestState *s, const char *string);
/**
- * qtest_irq_intercept_out:
+ * irq_intercept_out:
* @s: #QTestState instance to operate on.
* @string: QOM path of a device.
*
* Associate qtest irqs with the GPIO-out pins of the device
* whose path is specified by @string.
*/
-void qtest_irq_intercept_out(QTestState *s, const char *string);
+void irq_intercept_out(QTestState *s, const char *string);
/**
* qtest_outb:
@@ -594,41 +594,6 @@ static inline QDict *qmp_eventwait_ref(const char *event)
char *hmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
/**
- * get_irq:
- * @num: Interrupt to observe.
- *
- * Returns: The level of the @num interrupt.
- */
-static inline bool get_irq(int num)
-{
-return qtest_get_irq(global_qtest, num);
-}
-
-/**
- * irq_intercept_in:
- * @string: QOM path of a device.
- *
- * Associate qtest irqs with the GPIO-in pins of the device
- * whose path is specified by @string.
- */
-static inline void irq_intercept_in(const char *string)
-{
-qtest_irq_intercept_in(global_qtest, string);
-}
-
-/**
- * qtest_irq_intercept_out:
- * @string: QOM path of a device.
- *
- * Associate qtest irqs with the GPIO-out pins of the device
- * whose path is specified by @string.
- */
-static inline void irq_intercept_out(const char *string)
-{
-qtest_irq_intercept_out(global_qtest, string);
-}
-
-/**
* outb:
* @addr: I/O port to write to.
* @value: Value being written.
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 9f5f2cb933..962432a27a 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -648,7 +648,7 @@ const char *qtest_get_arch(void)
return end + strlen("/qemu-system-");
}
-bool qtest_get_irq(QTestState *s, int num)
+bool get_irq(QTestState *s, int num)
{
/* dummy operation in order to make sure irq is up to date */
qtest_inb(s, 0);
@@ -684,13 +684,13 @@ int64_t clock_set(QTestState *s, int64_t val)
return qtest_clock_rsp(s);
}
-void qtest_irq_intercept_out(QTestState *s, const char *qom_path)
+void irq_intercept_out(QTestState *s, const char *qom_path)
{
qtest_sendf(s, "irq_intercept_out %s\n", qom_path);
qtest_rsp(s, 0);
}
-void qtest_irq_intercept_in(QTestState *s, const char *qom_path)
+void irq_intercept_in(QTestState *s, const char *qom_path)
{
qtest_sendf(s, "irq_intercept_in %s\n", qom_path);
qtest_rsp(s, 0);
diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index e79cd0f3b5..584ad746ed 100644
--- a/tests/fdc-test.c
+++ b/tests/fdc-test.c
@@ -99,7 +99,7 @@ static void ack_irq(uint8_t *pcn)
{
uint8_t ret;
-g_assert(get_irq(FLOPPY_IRQ));
+g_assert(get_irq(global_qtest, FLOPPY_IRQ));
floppy_send(CMD_SENSE_INT);
floppy_recv();
@@ -108,7 +108,7 @@ static void ack_irq(uint8_t *pcn)
*pcn = ret;
}
-g_assert(!get_irq(FLOPPY_IRQ));
+g_assert(!get_irq(global_qtest, FLOPPY_IRQ));
}
static uint8_t send_read_command(uint8_t cmd)
@@ -129,7 +129,7 @@ static uint8_t send_read_command(uint8_t cmd)