提交 7f350f52 编写于 作者: P Peter Krempa

qemuMonitorTestProcessCommandDefaultValidate: Use testQEMUSchemaValidateCommand

Remove the ad-hoc command validation in favor of the new helper.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 23bd18dc
...@@ -537,9 +537,6 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test, ...@@ -537,9 +537,6 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
virJSONValuePtr args) virJSONValuePtr args)
{ {
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
virJSONValuePtr schemaroot;
g_autoptr(virJSONValue) emptyargs = NULL;
g_autofree char *schemapath = NULL;
if (!test->qapischema) if (!test->qapischema)
return 0; return 0;
...@@ -555,20 +552,13 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test, ...@@ -555,20 +552,13 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
if (STREQ(cmdname, "device_add")) if (STREQ(cmdname, "device_add"))
return 0; return 0;
schemapath = g_strdup_printf("%s/arg-type", cmdname); if (testQEMUSchemaValidateCommand(cmdname, args, test->qapischema, &debug) < 0) {
if (virTestGetDebug() == 2) {
if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) < 0 || g_autofree char *argstr = NULL;
!schemaroot) {
qemuMonitorTestError("command '%s' not found in QAPI schema", cmdname);
return -1;
}
if (!args) if (args)
args = emptyargs = virJSONValueNewObject(); argstr = virJSONValueToString(args, true);
if (testQEMUSchemaValidate(args, schemaroot, test->qapischema, &debug) < 0) {
if (virTestGetDebug() == 2) {
g_autofree char *argstr = virJSONValueToString(args, true);
fprintf(stderr, fprintf(stderr,
"\nfailed to validate arguments of '%s' against QAPI schema\n" "\nfailed to validate arguments of '%s' against QAPI schema\n"
"args:\n%s\nvalidator output:\n %s\n", "args:\n%s\nvalidator output:\n %s\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册