From cf68184e74e3b07b3d5f4e1d4b10cb7c484bcc91 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 17 Sep 2021 16:26:09 +0200 Subject: [PATCH] testQEMUSchemaValidateEnum: Use new 'members' for 'enum' meta type MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Switch to the new more featured way to report enum members which will also allow us to detect use of deprecated members. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik Reviewed-by: Ján Tomko --- tests/testutilsqemuschema.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index 82c5994604..dfb1add90b 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -324,6 +324,7 @@ testQEMUSchemaValidateEnum(virJSONValue *obj, { const char *objstr; virJSONValue *values = NULL; + virJSONValue *members = NULL; size_t i; if (virJSONValueGetType(obj) != VIR_JSON_TYPE_STRING) { @@ -333,6 +334,22 @@ testQEMUSchemaValidateEnum(virJSONValue *obj, objstr = virJSONValueGetString(obj); + /* qemu-6.2 added a "members" array superseding "values" */ + if ((members = virJSONValueObjectGetArray(root, "members"))) { + for (i = 0; i < virJSONValueArraySize(members); i++) { + virJSONValue *member = virJSONValueArrayGet(members, i); + + if (STREQ_NULLABLE(objstr, virJSONValueObjectGetString(member, "name"))) { + virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr)); + return 0; + } + } + + virBufferAsprintf(ctxt->debug, "ERROR: enum value '%s' is not in schema", + NULLSTR(objstr)); + return -1; + } + if ((values = virJSONValueObjectGetArray(root, "values"))) { for (i = 0; i < virJSONValueArraySize(values); i++) { virJSONValue *value = virJSONValueArrayGet(values, i); -- 2.47.2