Acceptance tests: drop left over usage of ":avocado: enable"
[qemu/ar7.git] / tests / libqtest.h
blob07ea35867c74d0119e1fb62de7b9ef1c4372d357
1 /*
2 * QTest
4 * Copyright IBM, Corp. 2012
5 * Copyright Red Hat, Inc. 2012
6 * Copyright SUSE LINUX Products GmbH 2013
8 * Authors:
9 * Anthony Liguori <aliguori@us.ibm.com>
10 * Paolo Bonzini <pbonzini@redhat.com>
11 * Andreas Färber <afaerber@suse.de>
13 * This work is licensed under the terms of the GNU GPL, version 2 or later.
14 * See the COPYING file in the top-level directory.
17 #ifndef LIBQTEST_H
18 #define LIBQTEST_H
20 #include "qapi/qmp/qobject.h"
21 #include "qapi/qmp/qdict.h"
23 typedef struct QTestState QTestState;
25 extern QTestState *global_qtest;
27 /**
28 * qtest_initf:
29 * @fmt...: Format for creating other arguments to pass to QEMU, formatted
30 * like sprintf().
32 * Convenience wrapper around qtest_init().
34 * Returns: #QTestState instance.
36 QTestState *qtest_initf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
38 /**
39 * qtest_vinitf:
40 * @fmt: Format for creating other arguments to pass to QEMU, formatted
41 * like vsprintf().
42 * @ap: Format arguments.
44 * Convenience wrapper around qtest_init().
46 * Returns: #QTestState instance.
48 QTestState *qtest_vinitf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
50 /**
51 * qtest_init:
52 * @extra_args: other arguments to pass to QEMU. CAUTION: these
53 * arguments are subject to word splitting and shell evaluation.
55 * Returns: #QTestState instance.
57 QTestState *qtest_init(const char *extra_args);
59 /**
60 * qtest_init_without_qmp_handshake:
61 * @extra_args: other arguments to pass to QEMU. CAUTION: these
62 * arguments are subject to word splitting and shell evaluation.
64 * Returns: #QTestState instance.
66 QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
68 /**
69 * qtest_init_with_serial:
70 * @extra_args: other arguments to pass to QEMU. CAUTION: these
71 * arguments are subject to word splitting and shell evaluation.
72 * @sock_fd: pointer to store the socket file descriptor for
73 * connection with serial.
75 * Returns: #QTestState instance.
77 QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
79 /**
80 * qtest_quit:
81 * @s: #QTestState instance to operate on.
83 * Shut down the QEMU process associated to @s.
85 void qtest_quit(QTestState *s);
87 /**
88 * qtest_qmp_fds:
89 * @s: #QTestState instance to operate on.
90 * @fds: array of file descriptors
91 * @fds_num: number of elements in @fds
92 * @fmt...: QMP message to send to qemu, formatted like
93 * qobject_from_jsonf_nofail(). See parse_escape() for what's
94 * supported after '%'.
96 * Sends a QMP message to QEMU with fds and returns the response.
98 QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num,
99 const char *fmt, ...)
100 GCC_FMT_ATTR(4, 5);
103 * qtest_qmp:
104 * @s: #QTestState instance to operate on.
105 * @fmt...: QMP message to send to qemu, formatted like
106 * qobject_from_jsonf_nofail(). See parse_escape() for what's
107 * supported after '%'.
109 * Sends a QMP message to QEMU and returns the response.
111 QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
112 GCC_FMT_ATTR(2, 3);
115 * qtest_qmp_send:
116 * @s: #QTestState instance to operate on.
117 * @fmt...: QMP message to send to qemu, formatted like
118 * qobject_from_jsonf_nofail(). See parse_escape() for what's
119 * supported after '%'.
121 * Sends a QMP message to QEMU and leaves the response in the stream.
123 void qtest_qmp_send(QTestState *s, const char *fmt, ...)
124 GCC_FMT_ATTR(2, 3);
127 * qtest_qmp_send_raw:
128 * @s: #QTestState instance to operate on.
129 * @fmt...: text to send, formatted like sprintf()
131 * Sends text to the QMP monitor verbatim. Need not be valid JSON;
132 * this is useful for negative tests.
134 void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
135 GCC_FMT_ATTR(2, 3);
138 * qtest_vqmp_fds:
139 * @s: #QTestState instance to operate on.
140 * @fds: array of file descriptors
141 * @fds_num: number of elements in @fds
142 * @fmt: QMP message to send to QEMU, formatted like
143 * qobject_from_jsonf_nofail(). See parse_escape() for what's
144 * supported after '%'.
145 * @ap: QMP message arguments
147 * Sends a QMP message to QEMU with fds and returns the response.
149 QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,
150 const char *fmt, va_list ap)
151 GCC_FMT_ATTR(4, 0);
154 * qtest_vqmp:
155 * @s: #QTestState instance to operate on.
156 * @fmt: QMP message to send to QEMU, formatted like
157 * qobject_from_jsonf_nofail(). See parse_escape() for what's
158 * supported after '%'.
159 * @ap: QMP message arguments
161 * Sends a QMP message to QEMU and returns the response.
163 QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
164 GCC_FMT_ATTR(2, 0);
167 * qtest_qmp_vsend_fds:
168 * @s: #QTestState instance to operate on.
169 * @fds: array of file descriptors
170 * @fds_num: number of elements in @fds
171 * @fmt: QMP message to send to QEMU, formatted like
172 * qobject_from_jsonf_nofail(). See parse_escape() for what's
173 * supported after '%'.
174 * @ap: QMP message arguments
176 * Sends a QMP message to QEMU and leaves the response in the stream.
178 void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num,
179 const char *fmt, va_list ap)
180 GCC_FMT_ATTR(4, 0);
183 * qtest_qmp_vsend:
184 * @s: #QTestState instance to operate on.
185 * @fmt: QMP message to send to QEMU, formatted like
186 * qobject_from_jsonf_nofail(). See parse_escape() for what's
187 * supported after '%'.
188 * @ap: QMP message arguments
190 * Sends a QMP message to QEMU and leaves the response in the stream.
192 void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
193 GCC_FMT_ATTR(2, 0);
196 * qtest_receive:
197 * @s: #QTestState instance to operate on.
199 * Reads a QMP message from QEMU and returns the response.
201 QDict *qtest_qmp_receive(QTestState *s);
204 * qtest_qmp_eventwait:
205 * @s: #QTestState instance to operate on.
206 * @s: #event event to wait for.
208 * Continuously polls for QMP responses until it receives the desired event.
210 void qtest_qmp_eventwait(QTestState *s, const char *event);
213 * qtest_qmp_eventwait_ref:
214 * @s: #QTestState instance to operate on.
215 * @s: #event event to wait for.
217 * Continuously polls for QMP responses until it receives the desired event.
218 * Returns a copy of the event for further investigation.
220 QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);
223 * qtest_qmp_receive_success:
224 * @s: #QTestState instance to operate on
225 * @event_cb: Event callback
226 * @opaque: Argument for @event_cb
228 * Poll QMP messages until a command success response is received.
229 * If @event_cb, call it for each event received, passing @opaque,
230 * the event's name and data.
231 * Return the success response's "return" member.
233 QDict *qtest_qmp_receive_success(QTestState *s,
234 void (*event_cb)(void *opaque,
235 const char *name,
236 QDict *data),
237 void *opaque);
240 * qtest_hmp:
241 * @s: #QTestState instance to operate on.
242 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
244 * Send HMP command to QEMU via QMP's human-monitor-command.
245 * QMP events are discarded.
247 * Returns: the command's output. The caller should g_free() it.
249 char *qtest_hmp(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
252 * qtest_hmpv:
253 * @s: #QTestState instance to operate on.
254 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
255 * @ap: HMP command arguments
257 * Send HMP command to QEMU via QMP's human-monitor-command.
258 * QMP events are discarded.
260 * Returns: the command's output. The caller should g_free() it.
262 char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)
263 GCC_FMT_ATTR(2, 0);
265 void qtest_module_load(QTestState *s, const char *prefix, const char *libname);
268 * qtest_get_irq:
269 * @s: #QTestState instance to operate on.
270 * @num: Interrupt to observe.
272 * Returns: The level of the @num interrupt.
274 bool qtest_get_irq(QTestState *s, int num);
277 * qtest_irq_intercept_in:
278 * @s: #QTestState instance to operate on.
279 * @string: QOM path of a device.
281 * Associate qtest irqs with the GPIO-in pins of the device
282 * whose path is specified by @string.
284 void qtest_irq_intercept_in(QTestState *s, const char *string);
287 * qtest_irq_intercept_out:
288 * @s: #QTestState instance to operate on.
289 * @string: QOM path of a device.
291 * Associate qtest irqs with the GPIO-out pins of the device
292 * whose path is specified by @string.
294 void qtest_irq_intercept_out(QTestState *s, const char *string);
297 * qtest_set_irq_in:
298 * @s: QTestState instance to operate on.
299 * @string: QOM path of a device
300 * @name: IRQ name
301 * @irq: IRQ number
302 * @level: IRQ level
304 * Force given device/irq GPIO-in pin to the given level.
306 void qtest_set_irq_in(QTestState *s, const char *string, const char *name,
307 int irq, int level);
310 * qtest_outb:
311 * @s: #QTestState instance to operate on.
312 * @addr: I/O port to write to.
313 * @value: Value being written.
315 * Write an 8-bit value to an I/O port.
317 void qtest_outb(QTestState *s, uint16_t addr, uint8_t value);
320 * qtest_outw:
321 * @s: #QTestState instance to operate on.
322 * @addr: I/O port to write to.
323 * @value: Value being written.
325 * Write a 16-bit value to an I/O port.
327 void qtest_outw(QTestState *s, uint16_t addr, uint16_t value);
330 * qtest_outl:
331 * @s: #QTestState instance to operate on.
332 * @addr: I/O port to write to.
333 * @value: Value being written.
335 * Write a 32-bit value to an I/O port.
337 void qtest_outl(QTestState *s, uint16_t addr, uint32_t value);
340 * qtest_inb:
341 * @s: #QTestState instance to operate on.
342 * @addr: I/O port to read from.
344 * Returns an 8-bit value from an I/O port.
346 uint8_t qtest_inb(QTestState *s, uint16_t addr);
349 * qtest_inw:
350 * @s: #QTestState instance to operate on.
351 * @addr: I/O port to read from.
353 * Returns a 16-bit value from an I/O port.
355 uint16_t qtest_inw(QTestState *s, uint16_t addr);
358 * qtest_inl:
359 * @s: #QTestState instance to operate on.
360 * @addr: I/O port to read from.
362 * Returns a 32-bit value from an I/O port.
364 uint32_t qtest_inl(QTestState *s, uint16_t addr);
367 * qtest_writeb:
368 * @s: #QTestState instance to operate on.
369 * @addr: Guest address to write to.
370 * @value: Value being written.
372 * Writes an 8-bit value to memory.
374 void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value);
377 * qtest_writew:
378 * @s: #QTestState instance to operate on.
379 * @addr: Guest address to write to.
380 * @value: Value being written.
382 * Writes a 16-bit value to memory.
384 void qtest_writew(QTestState *s, uint64_t addr, uint16_t value);
387 * qtest_writel:
388 * @s: #QTestState instance to operate on.
389 * @addr: Guest address to write to.
390 * @value: Value being written.
392 * Writes a 32-bit value to memory.
394 void qtest_writel(QTestState *s, uint64_t addr, uint32_t value);
397 * qtest_writeq:
398 * @s: #QTestState instance to operate on.
399 * @addr: Guest address to write to.
400 * @value: Value being written.
402 * Writes a 64-bit value to memory.
404 void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value);
407 * qtest_readb:
408 * @s: #QTestState instance to operate on.
409 * @addr: Guest address to read from.
411 * Reads an 8-bit value from memory.
413 * Returns: Value read.
415 uint8_t qtest_readb(QTestState *s, uint64_t addr);
418 * qtest_readw:
419 * @s: #QTestState instance to operate on.
420 * @addr: Guest address to read from.
422 * Reads a 16-bit value from memory.
424 * Returns: Value read.
426 uint16_t qtest_readw(QTestState *s, uint64_t addr);
429 * qtest_readl:
430 * @s: #QTestState instance to operate on.
431 * @addr: Guest address to read from.
433 * Reads a 32-bit value from memory.
435 * Returns: Value read.
437 uint32_t qtest_readl(QTestState *s, uint64_t addr);
440 * qtest_readq:
441 * @s: #QTestState instance to operate on.
442 * @addr: Guest address to read from.
444 * Reads a 64-bit value from memory.
446 * Returns: Value read.
448 uint64_t qtest_readq(QTestState *s, uint64_t addr);
451 * qtest_memread:
452 * @s: #QTestState instance to operate on.
453 * @addr: Guest address to read from.
454 * @data: Pointer to where memory contents will be stored.
455 * @size: Number of bytes to read.
457 * Read guest memory into a buffer.
459 void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size);
462 * qtest_rtas_call:
463 * @s: #QTestState instance to operate on.
464 * @name: name of the command to call.
465 * @nargs: Number of args.
466 * @args: Guest address to read args from.
467 * @nret: Number of return value.
468 * @ret: Guest address to write return values to.
470 * Call an RTAS function
472 uint64_t qtest_rtas_call(QTestState *s, const char *name,
473 uint32_t nargs, uint64_t args,
474 uint32_t nret, uint64_t ret);
477 * qtest_bufread:
478 * @s: #QTestState instance to operate on.
479 * @addr: Guest address to read from.
480 * @data: Pointer to where memory contents will be stored.
481 * @size: Number of bytes to read.
483 * Read guest memory into a buffer and receive using a base64 encoding.
485 void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size);
488 * qtest_memwrite:
489 * @s: #QTestState instance to operate on.
490 * @addr: Guest address to write to.
491 * @data: Pointer to the bytes that will be written to guest memory.
492 * @size: Number of bytes to write.
494 * Write a buffer to guest memory.
496 void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size);
499 * qtest_bufwrite:
500 * @s: #QTestState instance to operate on.
501 * @addr: Guest address to write to.
502 * @data: Pointer to the bytes that will be written to guest memory.
503 * @size: Number of bytes to write.
505 * Write a buffer to guest memory and transmit using a base64 encoding.
507 void qtest_bufwrite(QTestState *s, uint64_t addr,
508 const void *data, size_t size);
511 * qtest_memset:
512 * @s: #QTestState instance to operate on.
513 * @addr: Guest address to write to.
514 * @patt: Byte pattern to fill the guest memory region with.
515 * @size: Number of bytes to write.
517 * Write a pattern to guest memory.
519 void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
522 * qtest_clock_step_next:
523 * @s: #QTestState instance to operate on.
525 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
527 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
529 int64_t qtest_clock_step_next(QTestState *s);
532 * qtest_clock_step:
533 * @s: QTestState instance to operate on.
534 * @step: Number of nanoseconds to advance the clock by.
536 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
538 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
540 int64_t qtest_clock_step(QTestState *s, int64_t step);
543 * qtest_clock_set:
544 * @s: QTestState instance to operate on.
545 * @val: Nanoseconds value to advance the clock to.
547 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
549 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
551 int64_t qtest_clock_set(QTestState *s, int64_t val);
554 * qtest_big_endian:
555 * @s: QTestState instance to operate on.
557 * Returns: True if the architecture under test has a big endian configuration.
559 bool qtest_big_endian(QTestState *s);
562 * qtest_get_arch:
564 * Returns: The architecture for the QEMU executable under test.
566 const char *qtest_get_arch(void);
569 * qtest_add_func:
570 * @str: Test case path.
571 * @fn: Test case function
573 * Add a GTester testcase with the given name and function.
574 * The path is prefixed with the architecture under test, as
575 * returned by qtest_get_arch().
577 void qtest_add_func(const char *str, void (*fn)(void));
580 * qtest_add_data_func:
581 * @str: Test case path.
582 * @data: Test case data
583 * @fn: Test case function
585 * Add a GTester testcase with the given name, data and function.
586 * The path is prefixed with the architecture under test, as
587 * returned by qtest_get_arch().
589 void qtest_add_data_func(const char *str, const void *data,
590 void (*fn)(const void *));
593 * qtest_add_data_func_full:
594 * @str: Test case path.
595 * @data: Test case data
596 * @fn: Test case function
597 * @data_free_func: GDestroyNotify for data
599 * Add a GTester testcase with the given name, data and function.
600 * The path is prefixed with the architecture under test, as
601 * returned by qtest_get_arch().
603 * @data is passed to @data_free_func() on test completion.
605 void qtest_add_data_func_full(const char *str, void *data,
606 void (*fn)(const void *),
607 GDestroyNotify data_free_func);
610 * qtest_add:
611 * @testpath: Test case path
612 * @Fixture: Fixture type
613 * @tdata: Test case data
614 * @fsetup: Test case setup function
615 * @ftest: Test case function
616 * @fteardown: Test case teardown function
618 * Add a GTester testcase with the given name, data and functions.
619 * The path is prefixed with the architecture under test, as
620 * returned by qtest_get_arch().
622 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
623 do { \
624 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
625 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
626 g_free(path); \
627 } while (0)
629 void qtest_add_abrt_handler(GHookFunc fn, const void *data);
632 * qtest_start:
633 * @args: other arguments to pass to QEMU
635 * Start QEMU and assign the resulting #QTestState to a global variable.
636 * The global variable is used by "shortcut" functions documented below.
638 * Returns: #QTestState instance.
640 static inline QTestState *qtest_start(const char *args)
642 global_qtest = qtest_init(args);
643 return global_qtest;
647 * qtest_end:
649 * Shut down the QEMU process started by qtest_start().
651 static inline void qtest_end(void)
653 if (!global_qtest) {
654 return;
656 qtest_quit(global_qtest);
657 global_qtest = NULL;
661 * qmp:
662 * @fmt...: QMP message to send to qemu, formatted like
663 * qobject_from_jsonf_nofail(). See parse_escape() for what's
664 * supported after '%'.
666 * Sends a QMP message to QEMU and returns the response.
668 QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
671 * qtest_qmp_assert_success:
672 * @qts: QTestState instance to operate on
673 * @fmt...: QMP message to send to qemu, formatted like
674 * qobject_from_jsonf_nofail(). See parse_escape() for what's
675 * supported after '%'.
677 * Sends a QMP message to QEMU and asserts that a 'return' key is present in
678 * the response.
680 void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
681 GCC_FMT_ATTR(2, 3);
684 * qmp_eventwait:
685 * @s: #event event to wait for.
687 * Continuously polls for QMP responses until it receives the desired event.
689 static inline void qmp_eventwait(const char *event)
691 return qtest_qmp_eventwait(global_qtest, event);
695 * get_irq:
696 * @num: Interrupt to observe.
698 * Returns: The level of the @num interrupt.
700 static inline bool get_irq(int num)
702 return qtest_get_irq(global_qtest, num);
706 * outb:
707 * @addr: I/O port to write to.
708 * @value: Value being written.
710 * Write an 8-bit value to an I/O port.
712 static inline void outb(uint16_t addr, uint8_t value)
714 qtest_outb(global_qtest, addr, value);
718 * outw:
719 * @addr: I/O port to write to.
720 * @value: Value being written.
722 * Write a 16-bit value to an I/O port.
724 static inline void outw(uint16_t addr, uint16_t value)
726 qtest_outw(global_qtest, addr, value);
730 * outl:
731 * @addr: I/O port to write to.
732 * @value: Value being written.
734 * Write a 32-bit value to an I/O port.
736 static inline void outl(uint16_t addr, uint32_t value)
738 qtest_outl(global_qtest, addr, value);
742 * inb:
743 * @addr: I/O port to read from.
745 * Reads an 8-bit value from an I/O port.
747 * Returns: Value read.
749 static inline uint8_t inb(uint16_t addr)
751 return qtest_inb(global_qtest, addr);
755 * inw:
756 * @addr: I/O port to read from.
758 * Reads a 16-bit value from an I/O port.
760 * Returns: Value read.
762 static inline uint16_t inw(uint16_t addr)
764 return qtest_inw(global_qtest, addr);
768 * inl:
769 * @addr: I/O port to read from.
771 * Reads a 32-bit value from an I/O port.
773 * Returns: Value read.
775 static inline uint32_t inl(uint16_t addr)
777 return qtest_inl(global_qtest, addr);
781 * writeb:
782 * @addr: Guest address to write to.
783 * @value: Value being written.
785 * Writes an 8-bit value to guest memory.
787 static inline void writeb(uint64_t addr, uint8_t value)
789 qtest_writeb(global_qtest, addr, value);
793 * writew:
794 * @addr: Guest address to write to.
795 * @value: Value being written.
797 * Writes a 16-bit value to guest memory.
799 static inline void writew(uint64_t addr, uint16_t value)
801 qtest_writew(global_qtest, addr, value);
805 * writel:
806 * @addr: Guest address to write to.
807 * @value: Value being written.
809 * Writes a 32-bit value to guest memory.
811 static inline void writel(uint64_t addr, uint32_t value)
813 qtest_writel(global_qtest, addr, value);
817 * writeq:
818 * @addr: Guest address to write to.
819 * @value: Value being written.
821 * Writes a 64-bit value to guest memory.
823 static inline void writeq(uint64_t addr, uint64_t value)
825 qtest_writeq(global_qtest, addr, value);
829 * readb:
830 * @addr: Guest address to read from.
832 * Reads an 8-bit value from guest memory.
834 * Returns: Value read.
836 static inline uint8_t readb(uint64_t addr)
838 return qtest_readb(global_qtest, addr);
842 * readw:
843 * @addr: Guest address to read from.
845 * Reads a 16-bit value from guest memory.
847 * Returns: Value read.
849 static inline uint16_t readw(uint64_t addr)
851 return qtest_readw(global_qtest, addr);
855 * readl:
856 * @addr: Guest address to read from.
858 * Reads a 32-bit value from guest memory.
860 * Returns: Value read.
862 static inline uint32_t readl(uint64_t addr)
864 return qtest_readl(global_qtest, addr);
868 * readq:
869 * @addr: Guest address to read from.
871 * Reads a 64-bit value from guest memory.
873 * Returns: Value read.
875 static inline uint64_t readq(uint64_t addr)
877 return qtest_readq(global_qtest, addr);
881 * memread:
882 * @addr: Guest address to read from.
883 * @data: Pointer to where memory contents will be stored.
884 * @size: Number of bytes to read.
886 * Read guest memory into a buffer.
888 static inline void memread(uint64_t addr, void *data, size_t size)
890 qtest_memread(global_qtest, addr, data, size);
894 * memwrite:
895 * @addr: Guest address to write to.
896 * @data: Pointer to the bytes that will be written to guest memory.
897 * @size: Number of bytes to write.
899 * Write a buffer to guest memory.
901 static inline void memwrite(uint64_t addr, const void *data, size_t size)
903 qtest_memwrite(global_qtest, addr, data, size);
907 * clock_step_next:
909 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
911 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
913 static inline int64_t clock_step_next(void)
915 return qtest_clock_step_next(global_qtest);
919 * clock_step:
920 * @step: Number of nanoseconds to advance the clock by.
922 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
924 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
926 static inline int64_t clock_step(int64_t step)
928 return qtest_clock_step(global_qtest, step);
931 QDict *qmp_fd_receive(int fd);
932 void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num,
933 const char *fmt, va_list ap) GCC_FMT_ATTR(4, 0);
934 void qmp_fd_vsend(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
935 void qmp_fd_send(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
936 void qmp_fd_send_raw(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
937 void qmp_fd_vsend_raw(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
938 QDict *qmp_fdv(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
939 QDict *qmp_fd(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
942 * qtest_cb_for_every_machine:
943 * @cb: Pointer to the callback function
944 * @skip_old_versioned: true if versioned old machine types should be skipped
946 * Call a callback function for every name of all available machines.
948 void qtest_cb_for_every_machine(void (*cb)(const char *machine),
949 bool skip_old_versioned);
952 * qtest_qmp_device_add:
953 * @qts: QTestState instance to operate on
954 * @driver: Name of the device that should be added
955 * @id: Identification string
956 * @fmt...: QMP message to send to qemu, formatted like
957 * qobject_from_jsonf_nofail(). See parse_escape() for what's
958 * supported after '%'.
960 * Generic hot-plugging test via the device_add QMP command.
962 void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
963 const char *fmt, ...) GCC_FMT_ATTR(4, 5);
966 * qtest_qmp_device_del:
967 * @qts: QTestState instance to operate on
968 * @id: Identification string
970 * Generic hot-unplugging test via the device_del QMP command.
972 void qtest_qmp_device_del(QTestState *qts, const char *id);
975 * qmp_rsp_is_err:
976 * @rsp: QMP response to check for error
978 * Test @rsp for error and discard @rsp.
979 * Returns 'true' if there is error in @rsp and 'false' otherwise.
981 bool qmp_rsp_is_err(QDict *rsp);
984 * qmp_assert_error_class:
985 * @rsp: QMP response to check for error
986 * @class: an error class
988 * Assert the response has the given error class and discard @rsp.
990 void qmp_assert_error_class(QDict *rsp, const char *class);
993 * qtest_probe_child:
994 * @s: QTestState instance to operate on.
996 * Returns: true if the child is still alive.
998 bool qtest_probe_child(QTestState *s);
1000 #endif