From nobody Thu Nov 13 23:22:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1583253560; cv=none; d=zohomail.com; s=zohoarc; b=XRJTkKCw5ko5u92h3Yx4DyUUaGw/KmZQiufdVrhbt8hnHW8ItTZ/k06O5Re6un28g2+Dl/YOqlcAtVKyTTt4FuZB6gLxAIasUQZnrOqp8dMJWnqg4Urnh7SrRNvM9wIW0EZDOqjkasY4xYiBHUX3pE88rP/zw3FZT+rn66s1HWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253560; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=sW04fih2YXTfS8CLtTbDLCV2JzUFAWR4o8w8PMjp12g=; b=k3ZBoN3NjP1Ez0tK72+Jtk0GU4DAwsohaollRYPjb6COTlVX5D8ACW43xBL+QAGUeEIzX7c8XeqsWAm535DHOTxAb6zw4C2PY0hwo94AxjLJePJZdoILQ2jWaryz/RlwsHYEnB+1aIIwktUXkDR1/Zyuw4clAo0Y1O286q9RokQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583253560705973.9252492546162; Tue, 3 Mar 2020 08:39:20 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-AJ-CgI0XOOi2MbibbY5-Sw-1; Tue, 03 Mar 2020 11:35:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A82B4802563; Tue, 3 Mar 2020 16:35:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 721205C1D8; Tue, 3 Mar 2020 16:35:50 +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 11A6E1803C32; Tue, 3 Mar 2020 16:35:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZESh001240 for ; Tue, 3 Mar 2020 11:35:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5960660C05; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8EC9E60C84; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C26EA1135A4D; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253559; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sW04fih2YXTfS8CLtTbDLCV2JzUFAWR4o8w8PMjp12g=; b=bRsHIoTAQUaX2bqTJgzkCi5Bx4vSn8MtuRA5yi67V3/QRM9S4MmrBGKU/SKGvz0u5Qqyrv MmaDr4pRvT8g5xpS2udfNG0DB+cB49uROVwECD3Ryc1jLbtlQmOyh8LeHmg6yFGcYpXH5R 7VU6J/lyNSWHNVhAF4CTlE6LgF3+KgA= X-MC-Unique: AJ-CgI0XOOi2MbibbY5-Sw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 06/30] tests/test-qmp-cmds: Check responses more thoroughly Date: Tue, 3 Mar 2020 17:34:41 +0100 Message-Id: <20200303163505.32041-7-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- tests/test-qmp-cmds.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index b31064b064..464b370189 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -151,9 +151,10 @@ static QObject *do_qmp_dispatch(QDict *req, bool allow= _oob) QObject *ret; =20 resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); - g_assert(resp && !qdict_haskey(resp, "error")); + g_assert(resp); ret =3D qdict_get(resp, "return"); g_assert(ret); + g_assert(qdict_size(resp) =3D=3D 1); =20 qobject_ref(ret); qobject_unref(resp); @@ -163,9 +164,17 @@ static QObject *do_qmp_dispatch(QDict *req, bool allow= _oob) static void do_qmp_dispatch_error(QDict *req, bool allow_oob, ErrorClass c= ls) { QDict *resp; + QDict *error; =20 resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob); - g_assert(resp && qdict_haskey(resp, "error")); + g_assert(resp); + error =3D qdict_get_qdict(resp, "error"); + g_assert(error); + g_assert_cmpstr(qdict_get_try_str(error, "class"), + =3D=3D, QapiErrorClass_str(cls)); + g_assert(qdict_get_try_str(error, "desc")); + g_assert(qdict_size(error) =3D=3D 2); + g_assert(qdict_size(resp) =3D=3D 1); =20 qobject_unref(resp); } @@ -174,11 +183,12 @@ static void do_qmp_dispatch_error(QDict *req, bool al= low_oob, ErrorClass cls) static void test_dispatch_cmd(void) { QDict *req =3D qdict_new(); - QObject *ret; + QDict *ret; =20 qdict_put_str(req, "execute", "user_def_cmd"); =20 - ret =3D do_qmp_dispatch(req, false); + ret =3D qobject_to(QDict, do_qmp_dispatch(req, false)); + assert(ret && qdict_size(ret) =3D=3D 0); =20 qobject_unref(ret); qobject_unref(req); @@ -187,11 +197,12 @@ static void test_dispatch_cmd(void) static void test_dispatch_cmd_oob(void) { QDict *req =3D qdict_new(); - QObject *ret; + QDict *ret; =20 qdict_put_str(req, "exec-oob", "test-flags-command"); =20 - ret =3D do_qmp_dispatch(req, true); + ret =3D qobject_to(QDict, do_qmp_dispatch(req, true)); + assert(ret && qdict_size(ret) =3D=3D 0); =20 qobject_unref(ret); qobject_unref(req); --=20 2.21.1