xref: /qemu/tests/qtest/libqtest.h (revision 188052a13377ff1f88b433255005eb9082d048e5)
149ee3590SAnthony Liguori /*
249ee3590SAnthony Liguori  * QTest
349ee3590SAnthony Liguori  *
449ee3590SAnthony Liguori  * Copyright IBM, Corp. 2012
549ee3590SAnthony Liguori  * Copyright Red Hat, Inc. 2012
6872536bfSAndreas Färber  * Copyright SUSE LINUX Products GmbH 2013
749ee3590SAnthony Liguori  *
849ee3590SAnthony Liguori  * Authors:
949ee3590SAnthony Liguori  *  Anthony Liguori   <aliguori@us.ibm.com>
1049ee3590SAnthony Liguori  *  Paolo Bonzini     <pbonzini@redhat.com>
11872536bfSAndreas Färber  *  Andreas Färber    <afaerber@suse.de>
1249ee3590SAnthony Liguori  *
1349ee3590SAnthony Liguori  * This work is licensed under the terms of the GNU GPL, version 2 or later.
1449ee3590SAnthony Liguori  * See the COPYING file in the top-level directory.
1549ee3590SAnthony Liguori  *
1649ee3590SAnthony Liguori  */
1749ee3590SAnthony Liguori #ifndef LIBQTEST_H
1849ee3590SAnthony Liguori #define LIBQTEST_H
1949ee3590SAnthony Liguori 
205cb8f0dbSPaolo Bonzini #include "qapi/qmp/qobject.h"
215cb8f0dbSPaolo Bonzini #include "qapi/qmp/qdict.h"
22c6d3bcb4SMarc-André Lureau #include "libqmp.h"
235cb8f0dbSPaolo Bonzini 
2449ee3590SAnthony Liguori typedef struct QTestState QTestState;
2549ee3590SAnthony Liguori 
2649ee3590SAnthony Liguori /**
2788b988c8SMarkus Armbruster  * qtest_initf:
2851c778edSEduardo Habkost  * @fmt: Format for creating other arguments to pass to QEMU, formatted
2978b27badSEric Blake  * like sprintf().
3078b27badSEric Blake  *
3100825d96SThomas Huth  * Convenience wrapper around qtest_init().
3278b27badSEric Blake  *
3378b27badSEric Blake  * Returns: #QTestState instance.
3478b27badSEric Blake  */
359edc6313SMarc-André Lureau QTestState *qtest_initf(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
3678b27badSEric Blake 
3778b27badSEric Blake /**
3888b988c8SMarkus Armbruster  * qtest_vinitf:
3978b27badSEric Blake  * @fmt: Format for creating other arguments to pass to QEMU, formatted
4078b27badSEric Blake  * like vsprintf().
4178b27badSEric Blake  * @ap: Format arguments.
4278b27badSEric Blake  *
4300825d96SThomas Huth  * Convenience wrapper around qtest_init().
4478b27badSEric Blake  *
4578b27badSEric Blake  * Returns: #QTestState instance.
4678b27badSEric Blake  */
479edc6313SMarc-André Lureau QTestState *qtest_vinitf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
4878b27badSEric Blake 
4978b27badSEric Blake /**
5049ee3590SAnthony Liguori  * qtest_init:
5188b988c8SMarkus Armbruster  * @extra_args: other arguments to pass to QEMU.  CAUTION: these
5288b988c8SMarkus Armbruster  * arguments are subject to word splitting and shell evaluation.
536acf801dSAndreas Färber  *
546acf801dSAndreas Färber  * Returns: #QTestState instance.
5549ee3590SAnthony Liguori  */
5649ee3590SAnthony Liguori QTestState *qtest_init(const char *extra_args);
5749ee3590SAnthony Liguori 
5849ee3590SAnthony Liguori /**
59f66e7ac8SMarkus Armbruster  * qtest_init_without_qmp_handshake:
60ddee57e0SEric Blake  * @extra_args: other arguments to pass to QEMU.  CAUTION: these
61ddee57e0SEric Blake  * arguments are subject to word splitting and shell evaluation.
62f66e7ac8SMarkus Armbruster  *
63f66e7ac8SMarkus Armbruster  * Returns: #QTestState instance.
64f66e7ac8SMarkus Armbruster  */
65192f26a7SPeter Xu QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
66f66e7ac8SMarkus Armbruster 
67f66e7ac8SMarkus Armbruster /**
686c90a82cSJulia Suvorova  * qtest_init_with_serial:
696c90a82cSJulia Suvorova  * @extra_args: other arguments to pass to QEMU.  CAUTION: these
706c90a82cSJulia Suvorova  * arguments are subject to word splitting and shell evaluation.
716c90a82cSJulia Suvorova  * @sock_fd: pointer to store the socket file descriptor for
726c90a82cSJulia Suvorova  * connection with serial.
736c90a82cSJulia Suvorova  *
746c90a82cSJulia Suvorova  * Returns: #QTestState instance.
756c90a82cSJulia Suvorova  */
766c90a82cSJulia Suvorova QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
776c90a82cSJulia Suvorova 
786c90a82cSJulia Suvorova /**
797a23c523SStefan Hajnoczi  * qtest_kill_qemu:
807a23c523SStefan Hajnoczi  * @s: #QTestState instance to operate on.
817a23c523SStefan Hajnoczi  *
827a23c523SStefan Hajnoczi  * Kill the QEMU process and wait for it to terminate. It is safe to call this
837a23c523SStefan Hajnoczi  * function multiple times. Normally qtest_quit() is used instead because it
847a23c523SStefan Hajnoczi  * also frees QTestState. Use qtest_kill_qemu() when you just want to kill QEMU
857a23c523SStefan Hajnoczi  * and qtest_quit() will be called later.
867a23c523SStefan Hajnoczi  */
877a23c523SStefan Hajnoczi void qtest_kill_qemu(QTestState *s);
887a23c523SStefan Hajnoczi 
897a23c523SStefan Hajnoczi /**
9049ee3590SAnthony Liguori  * qtest_quit:
916acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
9249ee3590SAnthony Liguori  *
9349ee3590SAnthony Liguori  * Shut down the QEMU process associated to @s.
9449ee3590SAnthony Liguori  */
9549ee3590SAnthony Liguori void qtest_quit(QTestState *s);
9649ee3590SAnthony Liguori 
9749ee3590SAnthony Liguori /**
9824d5588cSYury Kotov  * qtest_qmp_fds:
9924d5588cSYury Kotov  * @s: #QTestState instance to operate on.
10024d5588cSYury Kotov  * @fds: array of file descriptors
10124d5588cSYury Kotov  * @fds_num: number of elements in @fds
10251c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
103ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
10424d5588cSYury Kotov  * supported after '%'.
10524d5588cSYury Kotov  *
10624d5588cSYury Kotov  * Sends a QMP message to QEMU with fds and returns the response.
10724d5588cSYury Kotov  */
10824d5588cSYury Kotov QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num,
10924d5588cSYury Kotov                      const char *fmt, ...)
1109edc6313SMarc-André Lureau     G_GNUC_PRINTF(4, 5);
11124d5588cSYury Kotov 
11224d5588cSYury Kotov /**
1130c460dacSStefan Hajnoczi  * qtest_qmp:
1140c460dacSStefan Hajnoczi  * @s: #QTestState instance to operate on.
11551c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
116ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
1176ce80fd8SMarkus Armbruster  * supported after '%'.
1180c460dacSStefan Hajnoczi  *
1190c460dacSStefan Hajnoczi  * Sends a QMP message to QEMU and returns the response.
1200c460dacSStefan Hajnoczi  */
121e3dc93beSMarkus Armbruster QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
1229edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
1230c460dacSStefan Hajnoczi 
1240c460dacSStefan Hajnoczi /**
1254277f1ebSMarkus Armbruster  * qtest_qmp_send:
126ba4ed393SJohn Snow  * @s: #QTestState instance to operate on.
12751c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
128ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
1296ce80fd8SMarkus Armbruster  * supported after '%'.
130ba4ed393SJohn Snow  *
131ba4ed393SJohn Snow  * Sends a QMP message to QEMU and leaves the response in the stream.
132ba4ed393SJohn Snow  */
133e3dc93beSMarkus Armbruster void qtest_qmp_send(QTestState *s, const char *fmt, ...)
1349edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
135ba4ed393SJohn Snow 
136ba4ed393SJohn Snow /**
137aed877c5SMarkus Armbruster  * qtest_qmp_send_raw:
138aed877c5SMarkus Armbruster  * @s: #QTestState instance to operate on.
13951c778edSEduardo Habkost  * @fmt: text to send, formatted like sprintf()
140aed877c5SMarkus Armbruster  *
141aed877c5SMarkus Armbruster  * Sends text to the QMP monitor verbatim.  Need not be valid JSON;
142aed877c5SMarkus Armbruster  * this is useful for negative tests.
143aed877c5SMarkus Armbruster  */
144aed877c5SMarkus Armbruster void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
1459edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
146aed877c5SMarkus Armbruster 
147aed877c5SMarkus Armbruster /**
1489fb7bb06SStefan Hajnoczi  * qtest_socket_server:
1499fb7bb06SStefan Hajnoczi  * @socket_path: the UNIX domain socket path
1509fb7bb06SStefan Hajnoczi  *
1519fb7bb06SStefan Hajnoczi  * Create and return a listen socket file descriptor, or abort on failure.
1529fb7bb06SStefan Hajnoczi  */
1539fb7bb06SStefan Hajnoczi int qtest_socket_server(const char *socket_path);
1549fb7bb06SStefan Hajnoczi 
1559fb7bb06SStefan Hajnoczi /**
15624d5588cSYury Kotov  * qtest_vqmp_fds:
15724d5588cSYury Kotov  * @s: #QTestState instance to operate on.
15824d5588cSYury Kotov  * @fds: array of file descriptors
15924d5588cSYury Kotov  * @fds_num: number of elements in @fds
16024d5588cSYury Kotov  * @fmt: QMP message to send to QEMU, formatted like
161ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
16224d5588cSYury Kotov  * supported after '%'.
16324d5588cSYury Kotov  * @ap: QMP message arguments
16424d5588cSYury Kotov  *
16524d5588cSYury Kotov  * Sends a QMP message to QEMU with fds and returns the response.
16624d5588cSYury Kotov  */
16724d5588cSYury Kotov QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,
16824d5588cSYury Kotov                       const char *fmt, va_list ap)
1699edc6313SMarc-André Lureau     G_GNUC_PRINTF(4, 0);
17024d5588cSYury Kotov 
17124d5588cSYury Kotov /**
17224d5588cSYury Kotov  * qtest_vqmp:
1730c460dacSStefan Hajnoczi  * @s: #QTestState instance to operate on.
174bb340eb2SEric Blake  * @fmt: QMP message to send to QEMU, formatted like
175ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
1766ce80fd8SMarkus Armbruster  * supported after '%'.
1770c460dacSStefan Hajnoczi  * @ap: QMP message arguments
1780c460dacSStefan Hajnoczi  *
1790c460dacSStefan Hajnoczi  * Sends a QMP message to QEMU and returns the response.
1800c460dacSStefan Hajnoczi  */
181248eef02SMarkus Armbruster QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
1829edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 0);
1830c460dacSStefan Hajnoczi 
1840c460dacSStefan Hajnoczi /**
18524d5588cSYury Kotov  * qtest_qmp_vsend_fds:
18624d5588cSYury Kotov  * @s: #QTestState instance to operate on.
18724d5588cSYury Kotov  * @fds: array of file descriptors
18824d5588cSYury Kotov  * @fds_num: number of elements in @fds
18924d5588cSYury Kotov  * @fmt: QMP message to send to QEMU, formatted like
190ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
19124d5588cSYury Kotov  * supported after '%'.
19224d5588cSYury Kotov  * @ap: QMP message arguments
19324d5588cSYury Kotov  *
19424d5588cSYury Kotov  * Sends a QMP message to QEMU and leaves the response in the stream.
19524d5588cSYury Kotov  */
19624d5588cSYury Kotov void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num,
19724d5588cSYury Kotov                          const char *fmt, va_list ap)
1989edc6313SMarc-André Lureau     G_GNUC_PRINTF(4, 0);
19924d5588cSYury Kotov 
20024d5588cSYury Kotov /**
2014277f1ebSMarkus Armbruster  * qtest_qmp_vsend:
202ba4ed393SJohn Snow  * @s: #QTestState instance to operate on.
203bb340eb2SEric Blake  * @fmt: QMP message to send to QEMU, formatted like
204ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
2056ce80fd8SMarkus Armbruster  * supported after '%'.
206ba4ed393SJohn Snow  * @ap: QMP message arguments
207ba4ed393SJohn Snow  *
208ba4ed393SJohn Snow  * Sends a QMP message to QEMU and leaves the response in the stream.
209ba4ed393SJohn Snow  */
210e3dc93beSMarkus Armbruster void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
2119edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 0);
212ba4ed393SJohn Snow 
213ba4ed393SJohn Snow /**
2141c3e2a38SMaxim Levitsky  * qtest_qmp_receive_dict:
21566e0c7b1SAndreas Färber  * @s: #QTestState instance to operate on.
21666e0c7b1SAndreas Färber  *
21766e0c7b1SAndreas Färber  * Reads a QMP message from QEMU and returns the response.
21866e0c7b1SAndreas Färber  */
2191c3e2a38SMaxim Levitsky QDict *qtest_qmp_receive_dict(QTestState *s);
22066e0c7b1SAndreas Färber 
22166e0c7b1SAndreas Färber /**
222c22045bfSMaxim Levitsky  * qtest_qmp_receive:
223c22045bfSMaxim Levitsky  * @s: #QTestState instance to operate on.
224c22045bfSMaxim Levitsky  *
225c22045bfSMaxim Levitsky  * Reads a QMP message from QEMU and returns the response.
226c22045bfSMaxim Levitsky  * Buffers all the events received meanwhile, until a
227c22045bfSMaxim Levitsky  * call to qtest_qmp_eventwait
228c22045bfSMaxim Levitsky  */
229c22045bfSMaxim Levitsky QDict *qtest_qmp_receive(QTestState *s);
230c22045bfSMaxim Levitsky 
231c22045bfSMaxim Levitsky /**
2328fe941f7SJohn Snow  * qtest_qmp_eventwait:
2338fe941f7SJohn Snow  * @s: #QTestState instance to operate on.
23451c778edSEduardo Habkost  * @event: event to wait for.
2358fe941f7SJohn Snow  *
236e8ec0117SEric Blake  * Continuously polls for QMP responses until it receives the desired event.
2378fe941f7SJohn Snow  */
2388fe941f7SJohn Snow void qtest_qmp_eventwait(QTestState *s, const char *event);
2398fe941f7SJohn Snow 
2408fe941f7SJohn Snow /**
2417ffe3124SJohn Snow  * qtest_qmp_eventwait_ref:
2427ffe3124SJohn Snow  * @s: #QTestState instance to operate on.
24351c778edSEduardo Habkost  * @event: event to wait for.
2447ffe3124SJohn Snow  *
245e8ec0117SEric Blake  * Continuously polls for QMP responses until it receives the desired event.
2467ffe3124SJohn Snow  * Returns a copy of the event for further investigation.
2477ffe3124SJohn Snow  */
2487ffe3124SJohn Snow QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);
2497ffe3124SJohn Snow 
2507ffe3124SJohn Snow /**
251c22045bfSMaxim Levitsky  * qtest_qmp_event_ref:
252c22045bfSMaxim Levitsky  * @s: #QTestState instance to operate on.
253c22045bfSMaxim Levitsky  * @event: event to return.
254c22045bfSMaxim Levitsky  *
255c22045bfSMaxim Levitsky  * Removes non-matching events from the buffer that was set by
256c22045bfSMaxim Levitsky  * qtest_qmp_receive, until an event bearing the given name is found,
257c22045bfSMaxim Levitsky  * and returns it.
258c22045bfSMaxim Levitsky  * If no event matches, clears the buffer and returns NULL.
259c22045bfSMaxim Levitsky  *
260c22045bfSMaxim Levitsky  */
261c22045bfSMaxim Levitsky QDict *qtest_qmp_event_ref(QTestState *s, const char *event);
262c22045bfSMaxim Levitsky 
263c22045bfSMaxim Levitsky /**
2646bb87be8SThomas Huth  * qtest_hmp:
2655fb48d96SMarkus Armbruster  * @s: #QTestState instance to operate on.
26651c778edSEduardo Habkost  * @fmt: HMP command to send to QEMU, formats arguments like sprintf().
2675fb48d96SMarkus Armbruster  *
2685fb48d96SMarkus Armbruster  * Send HMP command to QEMU via QMP's human-monitor-command.
2696bb87be8SThomas Huth  * QMP events are discarded.
2705fb48d96SMarkus Armbruster  *
2715fb48d96SMarkus Armbruster  * Returns: the command's output.  The caller should g_free() it.
2725fb48d96SMarkus Armbruster  */
2739edc6313SMarc-André Lureau char *qtest_hmp(QTestState *s, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
2745fb48d96SMarkus Armbruster 
2755fb48d96SMarkus Armbruster /**
2765fb48d96SMarkus Armbruster  * qtest_hmpv:
2775fb48d96SMarkus Armbruster  * @s: #QTestState instance to operate on.
278bb340eb2SEric Blake  * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
2795fb48d96SMarkus Armbruster  * @ap: HMP command arguments
2805fb48d96SMarkus Armbruster  *
2815fb48d96SMarkus Armbruster  * Send HMP command to QEMU via QMP's human-monitor-command.
2826bb87be8SThomas Huth  * QMP events are discarded.
2835fb48d96SMarkus Armbruster  *
2845fb48d96SMarkus Armbruster  * Returns: the command's output.  The caller should g_free() it.
2855fb48d96SMarkus Armbruster  */
286248eef02SMarkus Armbruster char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)
2879edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 0);
2885fb48d96SMarkus Armbruster 
289eb062cfaSMarc-André Lureau void qtest_module_load(QTestState *s, const char *prefix, const char *libname);
290eb062cfaSMarc-André Lureau 
2915fb48d96SMarkus Armbruster /**
29249ee3590SAnthony Liguori  * qtest_get_irq:
2936acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
29449ee3590SAnthony Liguori  * @num: Interrupt to observe.
29549ee3590SAnthony Liguori  *
2966acf801dSAndreas Färber  * Returns: The level of the @num interrupt.
29749ee3590SAnthony Liguori  */
29849ee3590SAnthony Liguori bool qtest_get_irq(QTestState *s, int num);
29949ee3590SAnthony Liguori 
30049ee3590SAnthony Liguori /**
30149ee3590SAnthony Liguori  * qtest_irq_intercept_in:
3026acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
30349ee3590SAnthony Liguori  * @string: QOM path of a device.
30449ee3590SAnthony Liguori  *
30549ee3590SAnthony Liguori  * Associate qtest irqs with the GPIO-in pins of the device
30649ee3590SAnthony Liguori  * whose path is specified by @string.
30749ee3590SAnthony Liguori  */
30849ee3590SAnthony Liguori void qtest_irq_intercept_in(QTestState *s, const char *string);
30949ee3590SAnthony Liguori 
31049ee3590SAnthony Liguori /**
31149ee3590SAnthony Liguori  * qtest_irq_intercept_out:
3126acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
31349ee3590SAnthony Liguori  * @string: QOM path of a device.
31449ee3590SAnthony Liguori  *
31549ee3590SAnthony Liguori  * Associate qtest irqs with the GPIO-out pins of the device
31649ee3590SAnthony Liguori  * whose path is specified by @string.
31749ee3590SAnthony Liguori  */
31849ee3590SAnthony Liguori void qtest_irq_intercept_out(QTestState *s, const char *string);
31949ee3590SAnthony Liguori 
32049ee3590SAnthony Liguori /**
3219813dc6aSSteffen Görtz  * qtest_set_irq_in:
3229813dc6aSSteffen Görtz  * @s: QTestState instance to operate on.
3239813dc6aSSteffen Görtz  * @string: QOM path of a device
3249813dc6aSSteffen Görtz  * @name: IRQ name
3259813dc6aSSteffen Görtz  * @irq: IRQ number
3269813dc6aSSteffen Görtz  * @level: IRQ level
3279813dc6aSSteffen Görtz  *
3289813dc6aSSteffen Görtz  * Force given device/irq GPIO-in pin to the given level.
3299813dc6aSSteffen Görtz  */
3309813dc6aSSteffen Görtz void qtest_set_irq_in(QTestState *s, const char *string, const char *name,
3319813dc6aSSteffen Görtz                       int irq, int level);
3329813dc6aSSteffen Görtz 
3339813dc6aSSteffen Görtz /**
33449ee3590SAnthony Liguori  * qtest_outb:
3356acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
33649ee3590SAnthony Liguori  * @addr: I/O port to write to.
33749ee3590SAnthony Liguori  * @value: Value being written.
33849ee3590SAnthony Liguori  *
33949ee3590SAnthony Liguori  * Write an 8-bit value to an I/O port.
34049ee3590SAnthony Liguori  */
34149ee3590SAnthony Liguori void qtest_outb(QTestState *s, uint16_t addr, uint8_t value);
34249ee3590SAnthony Liguori 
34349ee3590SAnthony Liguori /**
34449ee3590SAnthony Liguori  * qtest_outw:
3456acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
34649ee3590SAnthony Liguori  * @addr: I/O port to write to.
34749ee3590SAnthony Liguori  * @value: Value being written.
34849ee3590SAnthony Liguori  *
34949ee3590SAnthony Liguori  * Write a 16-bit value to an I/O port.
35049ee3590SAnthony Liguori  */
35149ee3590SAnthony Liguori void qtest_outw(QTestState *s, uint16_t addr, uint16_t value);
35249ee3590SAnthony Liguori 
35349ee3590SAnthony Liguori /**
35449ee3590SAnthony Liguori  * qtest_outl:
3556acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
35649ee3590SAnthony Liguori  * @addr: I/O port to write to.
35749ee3590SAnthony Liguori  * @value: Value being written.
35849ee3590SAnthony Liguori  *
35949ee3590SAnthony Liguori  * Write a 32-bit value to an I/O port.
36049ee3590SAnthony Liguori  */
36149ee3590SAnthony Liguori void qtest_outl(QTestState *s, uint16_t addr, uint32_t value);
36249ee3590SAnthony Liguori 
36349ee3590SAnthony Liguori /**
36449ee3590SAnthony Liguori  * qtest_inb:
3656acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
36649ee3590SAnthony Liguori  * @addr: I/O port to read from.
36749ee3590SAnthony Liguori  *
36849ee3590SAnthony Liguori  * Returns an 8-bit value from an I/O port.
36949ee3590SAnthony Liguori  */
37049ee3590SAnthony Liguori uint8_t qtest_inb(QTestState *s, uint16_t addr);
37149ee3590SAnthony Liguori 
37249ee3590SAnthony Liguori /**
37349ee3590SAnthony Liguori  * qtest_inw:
3746acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
37549ee3590SAnthony Liguori  * @addr: I/O port to read from.
37649ee3590SAnthony Liguori  *
37749ee3590SAnthony Liguori  * Returns a 16-bit value from an I/O port.
37849ee3590SAnthony Liguori  */
37949ee3590SAnthony Liguori uint16_t qtest_inw(QTestState *s, uint16_t addr);
38049ee3590SAnthony Liguori 
38149ee3590SAnthony Liguori /**
38249ee3590SAnthony Liguori  * qtest_inl:
3836acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
38449ee3590SAnthony Liguori  * @addr: I/O port to read from.
38549ee3590SAnthony Liguori  *
38649ee3590SAnthony Liguori  * Returns a 32-bit value from an I/O port.
38749ee3590SAnthony Liguori  */
38849ee3590SAnthony Liguori uint32_t qtest_inl(QTestState *s, uint16_t addr);
38949ee3590SAnthony Liguori 
39049ee3590SAnthony Liguori /**
391872536bfSAndreas Färber  * qtest_writeb:
392872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
393872536bfSAndreas Färber  * @addr: Guest address to write to.
394872536bfSAndreas Färber  * @value: Value being written.
395872536bfSAndreas Färber  *
396872536bfSAndreas Färber  * Writes an 8-bit value to memory.
397872536bfSAndreas Färber  */
398872536bfSAndreas Färber void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value);
399872536bfSAndreas Färber 
400872536bfSAndreas Färber /**
401872536bfSAndreas Färber  * qtest_writew:
402872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
403872536bfSAndreas Färber  * @addr: Guest address to write to.
404872536bfSAndreas Färber  * @value: Value being written.
405872536bfSAndreas Färber  *
406872536bfSAndreas Färber  * Writes a 16-bit value to memory.
407872536bfSAndreas Färber  */
408872536bfSAndreas Färber void qtest_writew(QTestState *s, uint64_t addr, uint16_t value);
409872536bfSAndreas Färber 
410872536bfSAndreas Färber /**
411872536bfSAndreas Färber  * qtest_writel:
412872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
413872536bfSAndreas Färber  * @addr: Guest address to write to.
414872536bfSAndreas Färber  * @value: Value being written.
415872536bfSAndreas Färber  *
416872536bfSAndreas Färber  * Writes a 32-bit value to memory.
417872536bfSAndreas Färber  */
418872536bfSAndreas Färber void qtest_writel(QTestState *s, uint64_t addr, uint32_t value);
419872536bfSAndreas Färber 
420872536bfSAndreas Färber /**
421872536bfSAndreas Färber  * qtest_writeq:
422872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
423872536bfSAndreas Färber  * @addr: Guest address to write to.
424872536bfSAndreas Färber  * @value: Value being written.
425872536bfSAndreas Färber  *
426872536bfSAndreas Färber  * Writes a 64-bit value to memory.
427872536bfSAndreas Färber  */
428872536bfSAndreas Färber void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value);
429872536bfSAndreas Färber 
430872536bfSAndreas Färber /**
431872536bfSAndreas Färber  * qtest_readb:
432872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
433872536bfSAndreas Färber  * @addr: Guest address to read from.
434872536bfSAndreas Färber  *
435872536bfSAndreas Färber  * Reads an 8-bit value from memory.
436872536bfSAndreas Färber  *
437872536bfSAndreas Färber  * Returns: Value read.
438872536bfSAndreas Färber  */
439872536bfSAndreas Färber uint8_t qtest_readb(QTestState *s, uint64_t addr);
440872536bfSAndreas Färber 
441872536bfSAndreas Färber /**
442872536bfSAndreas Färber  * qtest_readw:
443872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
444872536bfSAndreas Färber  * @addr: Guest address to read from.
445872536bfSAndreas Färber  *
446872536bfSAndreas Färber  * Reads a 16-bit value from memory.
447872536bfSAndreas Färber  *
448872536bfSAndreas Färber  * Returns: Value read.
449872536bfSAndreas Färber  */
450872536bfSAndreas Färber uint16_t qtest_readw(QTestState *s, uint64_t addr);
451872536bfSAndreas Färber 
452872536bfSAndreas Färber /**
453872536bfSAndreas Färber  * qtest_readl:
454872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
455872536bfSAndreas Färber  * @addr: Guest address to read from.
456872536bfSAndreas Färber  *
457872536bfSAndreas Färber  * Reads a 32-bit value from memory.
458872536bfSAndreas Färber  *
459872536bfSAndreas Färber  * Returns: Value read.
460872536bfSAndreas Färber  */
461872536bfSAndreas Färber uint32_t qtest_readl(QTestState *s, uint64_t addr);
462872536bfSAndreas Färber 
463872536bfSAndreas Färber /**
464872536bfSAndreas Färber  * qtest_readq:
465872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
466872536bfSAndreas Färber  * @addr: Guest address to read from.
467872536bfSAndreas Färber  *
468872536bfSAndreas Färber  * Reads a 64-bit value from memory.
469872536bfSAndreas Färber  *
470872536bfSAndreas Färber  * Returns: Value read.
471872536bfSAndreas Färber  */
472872536bfSAndreas Färber uint64_t qtest_readq(QTestState *s, uint64_t addr);
473872536bfSAndreas Färber 
474872536bfSAndreas Färber /**
47549ee3590SAnthony Liguori  * qtest_memread:
4766acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
47749ee3590SAnthony Liguori  * @addr: Guest address to read from.
47849ee3590SAnthony Liguori  * @data: Pointer to where memory contents will be stored.
47949ee3590SAnthony Liguori  * @size: Number of bytes to read.
48049ee3590SAnthony Liguori  *
48149ee3590SAnthony Liguori  * Read guest memory into a buffer.
48249ee3590SAnthony Liguori  */
48349ee3590SAnthony Liguori void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size);
48449ee3590SAnthony Liguori 
48549ee3590SAnthony Liguori /**
486eeddd59fSLaurent Vivier  * qtest_rtas_call:
487eeddd59fSLaurent Vivier  * @s: #QTestState instance to operate on.
488eeddd59fSLaurent Vivier  * @name: name of the command to call.
489eeddd59fSLaurent Vivier  * @nargs: Number of args.
490eeddd59fSLaurent Vivier  * @args: Guest address to read args from.
491eeddd59fSLaurent Vivier  * @nret: Number of return value.
492eeddd59fSLaurent Vivier  * @ret: Guest address to write return values to.
493eeddd59fSLaurent Vivier  *
494eeddd59fSLaurent Vivier  * Call an RTAS function
495eeddd59fSLaurent Vivier  */
496eeddd59fSLaurent Vivier uint64_t qtest_rtas_call(QTestState *s, const char *name,
497eeddd59fSLaurent Vivier                          uint32_t nargs, uint64_t args,
498eeddd59fSLaurent Vivier                          uint32_t nret, uint64_t ret);
499eeddd59fSLaurent Vivier 
500eeddd59fSLaurent Vivier /**
5017a6a740dSJohn Snow  * qtest_bufread:
5027a6a740dSJohn Snow  * @s: #QTestState instance to operate on.
5037a6a740dSJohn Snow  * @addr: Guest address to read from.
5047a6a740dSJohn Snow  * @data: Pointer to where memory contents will be stored.
5057a6a740dSJohn Snow  * @size: Number of bytes to read.
5067a6a740dSJohn Snow  *
5077a6a740dSJohn Snow  * Read guest memory into a buffer and receive using a base64 encoding.
5087a6a740dSJohn Snow  */
5097a6a740dSJohn Snow void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size);
5107a6a740dSJohn Snow 
5117a6a740dSJohn Snow /**
51249ee3590SAnthony Liguori  * qtest_memwrite:
5136acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
51449ee3590SAnthony Liguori  * @addr: Guest address to write to.
51549ee3590SAnthony Liguori  * @data: Pointer to the bytes that will be written to guest memory.
51649ee3590SAnthony Liguori  * @size: Number of bytes to write.
51749ee3590SAnthony Liguori  *
51849ee3590SAnthony Liguori  * Write a buffer to guest memory.
51949ee3590SAnthony Liguori  */
52049ee3590SAnthony Liguori void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size);
52149ee3590SAnthony Liguori 
52249ee3590SAnthony Liguori /**
5237a6a740dSJohn Snow  * qtest_bufwrite:
5247a6a740dSJohn Snow  * @s: #QTestState instance to operate on.
5257a6a740dSJohn Snow  * @addr: Guest address to write to.
5267a6a740dSJohn Snow  * @data: Pointer to the bytes that will be written to guest memory.
5277a6a740dSJohn Snow  * @size: Number of bytes to write.
5287a6a740dSJohn Snow  *
5297a6a740dSJohn Snow  * Write a buffer to guest memory and transmit using a base64 encoding.
5307a6a740dSJohn Snow  */
5317a6a740dSJohn Snow void qtest_bufwrite(QTestState *s, uint64_t addr,
5327a6a740dSJohn Snow                     const void *data, size_t size);
5337a6a740dSJohn Snow 
5347a6a740dSJohn Snow /**
53586298845SJohn Snow  * qtest_memset:
53686298845SJohn Snow  * @s: #QTestState instance to operate on.
53786298845SJohn Snow  * @addr: Guest address to write to.
53886298845SJohn Snow  * @patt: Byte pattern to fill the guest memory region with.
53986298845SJohn Snow  * @size: Number of bytes to write.
54086298845SJohn Snow  *
54186298845SJohn Snow  * Write a pattern to guest memory.
54286298845SJohn Snow  */
54386298845SJohn Snow void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
54486298845SJohn Snow 
54586298845SJohn Snow /**
54649ee3590SAnthony Liguori  * qtest_clock_step_next:
5476acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
54849ee3590SAnthony Liguori  *
549bc72ad67SAlex Bligh  * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
5506acf801dSAndreas Färber  *
551bc72ad67SAlex Bligh  * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
55249ee3590SAnthony Liguori  */
55349ee3590SAnthony Liguori int64_t qtest_clock_step_next(QTestState *s);
55449ee3590SAnthony Liguori 
55549ee3590SAnthony Liguori /**
55649ee3590SAnthony Liguori  * qtest_clock_step:
55749ee3590SAnthony Liguori  * @s: QTestState instance to operate on.
55849ee3590SAnthony Liguori  * @step: Number of nanoseconds to advance the clock by.
55949ee3590SAnthony Liguori  *
560bc72ad67SAlex Bligh  * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
5616acf801dSAndreas Färber  *
562bc72ad67SAlex Bligh  * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
56349ee3590SAnthony Liguori  */
56449ee3590SAnthony Liguori int64_t qtest_clock_step(QTestState *s, int64_t step);
56549ee3590SAnthony Liguori 
56649ee3590SAnthony Liguori /**
56749ee3590SAnthony Liguori  * qtest_clock_set:
56849ee3590SAnthony Liguori  * @s: QTestState instance to operate on.
56949ee3590SAnthony Liguori  * @val: Nanoseconds value to advance the clock to.
57049ee3590SAnthony Liguori  *
571bc72ad67SAlex Bligh  * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
5726acf801dSAndreas Färber  *
573bc72ad67SAlex Bligh  * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
57449ee3590SAnthony Liguori  */
57549ee3590SAnthony Liguori int64_t qtest_clock_set(QTestState *s, int64_t val);
57649ee3590SAnthony Liguori 
57749ee3590SAnthony Liguori /**
57854ce6f22SLaurent Vivier  * qtest_big_endian:
57954ce6f22SLaurent Vivier  * @s: QTestState instance to operate on.
58054ce6f22SLaurent Vivier  *
58154ce6f22SLaurent Vivier  * Returns: True if the architecture under test has a big endian configuration.
58254ce6f22SLaurent Vivier  */
58354ce6f22SLaurent Vivier bool qtest_big_endian(QTestState *s);
58454ce6f22SLaurent Vivier 
58554ce6f22SLaurent Vivier /**
58649ee3590SAnthony Liguori  * qtest_get_arch:
58749ee3590SAnthony Liguori  *
5886acf801dSAndreas Färber  * Returns: The architecture for the QEMU executable under test.
58949ee3590SAnthony Liguori  */
59049ee3590SAnthony Liguori const char *qtest_get_arch(void);
59149ee3590SAnthony Liguori 
59249ee3590SAnthony Liguori /**
593e741aff0SIgor Mammedov  * qtest_has_accel:
594e741aff0SIgor Mammedov  * @accel_name: Accelerator name to check for.
595e741aff0SIgor Mammedov  *
596e741aff0SIgor Mammedov  * Returns: true if the accelerator is built in.
597e741aff0SIgor Mammedov  */
598e741aff0SIgor Mammedov bool qtest_has_accel(const char *accel_name);
599e741aff0SIgor Mammedov 
600e741aff0SIgor Mammedov /**
60149ee3590SAnthony Liguori  * qtest_add_func:
60249ee3590SAnthony Liguori  * @str: Test case path.
60349ee3590SAnthony Liguori  * @fn: Test case function
60449ee3590SAnthony Liguori  *
60549ee3590SAnthony Liguori  * Add a GTester testcase with the given name and function.
60649ee3590SAnthony Liguori  * The path is prefixed with the architecture under test, as
6076acf801dSAndreas Färber  * returned by qtest_get_arch().
60849ee3590SAnthony Liguori  */
609041088c7SMarkus Armbruster void qtest_add_func(const char *str, void (*fn)(void));
61049ee3590SAnthony Liguori 
61149ee3590SAnthony Liguori /**
6127949c0e3SAndreas Färber  * qtest_add_data_func:
6137949c0e3SAndreas Färber  * @str: Test case path.
6147949c0e3SAndreas Färber  * @data: Test case data
6157949c0e3SAndreas Färber  * @fn: Test case function
6167949c0e3SAndreas Färber  *
6177949c0e3SAndreas Färber  * Add a GTester testcase with the given name, data and function.
6187949c0e3SAndreas Färber  * The path is prefixed with the architecture under test, as
6197949c0e3SAndreas Färber  * returned by qtest_get_arch().
6207949c0e3SAndreas Färber  */
621041088c7SMarkus Armbruster void qtest_add_data_func(const char *str, const void *data,
622041088c7SMarkus Armbruster                          void (*fn)(const void *));
6237949c0e3SAndreas Färber 
6247949c0e3SAndreas Färber /**
625822e36caSMarc-André Lureau  * qtest_add_data_func_full:
626822e36caSMarc-André Lureau  * @str: Test case path.
627822e36caSMarc-André Lureau  * @data: Test case data
628822e36caSMarc-André Lureau  * @fn: Test case function
629822e36caSMarc-André Lureau  * @data_free_func: GDestroyNotify for data
630822e36caSMarc-André Lureau  *
631822e36caSMarc-André Lureau  * Add a GTester testcase with the given name, data and function.
632822e36caSMarc-André Lureau  * The path is prefixed with the architecture under test, as
633822e36caSMarc-André Lureau  * returned by qtest_get_arch().
634822e36caSMarc-André Lureau  *
635822e36caSMarc-André Lureau  * @data is passed to @data_free_func() on test completion.
636822e36caSMarc-André Lureau  */
637822e36caSMarc-André Lureau void qtest_add_data_func_full(const char *str, void *data,
638822e36caSMarc-André Lureau                               void (*fn)(const void *),
639822e36caSMarc-André Lureau                               GDestroyNotify data_free_func);
640822e36caSMarc-André Lureau 
641822e36caSMarc-André Lureau /**
64245b0f830SAndreas Färber  * qtest_add:
64345b0f830SAndreas Färber  * @testpath: Test case path
64445b0f830SAndreas Färber  * @Fixture: Fixture type
64545b0f830SAndreas Färber  * @tdata: Test case data
64645b0f830SAndreas Färber  * @fsetup: Test case setup function
64745b0f830SAndreas Färber  * @ftest: Test case function
64845b0f830SAndreas Färber  * @fteardown: Test case teardown function
64945b0f830SAndreas Färber  *
65045b0f830SAndreas Färber  * Add a GTester testcase with the given name, data and functions.
65145b0f830SAndreas Färber  * The path is prefixed with the architecture under test, as
65245b0f830SAndreas Färber  * returned by qtest_get_arch().
65345b0f830SAndreas Färber  */
65445b0f830SAndreas Färber #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
65545b0f830SAndreas Färber     do { \
65645b0f830SAndreas Färber         char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
65745b0f830SAndreas Färber         g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
65845b0f830SAndreas Färber         g_free(path); \
65945b0f830SAndreas Färber     } while (0)
66045b0f830SAndreas Färber 
661e1fa7f55SStefan Hajnoczi /**
662e1fa7f55SStefan Hajnoczi  * qtest_add_abrt_handler:
663e1fa7f55SStefan Hajnoczi  * @fn: Handler function
664e1fa7f55SStefan Hajnoczi  * @data: Argument that is passed to the handler
665e1fa7f55SStefan Hajnoczi  *
666e1fa7f55SStefan Hajnoczi  * Add a handler function that is invoked on SIGABRT. This can be used to
667e1fa7f55SStefan Hajnoczi  * terminate processes and perform other cleanup. The handler can be removed
668e1fa7f55SStefan Hajnoczi  * with qtest_remove_abrt_handler().
669e1fa7f55SStefan Hajnoczi  */
670041088c7SMarkus Armbruster void qtest_add_abrt_handler(GHookFunc fn, const void *data);
671063c23d9SMarc-André Lureau 
67245b0f830SAndreas Färber /**
673e1fa7f55SStefan Hajnoczi  * qtest_remove_abrt_handler:
674e1fa7f55SStefan Hajnoczi  * @data: Argument previously passed to qtest_add_abrt_handler()
675e1fa7f55SStefan Hajnoczi  *
676e1fa7f55SStefan Hajnoczi  * Remove an abrt handler that was previously added with
677e1fa7f55SStefan Hajnoczi  * qtest_add_abrt_handler().
678e1fa7f55SStefan Hajnoczi  */
679e1fa7f55SStefan Hajnoczi void qtest_remove_abrt_handler(void *data);
680e1fa7f55SStefan Hajnoczi 
681e1fa7f55SStefan Hajnoczi /**
6826fc9f3d3SThomas Huth  * qtest_qmp_assert_success:
6836fc9f3d3SThomas Huth  * @qts: QTestState instance to operate on
68451c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
685ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
686edbe36adSKevin Wolf  * supported after '%'.
687edbe36adSKevin Wolf  *
688edbe36adSKevin Wolf  * Sends a QMP message to QEMU and asserts that a 'return' key is present in
689edbe36adSKevin Wolf  * the response.
690edbe36adSKevin Wolf  */
6916fc9f3d3SThomas Huth void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
6929edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
693edbe36adSKevin Wolf 
69402ef6e87SThomas Huth /**
69502ef6e87SThomas Huth  * qtest_cb_for_every_machine:
69602ef6e87SThomas Huth  * @cb: Pointer to the callback function
6971f4a0d81SThomas Huth  * @skip_old_versioned: true if versioned old machine types should be skipped
69802ef6e87SThomas Huth  *
69902ef6e87SThomas Huth  *  Call a callback function for every name of all available machines.
70002ef6e87SThomas Huth  */
7011f4a0d81SThomas Huth void qtest_cb_for_every_machine(void (*cb)(const char *machine),
7021f4a0d81SThomas Huth                                 bool skip_old_versioned);
70302ef6e87SThomas Huth 
704acd80015SThomas Huth /**
705719051caSThomas Huth  * qtest_has_machine:
706719051caSThomas Huth  * @machine: The machine to look for
707719051caSThomas Huth  *
708719051caSThomas Huth  * Returns: true if the machine is available in the target binary.
709719051caSThomas Huth  */
710719051caSThomas Huth bool qtest_has_machine(const char *machine);
711719051caSThomas Huth 
712719051caSThomas Huth /**
713ad9e129bSThomas Huth  * qtest_has_device:
714ad9e129bSThomas Huth  * @device: The device to look for
715ad9e129bSThomas Huth  *
716ad9e129bSThomas Huth  * Returns: true if the device is available in the target binary.
717ad9e129bSThomas Huth  */
718ad9e129bSThomas Huth bool qtest_has_device(const char *device);
719ad9e129bSThomas Huth 
720ad9e129bSThomas Huth /**
721b4510bb4SIgor Mammedov  * qtest_qmp_device_add_qdict:
722b4510bb4SIgor Mammedov  * @qts: QTestState instance to operate on
723b4510bb4SIgor Mammedov  * @drv: Name of the device that should be added
724b4510bb4SIgor Mammedov  * @arguments: QDict with properties for the device to intialize
725b4510bb4SIgor Mammedov  *
726b4510bb4SIgor Mammedov  * Generic hot-plugging test via the device_add QMP command with properties
727b4510bb4SIgor Mammedov  * supplied in form of QDict. Use NULL for empty properties list.
728b4510bb4SIgor Mammedov  */
729b4510bb4SIgor Mammedov void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv,
730b4510bb4SIgor Mammedov                                 const QDict *arguments);
731b4510bb4SIgor Mammedov 
732b4510bb4SIgor Mammedov /**
733acd80015SThomas Huth  * qtest_qmp_device_add:
734e5758de4SThomas Huth  * @qts: QTestState instance to operate on
735acd80015SThomas Huth  * @driver: Name of the device that should be added
736acd80015SThomas Huth  * @id: Identification string
73751c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
738ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
73982cab70bSMarkus Armbruster  * supported after '%'.
740acd80015SThomas Huth  *
741acd80015SThomas Huth  * Generic hot-plugging test via the device_add QMP command.
742acd80015SThomas Huth  */
743e5758de4SThomas Huth void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
7449edc6313SMarc-André Lureau                           const char *fmt, ...) G_GNUC_PRINTF(4, 5);
745acd80015SThomas Huth 
746acd80015SThomas Huth /**
7472c7294d7SMarc-André Lureau  * qtest_qmp_add_client:
7482c7294d7SMarc-André Lureau  * @qts: QTestState instance to operate on
7492c7294d7SMarc-André Lureau  * @protocol: the protocol to add to
7502c7294d7SMarc-André Lureau  * @fd: the client file-descriptor
7512c7294d7SMarc-André Lureau  *
7522c7294d7SMarc-André Lureau  * Call QMP ``getfd`` followed by ``add_client`` with the given @fd.
7532c7294d7SMarc-André Lureau  */
7542c7294d7SMarc-André Lureau void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd);
7552c7294d7SMarc-André Lureau 
7562c7294d7SMarc-André Lureau /**
757acd80015SThomas Huth  * qtest_qmp_device_del:
758e5758de4SThomas Huth  * @qts: QTestState instance to operate on
759acd80015SThomas Huth  * @id: Identification string
760acd80015SThomas Huth  *
761acd80015SThomas Huth  * Generic hot-unplugging test via the device_del QMP command.
762acd80015SThomas Huth  */
763e5758de4SThomas Huth void qtest_qmp_device_del(QTestState *qts, const char *id);
764acd80015SThomas Huth 
765c35665e1SIgor Mammedov /**
76621f80286SRichard Henderson  * qtest_probe_child:
76721f80286SRichard Henderson  * @s: QTestState instance to operate on.
76821f80286SRichard Henderson  *
76921f80286SRichard Henderson  * Returns: true if the child is still alive.
77021f80286SRichard Henderson  */
77121f80286SRichard Henderson bool qtest_probe_child(QTestState *s);
77221f80286SRichard Henderson 
773d43e59e7SYury Kotov /**
774d43e59e7SYury Kotov  * qtest_set_expected_status:
775d43e59e7SYury Kotov  * @s: QTestState instance to operate on.
776d43e59e7SYury Kotov  * @status: an expected exit status.
777d43e59e7SYury Kotov  *
778d43e59e7SYury Kotov  * Set expected exit status of the child.
779d43e59e7SYury Kotov  */
780d43e59e7SYury Kotov void qtest_set_expected_status(QTestState *s, int status);
781d43e59e7SYury Kotov 
782ca5d4641SAlexander Bulekov QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch,
783ca5d4641SAlexander Bulekov                     void (*send)(void*, const char*));
784ca5d4641SAlexander Bulekov 
785ca5d4641SAlexander Bulekov void qtest_client_inproc_recv(void *opaque, const char *str);
786*188052a1SIris Chen 
787*188052a1SIris Chen /**
788*188052a1SIris Chen  * qtest_qom_set_bool:
789*188052a1SIris Chen  * @s: QTestState instance to operate on.
790*188052a1SIris Chen  * @path: Path to the property being set.
791*188052a1SIris Chen  * @property: Property being set.
792*188052a1SIris Chen  * @value: Value to set the property.
793*188052a1SIris Chen  *
794*188052a1SIris Chen  * Set the property with passed in value.
795*188052a1SIris Chen  */
796*188052a1SIris Chen void qtest_qom_set_bool(QTestState *s, const char *path, const char *property,
797*188052a1SIris Chen                          bool value);
798*188052a1SIris Chen 
799*188052a1SIris Chen /**
800*188052a1SIris Chen  * qtest_qom_get_bool:
801*188052a1SIris Chen  * @s: QTestState instance to operate on.
802*188052a1SIris Chen  * @path: Path to the property being retrieved.
803*188052a1SIris Chen  * @property: Property from where the value is being retrieved.
804*188052a1SIris Chen  *
805*188052a1SIris Chen  * Returns: Value retrieved from property.
806*188052a1SIris Chen  */
807*188052a1SIris Chen bool qtest_qom_get_bool(QTestState *s, const char *path, const char *property);
80849ee3590SAnthony Liguori #endif
809