提交 56c2f2b4 编写于 作者: P Peter Krempa

tests: qemu: Add QMP schema checking in qemuMonitorTestProcessCommandVerbatim

In case when we are testing a QMP command we can try to schema check it
so that we catch inconsistencies.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 e4013f9f
......@@ -690,14 +690,30 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test,
struct qemuMonitorTestHandlerData *data = item->opaque;
VIR_AUTOFREE(char *) reformatted = NULL;
VIR_AUTOFREE(char *) errmsg = NULL;
VIR_AUTOPTR(virJSONValue) json = NULL;
virJSONValuePtr cmdargs;
const char *cmdname;
int ret = -1;
int rc;
/* JSON strings will be reformatted to simplify checking */
if (test->json || test->agent) {
if (!(reformatted = virJSONStringReformat(cmdstr, false)))
if (!(json = virJSONValueFromString(cmdstr)) ||
!(reformatted = virJSONValueToString(json, false)))
return -1;
cmdstr = reformatted;
/* in this case we do a best-effort schema check if we can find the command */
if ((cmdname = virJSONValueObjectGetString(json, "execute"))) {
cmdargs = virJSONValueObjectGet(json, "arguments");
if ((rc = qemuMonitorTestProcessCommandDefaultValidate(test, cmdname, cmdargs)) < 0)
return -1;
if (rc == 1)
return 0;
}
}
if (STREQ(data->command_name, cmdstr)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册