[PATCH 03/15] qemuMonitorTestProcessCommandDefaultValidate: Use testQEMUSchemaValidateCommand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove the ad-hoc command validation in favor of the new helper.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/qemumonitortestutils.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 4ca29ab061..df780643dd 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -537,9 +537,6 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
                                              virJSONValuePtr args)
 {
     g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
-    virJSONValuePtr schemaroot;
-    g_autoptr(virJSONValue) emptyargs = NULL;
-    g_autofree char *schemapath = NULL;

     if (!test->qapischema)
         return 0;
@@ -555,20 +552,13 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
     if (STREQ(cmdname, "device_add"))
         return 0;

-    schemapath = g_strdup_printf("%s/arg-type", cmdname);
-
-    if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) < 0 ||
-        !schemaroot) {
-        qemuMonitorTestError("command '%s' not found in QAPI schema", cmdname);
-        return -1;
-    }
+    if (testQEMUSchemaValidateCommand(cmdname, args, test->qapischema, &debug) < 0) {
+        if (virTestGetDebug() == 2) {
+            g_autofree char *argstr = NULL;

-    if (!args)
-        args = emptyargs = virJSONValueNewObject();
+            if (args)
+                argstr = virJSONValueToString(args, true);

-    if (testQEMUSchemaValidate(args, schemaroot, test->qapischema, &debug) < 0) {
-        if (virTestGetDebug() == 2) {
-            g_autofree char *argstr = virJSONValueToString(args, true);
             fprintf(stderr,
                     "\nfailed to validate arguments of '%s' against QAPI schema\n"
                     "args:\n%s\nvalidator output:\n %s\n",
-- 
2.26.2





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux