From nobody Wed Nov 27 08:28:05 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 --- .../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