提交 6d45b997 编写于 作者: P Peter Krempa

tests: qemumonitorjson: Add tests for QAPI schema query

While we technically test the query strings in the qemucapabilitiestest
this was done to help refactor and extend the QAPI schema query
infrastructure.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 432452eb
......@@ -2834,9 +2834,30 @@ struct testQAPISchemaData {
const char *query;
const char *json;
bool success;
int rc;
bool replyobj;
};
static int
testQAPISchemaQuery(const void *opaque)
{
const struct testQAPISchemaData *data = opaque;
virJSONValuePtr replyobj = NULL;
int rc;
rc = virQEMUQAPISchemaPathGet(data->query, data->schema, &replyobj);
if (data->rc != rc || data->replyobj != !!replyobj) {
VIR_TEST_VERBOSE("\n success: expected '%d' got '%d', replyobj: expected '%d' got '%d'",
data->rc, rc, data->replyobj, !!replyobj);
return -1;
}
return 0;
}
static int
testQAPISchemaValidate(const void *opaque)
{
......@@ -3054,6 +3075,30 @@ mymain(void)
#undef DO_TEST_BLOCK_NODE_DETECT
#define DO_TEST_QAPI_QUERY(nme, qry, scc, rplobj) \
do { \
qapiData.name = nme; \
qapiData.query = qry; \
qapiData.rc = scc; \
qapiData.replyobj = rplobj; \
if (virTestRun("qapi schema query" nme, testQAPISchemaQuery, &qapiData) < 0)\
ret = -1; \
} while (0)
DO_TEST_QAPI_QUERY("command", "blockdev-add", 0, true);
DO_TEST_QAPI_QUERY("event", "RTC_CHANGE", 0, true);
DO_TEST_QAPI_QUERY("object property", "screendump/arg-type/device", 0, true);
DO_TEST_QAPI_QUERY("optional property", "block-commit/arg-type/*top", 0, true);
DO_TEST_QAPI_QUERY("variant", "blockdev-add/arg-type/+file", 0, true);
DO_TEST_QAPI_QUERY("variant property", "blockdev-add/arg-type/+file/filename", 0, true);
DO_TEST_QAPI_QUERY("nonexistent command", "nonexistent", 0, false);
DO_TEST_QAPI_QUERY("nonexistent attr", "screendump/arg-type/nonexistent", 0, false);
DO_TEST_QAPI_QUERY("nonexistent variant", "blockdev-add/arg-type/+nonexistent", 0, false);
#undef DO_TEST_QAPI_QUERY
#define DO_TEST_QAPI_VALIDATE(nme, rootquery, scc, jsonstr) \
do { \
qapiData.name = nme; \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册