From nobody Sun Feb 8 22:08:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1631177392; cv=none; d=zohomail.com; s=zohoarc; b=CIZ9Bv7fwve1IMP0T91TmgZcYv6NF3KO19CgQg73hVZbc3+llLPdsEoB+w2+RDtULQqRJ7ryLSiBR9BNcYwKC/wZ4qQxsCUX4anPYDhLwR3Lovhfrjf9JD/qTePF3lx2Cp7/OAZtGaTf6gvw1Dhwpn8CfHm86rTqco3SSGcuF54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631177392; 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=bNfzxFH8/4EYE0SV+pnUMA/gSI1HRU78jMxJoAdN7D0=; b=OtCco8INdQBWrYq/RtSP5uGwILRVoogUpbLYJp2rynEZPxmBxzUj62rXyGXlMFtJ/W/3db748r1NAVsX57U0Kb4KiPB9QiWX8nZp4FPrH2cHYNND0wxYgjrRFJkP7+a/4atVDmcd6YHJsMO4kuvAzSneBWYq/7k/LKHQO7KwOoA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1631177392878921.6750870227937; Thu, 9 Sep 2021 01:49:52 -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-352-BYakmhv1MPu2BvlX4UImrg-1; Thu, 09 Sep 2021 04:49:45 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 909E4802C89; Thu, 9 Sep 2021 08:49:39 +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 419FA19D9B; 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 0E5FB4EA39; 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 1898naHD030097 for ; Thu, 9 Sep 2021 04:49:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E4CC19D9B; Thu, 9 Sep 2021 08:49:36 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3D9B19736 for ; Thu, 9 Sep 2021 08:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631177391; 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=bNfzxFH8/4EYE0SV+pnUMA/gSI1HRU78jMxJoAdN7D0=; b=NES4ZkbEchXmmmQCmkWlZUcQkmBJKL9JxLdSYqkr+tj1JSZQgzwrBtnmlqWZW3nWoA5yh9 Tu3dLcgjXMwUR4SFIVAIWtD1MrYEYEHivCBxAXMpOao0EslpCYb85Fx3zgDlBG59jyhcZn YA4DPlPTjN9GA+A0Hmyf2fK0ju4uWy0= X-MC-Unique: BYakmhv1MPu2BvlX4UImrg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/24] virstoragetest: Rework TEST_LOOKUP* cases to work on fake backing chain Date: Thu, 9 Sep 2021 10:49:06 +0200 Message-Id: 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.84 on 10.5.11.23 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: 1631177393337100001 Content-Type: text/plain; charset="utf-8" Rather than using 'qemu-img' and rewriting the chain we can use fake data and few empty files to ensure the same level of coverage. This is possible since we've already tested that the metadata parsing from files works properly and the only thing we are testing here is that the symlink resolution works properly. Additionally after the refactor of 'virstoragetest' is complete additional tests on real data will be added. Signed-off-by: Peter Krempa --- tests/virstoragetest.c | 140 ++++++++++------------ tests/virstoragetestdata/lookup/qcow2 | 0 tests/virstoragetestdata/lookup/raw | 0 tests/virstoragetestdata/lookup/sub/link2 | 1 + tests/virstoragetestdata/lookup/wrap | 0 5 files changed, 63 insertions(+), 78 deletions(-) create mode 100644 tests/virstoragetestdata/lookup/qcow2 create mode 100644 tests/virstoragetestdata/lookup/raw create mode 120000 tests/virstoragetestdata/lookup/sub/link2 create mode 100644 tests/virstoragetestdata/lookup/wrap diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index a3f9c537e5..299b16e119 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -499,10 +499,11 @@ mymain(void) struct testLookupData data2; struct testPathRelativeBacking data4; struct testBackingParseData data5; - virStorageSource *chain2; /* short for chain->backingStore */ - virStorageSource *chain3; /* short for chain2->backingStore */ + virStorageSource fakeChain[4]; + virStorageSource *chain =3D &fakeChain[0]; + virStorageSource *chain2 =3D &fakeChain[1]; + virStorageSource *chain3 =3D &fakeChain[2]; g_autoptr(virCommand) cmd =3D NULL; - g_autoptr(virStorageSource) chain =3D NULL; if (storageRegisterAll() < 0) return EXIT_FAILURE; @@ -622,22 +623,29 @@ mymain(void) /* Behavior of an infinite loop chain */ TEST_CHAIN("qcow2-qcow2_infinite-mutual", abswrap, VIR_STORAGE_FILE_QC= OW2, EXP_FAIL); - /* Rewrite wrap and qcow2 back to 3-deep chain, absolute backing */ - virCommandFree(cmd); - cmd =3D virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", absraw, "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret =3D -1; - - /* Test behavior of chain lookups, absolute backing from relative star= t */ - chain =3D testStorageFileGetMetadata("wrap", VIR_STORAGE_FILE_QCOW2, - -1, -1); - if (!chain) { - ret =3D -1; + /* setup data for backing chain lookup testing */ + if (chdir(abs_srcdir "/virstoragetestdata/lookup") < 0) { + fprintf(stderr, "unable to test relative backing chains\n"); goto cleanup; } - chain2 =3D chain->backingStore; - chain3 =3D chain2->backingStore; + + memset(fakeChain, 0, sizeof(fakeChain)); + fakeChain[0].backingStore =3D &fakeChain[1]; + fakeChain[1].backingStore =3D &fakeChain[2]; + fakeChain[2].backingStore =3D &fakeChain[3]; + + fakeChain[0].type =3D VIR_STORAGE_TYPE_FILE; + fakeChain[1].type =3D VIR_STORAGE_TYPE_FILE; + fakeChain[2].type =3D VIR_STORAGE_TYPE_FILE; + + fakeChain[0].format =3D VIR_STORAGE_FILE_QCOW2; + fakeChain[1].format =3D VIR_STORAGE_FILE_QCOW2; + fakeChain[2].format =3D VIR_STORAGE_FILE_RAW; + + /* backing chain with relative start and absolute backing paths */ + fakeChain[0].path =3D (char *) "wrap"; + fakeChain[1].path =3D (char *) abs_srcdir "/virstoragetestdata/lookup/= qcow2"; + fakeChain[2].path =3D (char *) abs_srcdir "/virstoragetestdata/lookup/= raw"; #define TEST_LOOKUP_TARGET(id, target, from, name, index, meta, parent) \ do { \ @@ -654,111 +662,87 @@ mymain(void) 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(5, NULL, abs_srcdir "/virstoragetestdata/lookup/wrap", cha= in, NULL); + TEST_LOOKUP(6, chain, abs_srcdir "/virstoragetestdata/lookup/wrap", NU= LL, NULL); + TEST_LOOKUP(7, chain2, abs_srcdir "/virstoragetestdata/lookup/wrap", N= ULL, 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(12, NULL, abs_srcdir "/virstoragetestdata/lookup/qcow2", c= hain2, chain); + TEST_LOOKUP(13, chain, abs_srcdir "/virstoragetestdata/lookup/qcow2", = chain2, chain); + TEST_LOOKUP(14, chain2, abs_srcdir "/virstoragetestdata/lookup/qcow2",= NULL, NULL); + TEST_LOOKUP(15, chain3, abs_srcdir "/virstoragetestdata/lookup/qcow2",= 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(20, NULL, abs_srcdir "/virstoragetestdata/lookup/raw", cha= in3, chain2); + TEST_LOOKUP(21, chain, abs_srcdir "/virstoragetestdata/lookup/raw", ch= ain3, chain2); + TEST_LOOKUP(22, chain2, abs_srcdir "/virstoragetestdata/lookup/raw", c= hain3, chain2); + TEST_LOOKUP(23, chain3, abs_srcdir "/virstoragetestdata/lookup/raw", N= ULL, 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); - cmd =3D virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", "raw", "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret =3D -1; + /* relative backing, absolute start */ + fakeChain[0].path =3D (char *) abs_srcdir "/virstoragetestdata/lookup/= wrap"; - virCommandFree(cmd); - cmd =3D virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "qcow2", "-b", "qcow2", "wrap", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret =3D -1; - - /* Test behavior of chain lookups, relative backing from absolute star= t */ - virObjectUnref(chain); - chain =3D testStorageFileGetMetadata(abswrap, VIR_STORAGE_FILE_QCOW2, = -1, -1); - if (!chain) { - ret =3D -1; - goto cleanup; - } - chain2 =3D chain->backingStore; - chain3 =3D chain2->backingStore; + fakeChain[1].relPath =3D (char *) "qcow2"; + fakeChain[2].relPath =3D (char *) "raw"; 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(33, NULL, abs_srcdir "/virstoragetestdata/lookup/wrap", ch= ain, NULL); + TEST_LOOKUP(34, chain, abs_srcdir "/virstoragetestdata/lookup/wrap", N= ULL, NULL); + TEST_LOOKUP(35, chain2, abs_srcdir "/virstoragetestdata/lookup/wrap", = 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(40, NULL, abs_srcdir "/virstoragetestdata/lookup/qcow2", c= hain2, chain); + TEST_LOOKUP(41, chain, abs_srcdir "/virstoragetestdata/lookup/qcow2", = chain2, chain); + TEST_LOOKUP(42, chain2, abs_srcdir "/virstoragetestdata/lookup/qcow2",= NULL, NULL); + TEST_LOOKUP(43, chain3, abs_srcdir "/virstoragetestdata/lookup/qcow2",= 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(48, NULL, abs_srcdir "/virstoragetestdata/lookup/raw", cha= in3, chain2); + TEST_LOOKUP(49, chain, abs_srcdir "/virstoragetestdata/lookup/raw", ch= ain3, chain2); + TEST_LOOKUP(50, chain2, abs_srcdir "/virstoragetestdata/lookup/raw", c= hain3, chain2); + TEST_LOOKUP(51, chain3, abs_srcdir "/virstoragetestdata/lookup/raw", N= ULL, 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); - cmd =3D virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "qcow2", "-b", "../qcow2", "wrap", NU= LL); - if (virCommandRun(cmd, NULL) < 0) - ret =3D -1; + fakeChain[0].path =3D (char *) abs_srcdir "/virstoragetestdata/lookup/= sub/link2"; - /* Test behavior of chain lookups, relative backing */ - virObjectUnref(chain); - chain =3D testStorageFileGetMetadata("sub/link2", VIR_STORAGE_FILE_QCO= W2, - -1, -1); - if (!chain) { - ret =3D -1; - goto cleanup; - } - chain2 =3D chain->backingStore; - chain3 =3D chain2->backingStore; + fakeChain[1].relPath =3D (char *) "../qcow2"; + fakeChain[2].relPath =3D (char *) "raw"; 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(59, NULL, abs_srcdir "/virstoragetestdata/lookup/wrap", ch= ain, NULL); TEST_LOOKUP(60, NULL, "../qcow2", chain2, chain); TEST_LOOKUP(61, NULL, "qcow2", NULL, NULL); - TEST_LOOKUP(62, NULL, absqcow2, chain2, chain); + TEST_LOOKUP(62, NULL, abs_srcdir "/virstoragetestdata/lookup/qcow2", c= hain2, chain); TEST_LOOKUP(63, NULL, "raw", chain3, chain2); - TEST_LOOKUP(64, NULL, absraw, chain3, chain2); + TEST_LOOKUP(64, NULL, abs_srcdir "/virstoragetestdata/lookup/raw", cha= in3, chain2); TEST_LOOKUP(65, NULL, NULL, chain3, chain2); + /* index lookup */ + fakeChain[0].id =3D 0; + fakeChain[1].id =3D 1; + fakeChain[2].id =3D 2; + 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); diff --git a/tests/virstoragetestdata/lookup/qcow2 b/tests/virstoragetestda= ta/lookup/qcow2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/virstoragetestdata/lookup/raw b/tests/virstoragetestdata= /lookup/raw new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/virstoragetestdata/lookup/sub/link2 b/tests/virstoragete= stdata/lookup/sub/link2 new file mode 120000 index 0000000000..5efbc33afa --- /dev/null +++ b/tests/virstoragetestdata/lookup/sub/link2 @@ -0,0 +1 @@ +../wrap \ No newline at end of file diff --git a/tests/virstoragetestdata/lookup/wrap b/tests/virstoragetestdat= a/lookup/wrap new file mode 100644 index 0000000000..e69de29bb2 --=20 2.31.1