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(a)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(a)redhat.com>
Jano