mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
testQEMUSchemaValidateCommand: Add possibility for partial QMP validation
The QMP schema for 'device_add' is not complete yet. Allow validation of incomplete schema so that we can enable at least some validation. Once there's more schema in the future all present members are still validated. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
387c900de9
commit
b17fd211e2
@ -171,6 +171,7 @@ qemuMigParamsTestJSON(const void *opaque)
|
||||
data->qmpschema,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
&debug) < 0) {
|
||||
VIR_TEST_VERBOSE("failed to validate migration params '%s' against QMP schema: %s",
|
||||
actualJSON, virBufferCurrentContent(&debug));
|
||||
|
@ -342,6 +342,7 @@ testQemuMigrationCookieBlockDirtyBitmaps(const void *opaque)
|
||||
qmpschema,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
&debug) < 0) {
|
||||
VIR_TEST_VERBOSE("failed to validate migration params '%s' against QMP schema: %s",
|
||||
actualJSON, virBufferCurrentContent(&debug));
|
||||
|
@ -542,6 +542,7 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTest *test,
|
||||
if (testQEMUSchemaValidateCommand(cmdname, args, test->qapischema,
|
||||
test->skipValidationDeprecated,
|
||||
test->skipValidationRemoved,
|
||||
false,
|
||||
&debug) < 0) {
|
||||
if (virTestGetDebug() == 2) {
|
||||
g_autofree char *argstr = NULL;
|
||||
|
@ -535,7 +535,7 @@ testCompareXMLToArgvValidateSchemaCommand(GStrv args,
|
||||
return -1;
|
||||
|
||||
if (testQEMUSchemaValidateCommand(command->schema, jsonargs,
|
||||
schema, false, false, &debug) < 0) {
|
||||
schema, false, false, false, &debug) < 0) {
|
||||
VIR_TEST_VERBOSE("failed to validate '%s %s' against QAPI schema: %s",
|
||||
command->name, curargs, virBufferCurrentContent(&debug));
|
||||
return -1;
|
||||
|
@ -25,6 +25,7 @@ struct testQEMUSchemaValidateCtxt {
|
||||
GHashTable *schema;
|
||||
virBuffer *debug;
|
||||
bool allowDeprecated;
|
||||
bool allowIncomplete; /* allow members not (yet) covered by the schema */
|
||||
};
|
||||
|
||||
|
||||
@ -137,6 +138,10 @@ testQEMUSchemaValidateObjectMember(const char *key,
|
||||
|
||||
/* lookup 'member' entry for key */
|
||||
if (!(keymember = testQEMUSchemaStealObjectMemberByName(key, data->rootmembers))) {
|
||||
if (data->ctxt->allowIncomplete) {
|
||||
virBufferAddLit(data->ctxt->debug, " schema missing - OK(waived)\n");
|
||||
return 0;
|
||||
}
|
||||
virBufferAddLit(data->ctxt->debug, "ERROR: attribute not in schema\n");
|
||||
return -1;
|
||||
}
|
||||
@ -553,6 +558,8 @@ testQEMUSchemaValidate(virJSONValue *obj,
|
||||
* @allowDeprecated: don't fails schema validation if @command or one of @arguments
|
||||
* is deprecated
|
||||
* @allowRemoved: skip validation fully if @command was not found
|
||||
* @allowIncomplete: don't fail validation if members not covered by schema are present
|
||||
* (for waiving commands with incomplete schema)
|
||||
* @debug: a virBuffer which will be filled with debug information if provided
|
||||
*
|
||||
* Validates whether @command and its @arguments conform to the QAPI schema
|
||||
@ -571,11 +578,13 @@ testQEMUSchemaValidateCommand(const char *command,
|
||||
GHashTable *schema,
|
||||
bool allowDeprecated,
|
||||
bool allowRemoved,
|
||||
bool allowIncomplete,
|
||||
virBuffer *debug)
|
||||
{
|
||||
struct testQEMUSchemaValidateCtxt ctxt = { .schema = schema,
|
||||
.debug = debug,
|
||||
.allowDeprecated = allowDeprecated };
|
||||
.allowDeprecated = allowDeprecated,
|
||||
.allowIncomplete = allowIncomplete };
|
||||
g_autofree char *schemapatharguments = g_strdup_printf("%s/arg-type", command);
|
||||
g_autoptr(virJSONValue) emptyargs = NULL;
|
||||
virJSONValue *schemarootcommand;
|
||||
|
@ -35,6 +35,7 @@ testQEMUSchemaValidateCommand(const char *command,
|
||||
GHashTable *schema,
|
||||
bool allowDeprecated,
|
||||
bool allowRemoved,
|
||||
bool allowIncomplete,
|
||||
virBuffer *debug);
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user