From nobody Tue Nov 26 13:31:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.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=1574161762; cv=none; d=zoho.com; s=zohoarc; b=YGOJyiKk5mhyCoV7c15ugrw1kTwyOOEeq8c1PPYMBn9HFb045yvzl5rmwtrJjk0ghqsjudEopEgc0r5AzuW0ewX4Kc6c1aVB0KL0meysV2z3H5Pn6SAsqWO0H5zaT3xwl8yQ+KsX0wzBRktG7nJB8FGanyCBvuscWHUVY5kKDds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574161762; 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; bh=Gwvs4wa8kQoT3FPsG03TLQf1ZUzKQkGklRKocSOIiSY=; b=D1Xce7p4wY+Jt1NBcDn7wmSkjan0Zv4hA1vsY43bijgO/c4oMH8yaMwObnIrjSeOvaxhZbcg3ihD1SLhz4D7073cGmNC5p3FTR4bLWBHXmGkYfrsw6W/Y74fcxr76GT4cZqESLyTG+d/1q4IoCu7o4/sd3D0S5YBVeuIXMaDtBs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1574161762377370.6312859717791; Tue, 19 Nov 2019 03:09:22 -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-172-8RDbeQy4MqmfV_RoqLuMow-1; Tue, 19 Nov 2019 06:09:19 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 52304801E76; Tue, 19 Nov 2019 11:09:14 +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 2A4FB46E67; Tue, 19 Nov 2019 11:09:14 +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 D870E1808878; Tue, 19 Nov 2019 11:09:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAJB8qa0021158 for ; Tue, 19 Nov 2019 06:08:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 191812935D; Tue, 19 Nov 2019 11:08:52 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97F0B2935A for ; Tue, 19 Nov 2019 11:08:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574161761; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=Gwvs4wa8kQoT3FPsG03TLQf1ZUzKQkGklRKocSOIiSY=; b=QECVthxsf54BlsRKO4J7SyDr+84T/Fm0vQTxei5AJIuhNMBTU56+kp5DCxhJ+lZg+zpDOA a9dDeFGvLKO00MYo/E/oGVYaf7S//IGHMrWeesJA1TAr6zkp/9Lho4Srhr4/+0xwqGqxIX cT6nWbDoi9P+KGWEoHyd7FHcMC1lxq4= From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 19 Nov 2019 12:08:45 +0100 Message-Id: <0bb889a2aa1a0e79308ed092025b7f6fa5a801b0.1574161682.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] tests: utils: Introduce helper for dispatching libvirt errors 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.15 X-MC-Unique: 8RDbeQy4MqmfV_RoqLuMow-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In cases when we call a libvirt helper which reports an error the error would be hidden unless libvirt library debug is on. This produces a lot of output and is hard to debug. The helper provides a way to dispatch the libvirt error in specific cases sice we do already dispatch it in case when virTestRun is used. Signed-off-by: Peter Krempa --- tests/testutils.c | 29 +++++++++++++++++++++++++---- tests/testutils.h | 1 + 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index f5d8487736..d9c0d5abbe 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -81,6 +81,30 @@ virTestGetFlag(const char *name) } +/** + * virTestPropagateLibvirtError: + * + * In cases when a libvirt utility function which reports libvirt errors is + * used in the test suite outside of the virTestRun call and the failure o= f such + * a function would cause an test failure the error message reported by th= at + * function will not be propagated to the user as the error callback is not + * invoked. + * + * In cases when the error message may be beneficial in debugging this hel= per + * provides means to dispatch the errors including invocation of the error + * callback. + */ +void +virTestPropagateLibvirtError(void) +{ + if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) + return; + + if (virTestGetVerbose() || virTestGetDebug()) + virDispatchError(NULL); +} + + /* * Runs test * @@ -112,10 +136,7 @@ virTestRun(const char *title, virResetLastError(); ret =3D body(data); - if (virGetLastErrorCode()) { - if (virTestGetVerbose() || virTestGetDebug()) - virDispatchError(NULL); - } + virTestPropagateLibvirtError(); if (virTestGetVerbose()) { if (ret =3D=3D 0) diff --git a/tests/testutils.h b/tests/testutils.h index 0088251dca..76090c5522 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -84,6 +84,7 @@ unsigned int virTestGetDebug(void); unsigned int virTestGetVerbose(void); unsigned int virTestGetExpensive(void); unsigned int virTestGetRegenerate(void); +void virTestPropagateLibvirtError(void); #define VIR_TEST_DEBUG(fmt, ...) \ do { \ --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list