mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 09:13:55 -06:00
libqtest: New hmp() & friends
New convenience function hmp() to facilitate use of human-monitor-command in tests. Use it to simplify its existing uses. To blend into existing libqtest code, also add qtest_hmpv() and qtest_hmp(). That, and the egregiously verbose GTK-Doc comment format make this patch look bigger than it is. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <1443689999-12182-7-git-send-email-armbru@redhat.com>
This commit is contained in:
parent
82b15c7bdb
commit
5fb48d9673
4 changed files with 78 additions and 22 deletions
|
@ -483,6 +483,33 @@ void qtest_qmp_eventwait(QTestState *s, const char *event)
|
|||
}
|
||||
}
|
||||
|
||||
char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap)
|
||||
{
|
||||
char *cmd;
|
||||
QDict *resp;
|
||||
char *ret;
|
||||
|
||||
cmd = g_strdup_vprintf(fmt, ap);
|
||||
resp = qtest_qmp(s, "{'execute': 'human-monitor-command',"
|
||||
" 'arguments': {'command-line': %s}}",
|
||||
cmd);
|
||||
ret = g_strdup(qdict_get_try_str(resp, "return"));
|
||||
g_assert(ret);
|
||||
QDECREF(resp);
|
||||
g_free(cmd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *qtest_hmp(QTestState *s, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = qtest_hmpv(s, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char *qtest_get_arch(void)
|
||||
{
|
||||
|
@ -774,6 +801,16 @@ void qmp_discard_response(const char *fmt, ...)
|
|||
qtest_qmpv_discard_response(global_qtest, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
char *hmp(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = qtest_hmpv(global_qtest, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool qtest_big_endian(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue