[PATCH 015/103] qemuxml2argvtest: Refactor QAPI schema validation code

Ján Tomko jtomko at redhat.com
Fri Oct 8 12:18:38 UTC 2021


On a Thursday in 2021, Peter Krempa wrote:
>Prevent duplication of code when extending the validator for new
>commands. Add a struct describing a command to validate and make the
>validation loop a bit more robust to corner cases.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> tests/qemuxml2argvtest.c | 120 +++++++++++++++++++++------------------
> 1 file changed, 66 insertions(+), 54 deletions(-)
>
>diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
>index 7c6e3d3dd7..b5fab1178c 100644
>--- a/tests/qemuxml2argvtest.c
>+++ b/tests/qemuxml2argvtest.c

[..]

>+
>+            if (!(jsonargs = virJSONValueFromString(curargs)))
>+                return -1;
>+
>+            if (testQEMUSchemaValidateCommand(command->schema, jsonargs,
>+                                              schema, false, false, &debug) < 0) {
>+                VIR_TEST_VERBOSE("failed to validate '%s %s' against QAPI schema: %s",
>+                                 command->name, curargs, virBufferCurrentContent(&debug));
>+                return -1;
>+            }
>+
>+            /* don't check the argument twice */

// this is bridge

>+            arg++;
>+        }
>+    }
>+
>+    return 0;

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20211008/3b9fe7f5/attachment-0001.sig>


More information about the libvir-list mailing list