xref: /qemu/tests/qtest/libqmp.h (revision bd2142c3)
1 /*
2  * libqmp test unit
3  *
4  * Copyright IBM, Corp. 2012
5  * Copyright Red Hat, Inc. 2012
6  * Copyright SUSE LINUX Products GmbH 2013
7  *
8  * Authors:
9  *  Anthony Liguori   <aliguori@us.ibm.com>
10  *  Paolo Bonzini     <pbonzini@redhat.com>
11  *  Andreas Färber    <afaerber@suse.de>
12  *
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.
15  *
16  */
17 #ifndef LIBQMP_H_
18 #define LIBQMP_H_
19 
20 #include "qapi/qmp/qdict.h"
21 
22 QDict *qmp_fd_receive(int fd);
23 void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num,
24                       const char *fmt, va_list ap) G_GNUC_PRINTF(4, 0);
25 void qmp_fd_vsend(int fd, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0);
26 void qmp_fd_send(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
27 void qmp_fd_send_raw(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
28 void qmp_fd_vsend_raw(int fd, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0);
29 QDict *qmp_fdv(int fd, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0);
30 QDict *qmp_fd(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
31 
32 /**
33  * qmp_rsp_is_err:
34  * @rsp: QMP response to check for error
35  *
36  * Test @rsp for error and discard @rsp.
37  * Returns 'true' if there is error in @rsp and 'false' otherwise.
38  */
39 bool qmp_rsp_is_err(QDict *rsp);
40 
41 /**
42  * qmp_expect_error_and_unref:
43  * @rsp: QMP response to check for error
44  * @class: an error class
45  *
46  * Assert the response has the given error class and discard @rsp.
47  */
48 void qmp_expect_error_and_unref(QDict *rsp, const char *class);
49 
50 #endif /* LIBQMP_H_ */
51