diff options
author | Markus Armbruster <armbru@redhat.com> | 2018-08-23 18:39:33 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2018-08-24 20:26:37 +0200 |
commit | aed877c53b5b8760b3fdb3605a212188c60f2eb3 (patch) | |
tree | 852e96bdc65fe0ef631e6323806e024944fad4f1 /tests/libqtest.c | |
parent | d93bb9d5c34c1b4ed97bf824e6459b5516db94f6 (diff) |
qmp-test: Cover syntax and lexical errors
qmp-test neglects to cover QMP input that isn't valid JSON. libqtest
doesn't let us send such input. Add qtest_qmp_send_raw() for this
purpose, and put it to use in qmp-test.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180823164025.12553-7-armbru@redhat.com>
[Commit message typo fixed]
Diffstat (limited to 'tests/libqtest.c')
-rw-r--r-- | tests/libqtest.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/libqtest.c b/tests/libqtest.c index 1105c37e08..7012c5ccd0 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -604,6 +604,23 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ...) va_end(ap); } +void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) +{ + bool log = getenv("QTEST_LOG") != NULL; + va_list ap; + char *str; + + va_start(ap, fmt); + str = g_strdup_vprintf(fmt, ap); + va_end(ap); + + if (log) { + fprintf(stderr, "%s", str); + } + socket_send(s->qmp_fd, str, strlen(str)); + g_free(str); +} + QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event) { QDict *response; |