From nobody Sun May 5 07:26:22 2024 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 1553587343642975.5914679659812; Tue, 26 Mar 2019 01:02:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39098356EA; Tue, 26 Mar 2019 08:02:22 +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 7B4422636E; Tue, 26 Mar 2019 08:02:21 +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 6F7DD18005C9; Tue, 26 Mar 2019 08:02:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2Q82JWB022200 for ; Tue, 26 Mar 2019 04:02:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0B26862669; Tue, 26 Mar 2019 08:02:19 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 880575B6BF for ; Tue, 26 Mar 2019 08:02:16 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 26 Mar 2019 09:02:14 +0100 Message-Id: <18a42da8846a73f082d3c6aa4853e0133a83b7ea.1553587288.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemufirmwaretest: Produce better message on error 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 26 Mar 2019 08:02:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If qemuFirmwareFetchConfigs() returned more or less paths than expected all that we see is the following error message: Expected 5 paths, got 7 While it is technically correct (the best kind of correct), we can do better: Unexpected path (i=3D0). Expected /some/path got /some/other/path Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- tests/qemufirmwaretest.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c index 340344ebba..2b5cbf649b 100644 --- a/tests/qemufirmwaretest.c +++ b/tests/qemufirmwaretest.c @@ -66,6 +66,7 @@ testFWPrecedence(const void *opaque ATTRIBUTE_UNUSED) PREFIX "/share/qemu/firmware/61-ovmf.json", PREFIX "/share/qemu/firmware/70-aavmf.json", }; + const size_t nexpected =3D ARRAY_CARDINALITY(expected); =20 if (VIR_STRDUP(fakehome, abs_srcdir "/qemufirmwaredata/home/user/.conf= ig") < 0) return -1; @@ -81,17 +82,15 @@ testFWPrecedence(const void *opaque ATTRIBUTE_UNUSED) } =20 nfwList =3D virStringListLength((const char **)fwList); - if (nfwList !=3D ARRAY_CARDINALITY(expected)) { - fprintf(stderr, "Expected %zu paths, got %zu\n", - ARRAY_CARDINALITY(expected), nfwList); - return -1; - } =20 - for (i =3D 0; i < ARRAY_CARDINALITY(expected); i++) { - if (STRNEQ_NULLABLE(expected[i], fwList[i])) { + for (i =3D 0; i < MAX(nfwList, nexpected); i++) { + const char *e =3D i < nexpected ? expected[i] : NULL; + const char *f =3D i < nfwList ? fwList[i] : NULL; + + if (STRNEQ_NULLABLE(e, f)) { fprintf(stderr, "Unexpected path (i=3D%zu). Expected %s got %s \n", - i, expected[i], NULLSTR(fwList[i])); + i, NULLSTR(e), NULLSTR(f)); return -1; } } --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list