From nobody Mon Feb 9 01:22:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1631177388; cv=none; d=zohomail.com; s=zohoarc; b=F7Dbpa2YzgcdGP1IPgBLXTIR3dSsffJjtyyxDnRlTBUgJ38UhP8gXP4XcZYx2ztmbP6RSjgdp6BfNEdIE+YcCbDCz6ovvCRZn+mf3PKSi7iyTCiNG8TmAiuZ88wOVA5+mpIl7CyWd3sD71CQRVFdOwi6nXBPNZ7LEoPjwGj2Gs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631177388; 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=lWYTYgDQDBz5z7PfKJlOnImNpNxUPV76TEkRj8FrUmo=; b=g1qhnloyVVPSJj2yvgMTy2gOkei2lDoVvd9UipzngbiwXfFnGt3g835lGeLQYTlHuM5KMlS6NOmQs54sn/piOwvzRjonqw4+SJmiNXWn/v6ZusAxSZ3ugtHTONCEL8P9OAJRIg9C5kGIgdqyfGbVZHSWgNYRNKCXBUZ5D7aCv7U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631177388490581.4921974364511; Thu, 9 Sep 2021 01:49:48 -0700 (PDT) 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-125-VlNn1LgwOFq6XD6Oy9RJzw-1; Thu, 09 Sep 2021 04:49:46 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC3E91006AB1; Thu, 9 Sep 2021 08:49:39 +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 A04546F7F0; Thu, 9 Sep 2021 08:49:39 +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 43E391806D03; Thu, 9 Sep 2021 08:49:39 +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 1898nZMW030090 for ; Thu, 9 Sep 2021 04:49:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 80DC619736; Thu, 9 Sep 2021 08:49:35 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id D469119D9B for ; Thu, 9 Sep 2021 08:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631177387; 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=lWYTYgDQDBz5z7PfKJlOnImNpNxUPV76TEkRj8FrUmo=; b=BHUR/hU2E5+pvmc7UP7aUIe1hDY6O7LkLTKHlvDJDI8LBFBNIt/1BEtV+PSXmy8Edi62yq vFR2ySGUY2Ejy8BJyqVW3xFIQmK+Na8Wo+mrpUvYNg7dF0mR3JnUJz3k/WMLH24d/U4VpK QbTuDovQTTwCVGuGf2HBAXPI/rjMJIQ= X-MC-Unique: VlNn1LgwOFq6XD6Oy9RJzw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/24] virstoragetest: Remove redundant arguments for chain lookup tests Date: Thu, 9 Sep 2021 10:49:05 +0200 Message-Id: <7c996bf229db80089f5bcd31e70b198feabea59e.1631177237.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 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1631177389209100001 Content-Type: text/plain; charset="utf-8" Passing in both "chain*" and "chain*->path" is pointless. Use only the full struct which we can use to infer the rest. Signed-off-by: Peter Krempa --- tests/virstoragetest.c | 201 +++++++++++++++++++---------------------- 1 file changed, 94 insertions(+), 107 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 4f4fd4e824..a3f9c537e5 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -303,7 +303,6 @@ struct testLookupData virStorageSource *from; const char *name; unsigned int expIndex; - const char *expResult; virStorageSource *expMeta; virStorageSource *expParent; }; @@ -318,25 +317,16 @@ testStorageLookup(const void *args) result =3D virStorageSourceChainLookup(data->chain, data->from, data->name, data->target, &actual= Parent); - if (!data->expResult) + if (!data->expMeta) virResetLastError(); - if (!result) { - if (data->expResult) { - fprintf(stderr, "result: expected %s, got NULL\n", - data->expResult); - ret =3D -1; - } - } else if (STRNEQ_NULLABLE(data->expResult, result->path)) { - fprintf(stderr, "result: expected %s, got %s\n", - NULLSTR(data->expResult), NULLSTR(result->path)); - ret =3D -1; - } if (data->expMeta !=3D result) { - fprintf(stderr, "meta: expected %p, got %p\n", - data->expMeta, result); + fprintf(stderr, "meta: expected %s, got %s\n", + NULLSTR(data->expMeta ? data->expMeta->path : NULL), + NULLSTR(result ? result->path : NULL)); ret =3D -1; } + if (data->expIndex > 0) { if (!result) { fprintf(stderr, "index: resulting lookup is empty, can't match= index\n"); @@ -649,47 +639,44 @@ mymain(void) chain2 =3D chain->backingStore; chain3 =3D chain2->backingStore; -#define TEST_LOOKUP_TARGET(id, target, from, name, index, result, \ - meta, parent) \ +#define TEST_LOOKUP_TARGET(id, target, from, name, index, meta, parent) \ do { \ data2 =3D (struct testLookupData){ \ - chain, target, from, name, index, \ - result, meta, parent, }; \ - if (virTestRun("Chain lookup " #id, \ - testStorageLookup, &data2) < 0) \ + chain, target, from, name, index, meta, parent, }; \ + if (virTestRun("Chain lookup " #id, testStorageLookup, &data2) < 0= ) \ ret =3D -1; \ } while (0) -#define TEST_LOOKUP(id, from, name, result, meta, parent) \ - TEST_LOOKUP_TARGET(id, NULL, from, name, 0, result, meta, parent) - - TEST_LOOKUP(0, NULL, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(1, chain, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(2, NULL, "wrap", chain->path, chain, NULL); - TEST_LOOKUP(3, chain, "wrap", NULL, NULL, NULL); - TEST_LOOKUP(4, chain2, "wrap", NULL, NULL, NULL); - TEST_LOOKUP(5, NULL, abswrap, chain->path, chain, NULL); - TEST_LOOKUP(6, chain, abswrap, NULL, NULL, NULL); - TEST_LOOKUP(7, chain2, abswrap, NULL, NULL, NULL); - TEST_LOOKUP(8, NULL, "qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(9, chain, "qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(10, chain2, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(11, chain3, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(12, NULL, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(13, chain, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(14, chain2, absqcow2, NULL, NULL, NULL); - TEST_LOOKUP(15, chain3, absqcow2, NULL, NULL, NULL); - TEST_LOOKUP(16, NULL, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(17, chain, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(18, chain2, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(19, chain3, "raw", NULL, NULL, NULL); - TEST_LOOKUP(20, NULL, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(21, chain, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(22, chain2, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(23, chain3, absraw, NULL, NULL, NULL); - TEST_LOOKUP(24, NULL, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(25, chain, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(26, chain2, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(27, chain3, NULL, NULL, NULL, NULL); +#define TEST_LOOKUP(id, from, name, meta, parent) \ + TEST_LOOKUP_TARGET(id, NULL, from, name, 0, meta, parent) + + TEST_LOOKUP(0, NULL, "bogus", NULL, NULL); + TEST_LOOKUP(1, chain, "bogus", NULL, NULL); + TEST_LOOKUP(2, NULL, "wrap", chain, NULL); + TEST_LOOKUP(3, chain, "wrap", NULL, NULL); + TEST_LOOKUP(4, chain2, "wrap", NULL, NULL); + TEST_LOOKUP(5, NULL, abswrap, chain, NULL); + TEST_LOOKUP(6, chain, abswrap, NULL, NULL); + TEST_LOOKUP(7, chain2, abswrap, NULL, NULL); + TEST_LOOKUP(8, NULL, "qcow2", chain2, chain); + TEST_LOOKUP(9, chain, "qcow2", chain2, chain); + TEST_LOOKUP(10, chain2, "qcow2", NULL, NULL); + TEST_LOOKUP(11, chain3, "qcow2", NULL, NULL); + TEST_LOOKUP(12, NULL, absqcow2, chain2, chain); + TEST_LOOKUP(13, chain, absqcow2, chain2, chain); + TEST_LOOKUP(14, chain2, absqcow2, NULL, NULL); + TEST_LOOKUP(15, chain3, absqcow2, NULL, NULL); + TEST_LOOKUP(16, NULL, "raw", chain3, chain2); + TEST_LOOKUP(17, chain, "raw", chain3, chain2); + TEST_LOOKUP(18, chain2, "raw", chain3, chain2); + TEST_LOOKUP(19, chain3, "raw", NULL, NULL); + TEST_LOOKUP(20, NULL, absraw, chain3, chain2); + TEST_LOOKUP(21, chain, absraw, chain3, chain2); + TEST_LOOKUP(22, chain2, absraw, chain3, chain2); + TEST_LOOKUP(23, chain3, absraw, NULL, NULL); + TEST_LOOKUP(24, NULL, NULL, chain3, chain2); + TEST_LOOKUP(25, chain, NULL, chain3, chain2); + TEST_LOOKUP(26, chain2, NULL, chain3, chain2); + TEST_LOOKUP(27, chain3, NULL, NULL, NULL); /* Rewrite wrap and qcow2 back to 3-deep chain, relative backing */ virCommandFree(cmd); @@ -714,34 +701,34 @@ mymain(void) chain2 =3D chain->backingStore; chain3 =3D chain2->backingStore; - TEST_LOOKUP(28, NULL, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(29, chain, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(30, NULL, "wrap", chain->path, chain, NULL); - TEST_LOOKUP(31, chain, "wrap", NULL, NULL, NULL); - TEST_LOOKUP(32, chain2, "wrap", NULL, NULL, NULL); - TEST_LOOKUP(33, NULL, abswrap, chain->path, chain, NULL); - TEST_LOOKUP(34, chain, abswrap, NULL, NULL, NULL); - TEST_LOOKUP(35, chain2, abswrap, NULL, NULL, NULL); - TEST_LOOKUP(36, NULL, "qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(37, chain, "qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(38, chain2, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(39, chain3, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(40, NULL, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(41, chain, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(42, chain2, absqcow2, NULL, NULL, NULL); - TEST_LOOKUP(43, chain3, absqcow2, NULL, NULL, NULL); - TEST_LOOKUP(44, NULL, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(45, chain, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(46, chain2, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(47, chain3, "raw", NULL, NULL, NULL); - TEST_LOOKUP(48, NULL, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(49, chain, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(50, chain2, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(51, chain3, absraw, NULL, NULL, NULL); - TEST_LOOKUP(52, NULL, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(53, chain, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(54, chain2, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(55, chain3, NULL, NULL, NULL, NULL); + TEST_LOOKUP(28, NULL, "bogus", NULL, NULL); + TEST_LOOKUP(29, chain, "bogus", NULL, NULL); + TEST_LOOKUP(30, NULL, "wrap", chain, NULL); + TEST_LOOKUP(31, chain, "wrap", NULL, NULL); + TEST_LOOKUP(32, chain2, "wrap", NULL, NULL); + TEST_LOOKUP(33, NULL, abswrap, chain, NULL); + TEST_LOOKUP(34, chain, abswrap, NULL, NULL); + TEST_LOOKUP(35, chain2, abswrap, NULL, NULL); + TEST_LOOKUP(36, NULL, "qcow2", chain2, chain); + TEST_LOOKUP(37, chain, "qcow2", chain2, chain); + TEST_LOOKUP(38, chain2, "qcow2", NULL, NULL); + TEST_LOOKUP(39, chain3, "qcow2", NULL, NULL); + TEST_LOOKUP(40, NULL, absqcow2, chain2, chain); + TEST_LOOKUP(41, chain, absqcow2, chain2, chain); + TEST_LOOKUP(42, chain2, absqcow2, NULL, NULL); + TEST_LOOKUP(43, chain3, absqcow2, NULL, NULL); + TEST_LOOKUP(44, NULL, "raw", chain3, chain2); + TEST_LOOKUP(45, chain, "raw", chain3, chain2); + TEST_LOOKUP(46, chain2, "raw", chain3, chain2); + TEST_LOOKUP(47, chain3, "raw", NULL, NULL); + TEST_LOOKUP(48, NULL, absraw, chain3, chain2); + TEST_LOOKUP(49, chain, absraw, chain3, chain2); + TEST_LOOKUP(50, chain2, absraw, chain3, chain2); + TEST_LOOKUP(51, chain3, absraw, NULL, NULL); + TEST_LOOKUP(52, NULL, NULL, chain3, chain2); + TEST_LOOKUP(53, chain, NULL, chain3, chain2); + TEST_LOOKUP(54, chain2, NULL, chain3, chain2); + TEST_LOOKUP(55, chain3, NULL, NULL, NULL); /* Use link to wrap with cross-directory relative backing */ virCommandFree(cmd); @@ -761,33 +748,33 @@ mymain(void) chain2 =3D chain->backingStore; chain3 =3D chain2->backingStore; - TEST_LOOKUP(56, NULL, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(57, NULL, "sub/link2", chain->path, chain, NULL); - TEST_LOOKUP(58, NULL, "wrap", chain->path, chain, NULL); - TEST_LOOKUP(59, NULL, abswrap, chain->path, chain, NULL); - TEST_LOOKUP(60, NULL, "../qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(61, NULL, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(62, NULL, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(63, NULL, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(64, NULL, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(65, NULL, NULL, chain3->path, chain3, chain2); - - TEST_LOOKUP_TARGET(66, "vda", NULL, "bogus[1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(67, "vda", NULL, "vda[-1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(68, "vda", NULL, "vda[1][1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(69, "vda", NULL, "wrap", 0, chain->path, chain, NUL= L); - TEST_LOOKUP_TARGET(70, "vda", chain, "wrap", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(71, "vda", chain2, "wrap", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(72, "vda", NULL, "vda[0]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(73, "vda", NULL, "vda[1]", 1, chain2->path, chain2,= chain); - TEST_LOOKUP_TARGET(74, "vda", chain, "vda[1]", 1, chain2->path, chain2= , chain); - TEST_LOOKUP_TARGET(75, "vda", chain2, "vda[1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(76, "vda", chain3, "vda[1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(77, "vda", NULL, "vda[2]", 2, chain3->path, chain3,= chain2); - TEST_LOOKUP_TARGET(78, "vda", chain, "vda[2]", 2, chain3->path, chain3= , chain2); - TEST_LOOKUP_TARGET(79, "vda", chain2, "vda[2]", 2, chain3->path, chain= 3, chain2); - TEST_LOOKUP_TARGET(80, "vda", chain3, "vda[2]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(81, "vda", NULL, "vda[3]", 0, NULL, NULL, NULL); + TEST_LOOKUP(56, NULL, "bogus", NULL, NULL); + TEST_LOOKUP(57, NULL, "sub/link2", chain, NULL); + TEST_LOOKUP(58, NULL, "wrap", chain, NULL); + TEST_LOOKUP(59, NULL, abswrap, chain, NULL); + TEST_LOOKUP(60, NULL, "../qcow2", chain2, chain); + TEST_LOOKUP(61, NULL, "qcow2", NULL, NULL); + TEST_LOOKUP(62, NULL, absqcow2, chain2, chain); + TEST_LOOKUP(63, NULL, "raw", chain3, chain2); + TEST_LOOKUP(64, NULL, absraw, chain3, chain2); + TEST_LOOKUP(65, NULL, NULL, chain3, chain2); + + TEST_LOOKUP_TARGET(66, "vda", NULL, "bogus[1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(67, "vda", NULL, "vda[-1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(68, "vda", NULL, "vda[1][1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(69, "vda", NULL, "wrap", 0, chain, NULL); + TEST_LOOKUP_TARGET(70, "vda", chain, "wrap", 0, NULL, NULL); + TEST_LOOKUP_TARGET(71, "vda", chain2, "wrap", 0, NULL, NULL); + TEST_LOOKUP_TARGET(72, "vda", NULL, "vda[0]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(73, "vda", NULL, "vda[1]", 1, chain2, chain); + TEST_LOOKUP_TARGET(74, "vda", chain, "vda[1]", 1, chain2, chain); + TEST_LOOKUP_TARGET(75, "vda", chain2, "vda[1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(76, "vda", chain3, "vda[1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(77, "vda", NULL, "vda[2]", 2, chain3, chain2); + TEST_LOOKUP_TARGET(78, "vda", chain, "vda[2]", 2, chain3, chain2); + TEST_LOOKUP_TARGET(79, "vda", chain2, "vda[2]", 2, chain3, chain2); + TEST_LOOKUP_TARGET(80, "vda", chain3, "vda[2]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(81, "vda", NULL, "vda[3]", 0, NULL, NULL); #define TEST_RELATIVE_BACKING(id, TOP, BASE, EXPECT) \ do { \ --=20 2.31.1