From nobody Mon Feb 9 03:14:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531145098698862.8146197373742; Mon, 9 Jul 2018 07:04:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15BEB30DED14; Mon, 9 Jul 2018 14:04:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D003460928; Mon, 9 Jul 2018 14:04:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F0AFB4A465; Mon, 9 Jul 2018 14:04:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w69E4qwI001235 for ; Mon, 9 Jul 2018 10:04:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 16803111DCE9; Mon, 9 Jul 2018 14:04:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF352111DCE8 for ; Mon, 9 Jul 2018 14:04:51 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 9 Jul 2018 16:12:36 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] tests: qemu: Use qmp schema data from the qemucapabilities test X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 09 Jul 2018 14:04:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add helpers that allow using the latest schema from the replies from an actual qemu which are recorded for the purpose of the qemucapabilities test instead of an unsynced copy stored in qemuqapischema.json. Signed-off-by: Peter Krempa --- tests/qemumonitorjsontest.c | 13 +++++---- tests/testutilsqemuschema.c | 65 +++++++++++++++++++++++++++++++++++++++++= +--- tests/testutilsqemuschema.h | 3 +++ 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index c85bcbfc3b..9039cef423 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2860,7 +2860,8 @@ mymain(void) virQEMUDriver driver; testQemuMonitorJSONSimpleFuncData simpleFunc; struct testQAPISchemaData qapiData; - char *metaschema =3D NULL; + virJSONValuePtr metaschema =3D NULL; + char *metaschemastr =3D NULL; #if !WITH_YAJL fputs("libvirt not compiled with JSON support, skipping this test\n", = stderr); @@ -3062,20 +3063,22 @@ mymain(void) DO_TEST_QAPI_SCHEMA("alternate 2", "blockdev-add/arg-type", false, "{\"driver\":\"qcow2\",\"file\": 1234}"); - if (!(metaschema =3D virTestLoadFilePath("qemuqapischema.json", NULL))= ) { - VIR_TEST_VERBOSE("failed to load qapi schema\n"); + if (!(metaschema =3D testQEMUSchemaGetLatest()) || + !(metaschemastr =3D virJSONValueToString(metaschema, false))) { + VIR_TEST_VERBOSE("failed to load latest qapi schema\n"); ret =3D -1; goto cleanup; } DO_TEST_QAPI_SCHEMA("schema-meta", "query-qmp-schema/ret-type", true, - metaschema); + metaschemastr); #undef DO_TEST_QAPI_SCHEMA cleanup: - VIR_FREE(metaschema); + VIR_FREE(metaschemastr); + virJSONValueFree(metaschema); virHashFree(qapiData.schema); qemuTestDriverFree(&driver); return (ret =3D=3D 0) ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index 46bbc4f1e5..1cec5265e1 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -17,6 +17,7 @@ */ #include #include "testutils.h" +#include "testutilsqemu.h" #include "testutilsqemuschema.h" #include "qemu/qemu_qapi.h" @@ -516,13 +517,71 @@ testQEMUSchemaValidate(virJSONValuePtr obj, } +/** + * testQEMUSchemaGetLatest: + * + * Returns the schema data as the qemu monitor would reply from the latest + * replies file used for qemucapabilitiestest for the x86_64 architecture. + */ +virJSONValuePtr +testQEMUSchemaGetLatest(void) +{ + char *capsLatestFile =3D NULL; + char *capsLatest =3D NULL; + char *schemaReply; + char *end; + virJSONValuePtr reply =3D NULL; + virJSONValuePtr schema =3D NULL; + + if (!(capsLatestFile =3D testQemuGetLatestCapsForArch(abs_srcdir "/qem= ucapabilitiesdata", + "x86_64", "replies= "))) { + VIR_TEST_VERBOSE("failed to find latest caps replies\n"); + return NULL; + } + + VIR_TEST_DEBUG("replies file: '%s'", capsLatestFile); + + if (virTestLoadFile(capsLatestFile, &capsLatest) < 0) + goto cleanup; + + if (!(schemaReply =3D strstr(capsLatest, "\"execute\": \"query-qmp-sch= ema\"")) || + !(schemaReply =3D strstr(schemaReply, "\n\n")) || + !(end =3D strstr(schemaReply + 2, "\n\n"))) { + VIR_TEST_VERBOSE("failed to find reply to 'query-qmp-schema' in '%= s'\n", + capsLatestFile); + goto cleanup; + } + + schemaReply +=3D 2; + *end =3D '\0'; + + if (!(reply =3D virJSONValueFromString(schemaReply))) { + VIR_TEST_VERBOSE("failed to parse 'query-qmp-schema' reply from '%= s'\n", + capsLatestFile); + goto cleanup; + } + + if (!(schema =3D virJSONValueObjectStealArray(reply, "return"))) { + VIR_TEST_VERBOSE("missing qapi schema data in reply in '%s'\n", + capsLatestFile); + goto cleanup; + } + + cleanup: + VIR_FREE(capsLatestFile); + VIR_FREE(capsLatest); + virJSONValueFree(reply); + return schema; +} + + virHashTablePtr testQEMUSchemaLoad(void) { - virJSONValuePtr schemajson; + virJSONValuePtr schema; - if (!(schemajson =3D virTestLoadFileJSON("qemuqapischema.json", NULL))) + if (!(schema =3D testQEMUSchemaGetLatest())) return NULL; - return virQEMUQAPISchemaConvert(schemajson); + return virQEMUQAPISchemaConvert(schema); } diff --git a/tests/testutilsqemuschema.h b/tests/testutilsqemuschema.h index cb383db174..c69435f420 100644 --- a/tests/testutilsqemuschema.h +++ b/tests/testutilsqemuschema.h @@ -26,5 +26,8 @@ testQEMUSchemaValidate(virJSONValuePtr obj, virHashTablePtr schema, virBufferPtr debug); +virJSONValuePtr +testQEMUSchemaGetLatest(void); + virHashTablePtr testQEMUSchemaLoad(void); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list