From nobody Mon Feb 9 03:48:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1603110174; cv=none; d=zohomail.com; s=zohoarc; b=QO11lY5vJQ9ZlqBZvQO4Jpri0S5lpZyKCjUPbdkrmt2zdkT40AS/QjJTmXXMp5dBYSK0gK3Or69b/l3H4sOcr4BVWJ73d9Xkhfc6+lFAq7N/lAS2oMy/7TIyfhgW9ruG+vZ/6P33oixRjtvYcLpvcrTvLIhqiobUv4HpwIxY0Z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603110174; 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=S0JDCdleaOL4oMN4jRTI46XuBvtq5WR/lIEO9myZlsY=; b=nNO9mKP3m+opfbKpX8X3TmCtyM57JnfBICz/CMEcjkwv1a8xk+S/h9C3rTgkMN61hVcUrQsV+6mvS3lu3oUiYAYEd9W5PBjSbIJ/6NW9SqFwcNszB52R1+CVubTbKLg2pee2nViQQP5/WYdSl0zVmQj4jyccSG94kUQvu4EuG5g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603110174625733.6329972486124; Mon, 19 Oct 2020 05:22:54 -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-188-InQN0lr9P_GZaEafVXwDXQ-1; Mon, 19 Oct 2020 08:22:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 875BB84F226; Mon, 19 Oct 2020 12:22:44 +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 67A4E5D9D2; Mon, 19 Oct 2020 12:22:44 +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 36E6D8C7A8; Mon, 19 Oct 2020 12:22:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09JCMgcA001875 for ; Mon, 19 Oct 2020 08:22:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id AA7CB6198E; Mon, 19 Oct 2020 12:22:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6CC86198C for ; Mon, 19 Oct 2020 12:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603110173; 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=S0JDCdleaOL4oMN4jRTI46XuBvtq5WR/lIEO9myZlsY=; b=V8Mx5vhDqkRZ6jNlK6ZydzvRwZLMD4B6Fb10qWrhEDxCdJhj33NncsIV+SZ3mOxDM6rlAV VrXFZiEvmCLsFfusS8C+IRiWi9IpNw9iOZlx31aPEMhJ4ahuOldQHnOnGfnHuLM8Zn0Dr3 akwSuG/vp4cWPyPXHQL2ubkggfopEsI= X-MC-Unique: InQN0lr9P_GZaEafVXwDXQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 02/18] virschematest: Add regex filtering for directory contents Date: Mon, 19 Oct 2020 14:22:11 +0200 Message-Id: <8c700de246a2a15ab72f292afa4c3597401fd4f4.1603109876.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.14 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) Content-Type: text/plain; charset="utf-8" In some cases we have directories with mixed XML files in the test suite. Adding regex filtering will allow testing subsets of the XML files against schema. Signed-off-by: Peter Krempa --- tests/virschematest.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/virschematest.c b/tests/virschematest.c index e6e176eef3..7d7db3e354 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -32,6 +32,10 @@ VIR_LOG_INIT("tests.schematest"); struct testSchemaEntry { const char *dir; + /* if dirRegex is non-NULL the provided regular expression is used to = match + * the file names in a directory (without path prefixed) and only matc= hing + * files are validated */ + const char *dirRegex; const char *file; }; @@ -79,18 +83,29 @@ testSchemaFile(const char *schema, static int testSchemaDir(const char *schema, virXMLValidatorPtr validator, - const char *dir_path) + const char *dir_path, + const char *filterstr) { DIR *dir =3D NULL; struct dirent *ent; int ret =3D 0; int rc; + g_autoptr(GRegex) filter =3D NULL; if (virDirOpen(&dir, dir_path) < 0) { virTestPropagateLibvirtError(); return -1; } + if (filterstr) { + g_autoptr(GError) err =3D NULL; + + if (!(filter =3D g_regex_new(filterstr, 0, 0, &err))) { + VIR_TEST_VERBOSE("\nfailed to compile regex '%s': %s", filters= tr, err->message); + return -1; + } + } + while ((rc =3D virDirRead(dir, &ent, dir_path)) > 0) { g_autofree char *xml_path =3D NULL; @@ -98,6 +113,9 @@ testSchemaDir(const char *schema, continue; if (ent->d_name[0] =3D=3D '.') continue; + if (filter && + !g_regex_match(filter, ent->d_name, 0, NULL)) + continue; xml_path =3D g_strdup_printf("%s/%s", dir_path, ent->d_name); @@ -176,7 +194,7 @@ testSchemaEntries(const char *schema, if (entry->dir) { g_autofree char *path =3D g_strdup_printf("%s/%s", abs_top_src= dir, entry->dir); - if (testSchemaDir(schema, validator, path) < 0) + if (testSchemaDir(schema, validator, path, entry->dirRegex) < = 0) ret =3D -1; } --=20 2.26.2