Re: [PATCH 08/15] testQEMUSchemaValidate(Command): Allow skipping validation of deprecated fields

2020-05-19 Thread Ján Tomko

On a Wednesday in 2020, Peter Krempa wrote:

Some test cases are used to validate interactions with old qemu. We need
to skip validation of deprecation with those once it will be added.

In case of commands which were already replaced by code based on
capabilities we can skip the full validation once the command is
removed.

Signed-off-by: Peter Krempa 
---
tests/qemublocktest.c| 14 +++---
tests/qemumonitorjsontest.c  |  3 ++-
tests/qemumonitortestutils.c |  5 -
tests/testutilsqemuschema.c  | 17 +++--
tests/testutilsqemuschema.h  |  3 +++
5 files changed, 31 insertions(+), 11 deletions(-)

@@ -508,16 +515,22 @@ testQEMUSchemaValidate(virJSONValuePtr obj,
 * -1 if it does not and -2 if there is a problem with the schema or with
 *  internals.
 *
+ * @alllowRemoved should generally be used only if it's certain that there's a


*allow


+ * replacement of @command in place.
+ *
 * @debug is filled with information regarding the validation process
 */
int
testQEMUSchemaValidateCommand(const char *command,
  virJSONValuePtr arguments,
  virHashTablePtr schema,


Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


[PATCH 08/15] testQEMUSchemaValidate(Command): Allow skipping validation of deprecated fields

2020-04-29 Thread Peter Krempa
Some test cases are used to validate interactions with old qemu. We need
to skip validation of deprecation with those once it will be added.

In case of commands which were already replaced by code based on
capabilities we can skip the full validation once the command is
removed.

Signed-off-by: Peter Krempa 
---
 tests/qemublocktest.c| 14 +++---
 tests/qemumonitorjsontest.c  |  3 ++-
 tests/qemumonitortestutils.c |  5 -
 tests/testutilsqemuschema.c  | 17 +++--
 tests/testutilsqemuschema.h  |  3 +++
 5 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 8001807552..604e71bba7 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -86,7 +86,7 @@ testBackingXMLjsonXML(const void *args)

 if (!data->legacy) {
 if (testQEMUSchemaValidate(backendprops, data->schemaroot,
-   data->schema, ) < 0) {
+   data->schema, false, ) < 0) {
 g_autofree char *debugmsg = virBufferContentAndReset();
 g_autofree char *debugprops = virJSONValueToString(backendprops, 
true);

@@ -168,7 +168,7 @@ testJSONtoJSON(const void *args)
 return -1;

 if (testQEMUSchemaValidate(jsonsrcout, data->schemaroot,
-   data->schema, ) < 0) {
+   data->schema, false, ) < 0) {
 g_autofree char *debugmsg = virBufferContentAndReset();

 VIR_TEST_VERBOSE("json does not conform to QAPI schema");
@@ -342,7 +342,7 @@ testQemuDiskXMLToPropsValidateSchema(const void *opaque)
 g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;

 if (testQEMUSchemaValidate(data->images[i].formatprops, 
data->schemaroot,
-   data->schema, ) < 0) {
+   data->schema, false, ) < 0) {
 g_autofree char *debugmsg = virBufferContentAndReset();
 g_autofree char *propsstr = 
virJSONValueToString(data->images[i].formatprops, true);
 VIR_TEST_VERBOSE("json does not conform to QAPI schema");
@@ -354,7 +354,7 @@ testQemuDiskXMLToPropsValidateSchema(const void *opaque)
 virBufferFreeAndReset();

 if (testQEMUSchemaValidate(data->images[i].storageprops, 
data->schemaroot,
-   data->schema, ) < 0) {
+   data->schema, false, ) < 0) {
 g_autofree char *debugmsg = virBufferContentAndReset();
 g_autofree char *propsstr = 
virJSONValueToString(data->images[i].storageprops, true);
 VIR_TEST_VERBOSE("json does not conform to QAPI schema");
@@ -366,7 +366,7 @@ testQemuDiskXMLToPropsValidateSchema(const void *opaque)
 virBufferFreeAndReset();

 if (testQEMUSchemaValidate(data->images[i].storagepropssrc, 
data->schemaroot,
-   data->schema, ) < 0) {
+   data->schema, false, ) < 0) {
 g_autofree char *debugmsg = virBufferContentAndReset();
 g_autofree char *propsstr = 
virJSONValueToString(data->images[i].storagepropssrc, true);
 VIR_TEST_VERBOSE("json does not conform to QAPI schema");
@@ -544,7 +544,7 @@ testQemuImageCreate(const void *opaque)
 return -1;

 if (testQEMUSchemaValidate(formatprops, data->schemaroot, data->schema,
-   ) < 0) {
+   false, ) < 0) {
 g_autofree char *debugmsg = virBufferContentAndReset();
 VIR_TEST_VERBOSE("blockdev-create format json does not conform to 
QAPI schema");
 VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n 
%s",
@@ -559,7 +559,7 @@ testQemuImageCreate(const void *opaque)
 return -1;

 if (testQEMUSchemaValidate(protocolprops, data->schemaroot, 
data->schema,
-   ) < 0) {
+   false, ) < 0) {
 g_autofree char *debugmsg = virBufferContentAndReset();
 VIR_TEST_VERBOSE("blockdev-create protocol json does not conform 
to QAPI schema");
 VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n 
%s",
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 60c816d1d1..fce88083b9 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2842,7 +2842,8 @@ testQAPISchemaValidate(const void *opaque)
 if (!(json = virJSONValueFromString(data->json)))
 goto cleanup;

-if ((testQEMUSchemaValidate(json, schemaroot, data->schema, ) == 0) 
!= data->success) {
+if ((testQEMUSchemaValidate(json, schemaroot, data->schema, false,
+) == 0) != data->success) {
 if (!data->success)
 VIR_TEST_VERBOSE("\nschema validation should have failed");
 } else {
diff --git