From nobody Sun Feb 8 21:29:11 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=1602143761; cv=none; d=zohomail.com; s=zohoarc; b=eOPl6RzMOYqaEcrf4c0dTQZTl1XyZl5uNk/9cYHiDHdwlXQyw5+j1oDBLCcuk6D91KUrFw8kuemLdX3WjeFZ9PpxjjsSqrnjQrGwywU4xzjy1L5+9Dp/+D5XQZ8IQfuMp9D80g6q3iZDBNAUhkXMEO/YAFG9WJxAPCFmgx40M8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602143761; 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=N8b8V0g441tzpjgX3Tqj84fxjwHn/ArHQYUTq+GUSOo9UMZJ2cWGJTWQ2x3ItY+skDwWb70oVxnKBvo6E53lA2EbfGfjRfCtRAT9p3jcH0vICCr0YoAdGUgNDYhpvyW3LXIXIgDpM0XGlqK2/3u8Iia0sFSSDm9cLUNJJehzW9s= 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 1602143761550440.3052682000632; Thu, 8 Oct 2020 00:56:01 -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-152-o3DrAC96ORGkUozBJ59LRQ-1; Thu, 08 Oct 2020 03:55:57 -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 BB4D41015ECB; Thu, 8 Oct 2020 07:55:52 +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 881A01992D; Thu, 8 Oct 2020 07:55:52 +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 3FEF779FF4; Thu, 8 Oct 2020 07:55:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0987tpts003614 for ; Thu, 8 Oct 2020 03:55:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1FF4E5D9F1; Thu, 8 Oct 2020 07:55:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E1275D9DD for ; Thu, 8 Oct 2020 07:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602143760; 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=IZRWBX0eARrHGxDMdp3suAcEQubsRDdoYoJ0Fn2UMj5QiB1f3mHOBmey2XfQIt2mWYfkOC O6HK11rTy5IfDl9xvEZ4jCYaVu/hF2NIn/bbJmMnpAWV2K+ILLrtvWXsGxfwK1HsoM+eyt WUvif4nHBVQCgci9KG85Amdcbjw9LCE= X-MC-Unique: o3DrAC96ORGkUozBJ59LRQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/21] virschematest: Add regex filtering for directory contents Date: Thu, 8 Oct 2020 09:55:17 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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) 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