From nobody Wed May 14 14:03:00 2025 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 1524065687611431.04406924246337; Wed, 18 Apr 2018 08:34:47 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id DDD91326227B; Wed, 18 Apr 2018 15:34:45 +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 A905E81F0A; Wed, 18 Apr 2018 15:34:45 +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 52C0A180BAD4; Wed, 18 Apr 2018 15:34:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3IFXnUH009045 for ; Wed, 18 Apr 2018 11:33:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1821D1134CD3; Wed, 18 Apr 2018 15:33:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92C151134CCD; Wed, 18 Apr 2018 15:33:48 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Apr 2018 17:33:32 +0200 Message-Id: <8dc36077733036086b2dd99a924f47eee5c21033.1524065411.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v3 1/7] tests: qemu: Add helper code to lookup latest capability file 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 18 Apr 2018 15:34:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The helper iterates the directory with files for the capability test and looks up the most recent one for the given architecture. This will allow testing against the newest qemu capabilities so that we can catch regressions in behaviour more easily. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- tests/testutilsqemu.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ tests/testutilsqemu.h | 5 ++++ 2 files changed, 68 insertions(+) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 9671a46f12..3222d7864c 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -674,3 +674,66 @@ testQemuCapsSetGIC(virQEMUCapsPtr qemuCaps, } #endif + + +char * +testQemuGetLatestCapsForArch(const char *dirname, + const char *arch, + const char *suffix) +{ + struct dirent *ent; + DIR *dir =3D NULL; + int rc; + char *fullsuffix =3D NULL; + char *tmp =3D NULL; + unsigned long maxver =3D 0; + unsigned long ver; + const char *maxname =3D NULL; + char *ret =3D NULL; + + if (virAsprintf(&fullsuffix, "%s.%s", arch, suffix) < 0) + goto cleanup; + + if (virDirOpen(&dir, dirname) < 0) + goto cleanup; + + while ((rc =3D virDirRead(dir, &ent, dirname)) > 0) { + VIR_FREE(tmp); + + if ((rc =3D VIR_STRDUP(tmp, STRSKIP(ent->d_name, "caps_"))) < 0) + goto cleanup; + + if (rc =3D=3D 0) + continue; + + if (virFileStripSuffix(tmp, fullsuffix) !=3D 1) + continue; + + if (virParseVersionString(tmp, &ver, false) < 0) { + VIR_TEST_DEBUG("skipping caps file '%s'\n", ent->d_name); + continue; + } + + if (ver > maxver) { + maxname =3D ent->d_name; + maxver =3D ver; + } + } + + if (rc < 0) + goto cleanup; + + if (!maxname) { + VIR_TEST_VERBOSE("failed to find capabilities for '%s' in '%s'\n", + arch, dirname); + goto cleanup; + } + + ignore_value(virAsprintf(&ret, "%s/%s", dirname, maxname)); + + cleanup: + VIR_FREE(tmp); + VIR_FREE(fullsuffix); + virDirClose(&dir); + return ret; +} diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 7ae8324933..efb1baeadd 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -39,4 +39,9 @@ int qemuTestCapsCacheInsert(virFileCachePtr cache, int testQemuCapsSetGIC(virQEMUCapsPtr qemuCaps, int gic); + +char *testQemuGetLatestCapsForArch(const char *dirname, + const char *arch, + const char *suffix); + #endif --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list