From nobody Mon Feb 9 11:07:36 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 ARC-Seal: i=1; a=rsa-sha256; t=1555344174; cv=none; d=zoho.com; s=zohoarc; b=VN5Dce3CTFEvf5QgNelrKWfuQg/5dx4cDx2gCeojLj2VNNtnk7vRsUvxyOA/589P1oJKGbQnmKXNzUn/fbyPlTqLuqPOw27nB009xbF7q2oe/+3eEnbs1Yqll+6vPnneLGbjoJFZNubGsZVoWrX6TWvcRnB6V3utJqZXoZe5mXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555344174; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=J8mM2YDV7e/Ry2LxH+Mw8CJd07obWc6VaIr91nnYe14=; b=gJuUe1FqR+p6KMFdc3ZoiMxHB9yM//K39UpzduucaAT8bAXRCiIPpiCR7b+3Hk+ID9D2d8dMNWtAAYnbHBPJlKeWv2XkRt22JPjbP2GxHqnpGyzw8zyKtTqLPT8JUCP5eHdPfP2lXvcjpde2waw393xKMOs8RRX24B/PXiP1uLI= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1555344174136843.8549484415097; Mon, 15 Apr 2019 09:02:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6113F3092661; Mon, 15 Apr 2019 16:02:52 +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 2B93060148; Mon, 15 Apr 2019 16:02:52 +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 BE9233FA50; Mon, 15 Apr 2019 16:02:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3FG2K8R002908 for ; Mon, 15 Apr 2019 12:02:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 311561001DE8; Mon, 15 Apr 2019 16:02:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC5701001947 for ; Mon, 15 Apr 2019 16:02:19 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 15 Apr 2019 18:01:56 +0200 Message-Id: <9de8d79f84c1f565beb2227b513032e25621499b.1555344008.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/21] tests: qemumonitorjson: Add tests for QAPI schema query 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 15 Apr 2019 16:02:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" While we technically test the query strings in the qemucapabilitiestest this was done to help refactor and extend the QAPI schema query infrastructure. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index e3d23a8800..bcd7d37b03 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2836,9 +2836,30 @@ struct testQAPISchemaData { const char *query; const char *json; bool success; + int rc; + bool replyobj; }; +static int +testQAPISchemaQuery(const void *opaque) +{ + const struct testQAPISchemaData *data =3D opaque; + virJSONValuePtr replyobj =3D NULL; + int rc; + + rc =3D virQEMUQAPISchemaPathGet(data->query, data->schema, &replyobj); + + if (data->rc !=3D rc || data->replyobj !=3D !!replyobj) { + VIR_TEST_VERBOSE("\n success: expected '%d' got '%d', replyobj: ex= pected '%d' got '%d'", + data->rc, rc, data->replyobj, !!replyobj); + return -1; + } + + return 0; +} + + static int testQAPISchemaValidate(const void *opaque) { @@ -3056,6 +3077,30 @@ mymain(void) #undef DO_TEST_BLOCK_NODE_DETECT +#define DO_TEST_QAPI_QUERY(nme, qry, scc, rplobj) \ + do { \ + qapiData.name =3D nme; \ + qapiData.query =3D qry; \ + qapiData.rc =3D scc; \ + qapiData.replyobj =3D rplobj; \ + if (virTestRun("qapi schema query" nme, testQAPISchemaQuery, &qapi= Data) < 0)\ + ret =3D -1; \ + } while (0) + + DO_TEST_QAPI_QUERY("command", "blockdev-add", 0, true); + DO_TEST_QAPI_QUERY("event", "RTC_CHANGE", 0, true); + DO_TEST_QAPI_QUERY("object property", "screendump/arg-type/device", 0,= true); + DO_TEST_QAPI_QUERY("optional property", "block-commit/arg-type/*top", = 0, true); + DO_TEST_QAPI_QUERY("variant", "blockdev-add/arg-type/+file", 0, true); + DO_TEST_QAPI_QUERY("variant property", "blockdev-add/arg-type/+file/fi= lename", 0, true); + + DO_TEST_QAPI_QUERY("nonexistent command", "nonexistent", 0, false); + DO_TEST_QAPI_QUERY("nonexistent attr", "screendump/arg-type/nonexisten= t", 0, false); + DO_TEST_QAPI_QUERY("nonexistent variant", "blockdev-add/arg-type/+none= xistent", 0, false); + +#undef DO_TEST_QAPI_QUERY + + #define DO_TEST_QAPI_VALIDATE(nme, rootquery, scc, jsonstr) \ do { \ qapiData.name =3D nme; \ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list