From nobody Wed Nov 27 05:31:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1723207312000496.5328254001887; Fri, 9 Aug 2024 05:41:52 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DE6301551; Fri, 9 Aug 2024 08:41:50 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 345F0147F; Fri, 9 Aug 2024 08:41:01 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 06E241395; Fri, 9 Aug 2024 08:40:57 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 8A2FD1425 for ; Fri, 9 Aug 2024 08:40:56 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-aOfUehA0M8-DbjQB5cU49g-1; Fri, 09 Aug 2024 08:40:54 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B723F1955D47 for ; Fri, 9 Aug 2024 12:40:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D128C19560A3 for ; Fri, 9 Aug 2024 12:40:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723207256; h=from:from: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; bh=f7bxVicU5niepOTVXPkH0BLFabH66P1ffQe+Rlw7Slo=; b=C3LJQc+2Lalo2duxy9LZD68lGZB7AHjTAusqV5qDq18xxhDiNFvlOgeEHyPX0+5I8TBQjC HoWT+UbaDN8ZoBZZdOnTJOeXHONdtkfis19gUNoVbT34r12y7V6awEwluonZMBjpojeGeH dWczzx4k0YqxrpoKHv2cVldfPnZh6tk= X-MC-Unique: aOfUehA0M8-DbjQB5cU49g-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 1/3] glibcompat: "Backport" 'g_string_replace' Date: Fri, 9 Aug 2024 14:40:47 +0200 Message-ID: <1e5d45164ed60882e9d43046d2b1eff27527f3eb.1723207140.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JKC7WGIPGE6UL2FN3TOEEMUCVO5KIA5E X-Message-ID-Hash: JKC7WGIPGE6UL2FN3TOEEMUCVO5KIA5E X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1723207312836116600 Content-Type: text/plain; charset="utf-8" Backport the implementation of 'g_string_replace' until we require at least glib-2.68 Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/glibcompat.c | 65 ++++++++++++++++++++++++++++++++++++++++ src/util/glibcompat.h | 10 +++++++ 3 files changed, 76 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d15d6a6a9d..0accca442a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1864,6 +1864,7 @@ vir_g_fsync; vir_g_source_unref; vir_g_strdup_printf; vir_g_strdup_vprintf; +vir_g_string_replace; # util/viracpi.c diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index d8912b323b..98dcfab389 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -155,3 +155,68 @@ void vir_g_source_unref(GSource *src, GMainContext *ct= x) } #endif + + +/** + * Adapted (to pass syntax check) from 'g_string_replace' from + * glib-2.81.1. Drop once minimum glib is bumped to 2.68. + * + * g_string_replace: + * @string: a #GString + * @find: the string to find in @string + * @replace: the string to insert in place of @find + * @limit: the maximum instances of @find to replace with @replace, or `0`= for + * no limit + * + * Replaces the string @find with the string @replace in a #GString up to + * @limit times. If the number of instances of @find in the #GString is + * less than @limit, all instances are replaced. If @limit is `0`, + * all instances of @find are replaced. + * + * If @find is the empty string, since versions 2.69.1 and 2.68.4 the + * replacement will be inserted no more than once per possible position + * (beginning of string, end of string and between characters). This did + * not work correctly in earlier versions. + * + * Returns: the number of find and replace operations performed. + * + * Since: 2.68 + */ +guint +vir_g_string_replace(GString *string, + const gchar *find, + const gchar *replace, + guint limit) +{ + gsize f_len, r_len, pos; + gchar *cur, *next; + guint n =3D 0; + + g_return_val_if_fail(string !=3D NULL, 0); + g_return_val_if_fail(find !=3D NULL, 0); + g_return_val_if_fail(replace !=3D NULL, 0); + + f_len =3D strlen(find); + r_len =3D strlen(replace); + cur =3D string->str; + + while ((next =3D strstr(cur, find)) !=3D NULL) { + pos =3D next - string->str; + g_string_erase(string, pos, f_len); + g_string_insert(string, pos, replace); + cur =3D string->str + pos + r_len; + n++; + /* Only match the empty string once at any given position, to + * avoid infinite loops */ + if (f_len =3D=3D 0) { + if (cur[0] =3D=3D '\0') + break; + else + cur++; + } + if (n =3D=3D limit) + break; + } + + return n; +} diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index 2542b4d5dc..3518023a41 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -85,6 +85,16 @@ char *vir_g_strdup_vprintf(const char *msg, va_list args) void vir_g_source_unref(GSource *src, GMainContext *ctx); + +/* Drop once we require glib-2.68 at minimum */ +guint +vir_g_string_replace(GString *string, + const gchar *find, + const gchar *replace, + guint limit); +#undef g_string_replace +#define g_string_replace vir_g_string_replace + #if !GLIB_CHECK_VERSION(2, 73, 2) # if (defined(__has_attribute) && __has_attribute(__noinline__)) || G_GNUC= _CHECK_VERSION (2, 96) # if defined (__cplusplus) && __cplusplus >=3D 201103L --=20 2.45.2 From nobody Wed Nov 27 05:31:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 17232073334861014.1957698368421; Fri, 9 Aug 2024 05:42:13 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 69E1414FC; Fri, 9 Aug 2024 08:42:12 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C6D61157C; Fri, 9 Aug 2024 08:41:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 05D661395; Fri, 9 Aug 2024 08:40:58 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 8C15A1425 for ; Fri, 9 Aug 2024 08:40:57 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-9WUKfgIlPGO-7GuYrKKcfw-1; Fri, 09 Aug 2024 08:40:56 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32F751944AB0 for ; Fri, 9 Aug 2024 12:40:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 26C901955E82 for ; Fri, 9 Aug 2024 12:40:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723207257; h=from:from: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; bh=Lwkcjdbbr4j3BnVFolCIFcTETryrhYnO6DJ2E8HPzgw=; b=iXb+dHfiWUVxAzkFs827RGkCOKbrrEH1H5ys+t4FX6pNfYe5moJ8jInm5tDtD0rFNniN/u l6VwwJS2KKi0a6BjZfwDeBB14pa0TJluBaFBSyiieNARaVguGOtxsbd+hpZddlGbx4hRPv ZLudjWcTFbjRphX2ua/1dUxWSROUKLk= X-MC-Unique: 9WUKfgIlPGO-7GuYrKKcfw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 2/3] testQemuConfXMLCommon: Strip 'abs_srcdir' paths from '.err' files in qemuxmlconftest Date: Fri, 9 Aug 2024 14:40:48 +0200 Message-ID: <9c04f4e7276f035e00a1093e8cb2577bb54bc488.1723207140.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CEVXXKRHDUVSBMNBUCENDQZCWYSIC3QG X-Message-ID-Hash: CEVXXKRHDUVSBMNBUCENDQZCWYSIC3QG X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1723207334925116600 Content-Type: text/plain; charset="utf-8" Upcoming patch will result in having the build directory path in some of the output files. Replace it by a constant 'ABS_SRCDIR' to avoild breaking tests. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tests/qemuxmlconftest.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 7e47c78150..5fe69db15f 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -687,8 +687,12 @@ testQemuConfXMLCommon(testQemuInfo *info, } if (info->flags & FLAG_EXPECT_PARSE_ERROR) { - g_autofree char *tmperr =3D g_strdup_printf("%s\n", NULLSTR(er= r->message)); - if (virTestCompareToFile(tmperr, info->errfile) >=3D 0) { + g_autoptr(GString) errstr =3D g_string_new(NULLSTR(err->messag= e)); + + g_string_replace(errstr, abs_srcdir, "ABS_SRCDIR", 0); + g_string_append_c(errstr, '\n'); + + if (virTestCompareToFile(errstr->str, info->errfile) >=3D 0) { info->prep_skip =3D true; } } --=20 2.45.2 From nobody Wed Nov 27 05:31:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1723207366245734.3804401667658; Fri, 9 Aug 2024 05:42:46 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 32CD81520; Fri, 9 Aug 2024 08:42:45 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 96BEB1562; Fri, 9 Aug 2024 08:41:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0D37E1519; Fri, 9 Aug 2024 08:41:12 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 8ADD1150F for ; Fri, 9 Aug 2024 08:40:58 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-xc8WBFs7NmiUvUFQAZNeuw-1; Fri, 09 Aug 2024 08:40:57 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 533D91955F3B for ; Fri, 9 Aug 2024 12:40:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7D02119560AE for ; Fri, 9 Aug 2024 12:40:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723207258; h=from:from: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; bh=2e4/qMXJ3H2sFhWRvR5hhxyvMfekoGaHxBHkvEdxj3I=; b=DKMrbZUvxbxzagjYkTwx1derRIMU3/rAFXtDl9tmxnnerNVRhtfbZhOERc258wXbsuuPlI qOc57o7zCiFXP0HCQvf5L2cqDyZMSlRVv9RnSqCOdqfMBgoj5nEprUG0tz+q3aIlGa2BVT OKQAgRb1LV1genJWzoYtlNr7LXw9Ei0= X-MC-Unique: xc8WBFs7NmiUvUFQAZNeuw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 3/3] qemuxmlconftest: Add test cases for broken and missing XML files Date: Fri, 9 Aug 2024 14:40:49 +0200 Message-ID: <4f80803181b073baae7b2d5df16148786668cbb5.1723207140.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7FH4GLLDW6EPZ4DW4Y4JBR6DTBLCTP5R X-Message-ID-Hash: 7FH4GLLDW6EPZ4DW4Y4JBR6DTBLCTP5R X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1723207367132116600 Content-Type: text/plain; charset="utf-8" Add test cases for few edge cases which excercise the XML reporting from libxml2 in anticipation of upcoming changes of behaviour. 'virschematest' must skip parsing of the broken file altogether so this patch adds infrastructure to allow that. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- .../broken-xml-invalid.x86_64-latest.err | 3 +++ tests/qemuxmlconfdata/broken-xml-invalid.xml | 1 + .../nonexistent-file.x86_64-latest.err | 1 + tests/qemuxmlconftest.c | 8 +++++++- tests/testutilsqemu.h | 1 + tests/virschematest.c | 12 ++++++++++++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.= err create mode 100644 tests/qemuxmlconfdata/broken-xml-invalid.xml create mode 100644 tests/qemuxmlconfdata/nonexistent-file.x86_64-latest.err diff --git a/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err b/t= ests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err new file mode 100644 index 0000000000..35a1801371 --- /dev/null +++ b/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err @@ -0,0 +1,3 @@ +ABS_SRCDIR/qemuxmlconfdata/broken-xml-invalid.xml:2: Couldn't find end of = Start Tag dom line 1 +(null) +^ diff --git a/tests/qemuxmlconfdata/broken-xml-invalid.xml b/tests/qemuxmlco= nfdata/broken-xml-invalid.xml new file mode 100644 index 0000000000..9903e61ead --- /dev/null +++ b/tests/qemuxmlconfdata/broken-xml-invalid.xml @@ -0,0 +1 @@ +qemuCaps) < 0) goto cleanup; - if (!virFileExists(info->infile)) { + if (!(info->flags & FLAG_ALLOW_MISSING_INPUT) && + !virFileExists(info->infile)) { virReportError(VIR_ERR_INTERNAL_ERROR, "Input file '%s' not found", info->infile); goto cleanup; @@ -1237,6 +1239,10 @@ mymain(void) g_unsetenv("PIPEWIRE_REMOTE"); g_unsetenv("PIPEWIRE_RUNTIME_DIR"); + DO_TEST_CAPS_ARCH_LATEST_FULL("nonexistent-file", "x86_64", + ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLA= G_ALLOW_MISSING_INPUT); + DO_TEST_CAPS_LATEST_PARSE_ERROR("broken-xml-invalid"); + DO_TEST_CAPS_LATEST("x86_64-pc-minimal"); DO_TEST_CAPS_LATEST_ABI_UPDATE("x86_64-pc-minimal"); DO_TEST_CAPS_LATEST("x86_64-q35-minimal"); diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index a5806f244b..90632031ff 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -61,6 +61,7 @@ typedef enum { FLAG_REAL_CAPS =3D 1 << 2, FLAG_SLIRP_HELPER =3D 1 << 3, FLAG_ALLOW_DUPLICATE_OUTPUT =3D 1 << 4, /* allow multiple tests with t= he same output file */ + FLAG_ALLOW_MISSING_INPUT =3D 1 << 5, } testQemuInfoFlags; struct testQemuConf { diff --git a/tests/virschematest.c b/tests/virschematest.c index 9b6649a6cf..e89730e8dc 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -36,6 +36,7 @@ struct testSchemaEntry { const char **exceptions; /* optional NULL terminated list of filenames= inside directory where the expected validation re= sult is inverted */ + const char **skip; /* list of files to skip altogether */ const char *dirRegex; const char *file; }; @@ -131,6 +132,10 @@ testSchemaDir(const char *schema, !g_regex_match(filter, ent->d_name, 0, NULL)) continue; + if (entry->skip && + g_strv_contains(entry->skip, ent->d_name)) + continue; + if (entry->exceptions) exception =3D g_strv_contains(entry->exceptions, ent->d_name); @@ -237,10 +242,17 @@ static const char *exceptions_qemuxmlconfdata[] =3D { NULL }; +/* skip tests with completely broken XML */ +static const char *skip_qemuxmlconfdata[] =3D { + "broken-xml-invalid.xml", + NULL +}; + static const struct testSchemaEntry schemaDomain[] =3D { { .dir =3D "tests/domainschemadata" }, { .dir =3D "tests/qemuxmlconfdata", .exceptions =3D exceptions_qemuxmlconfdata, + .skip =3D skip_qemuxmlconfdata, }, { .dir =3D "tests/xmconfigdata" }, { .dir =3D "tests/lxcxml2xmldata" }, --=20 2.45.2