From nobody Sat Nov 23 16:02:19 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 1723102059276915.0314113756295; Thu, 8 Aug 2024 00:27:39 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 29FB81293; Thu, 8 Aug 2024 03:27:38 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6E8E61289; Thu, 8 Aug 2024 03:27:16 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 75F94123C; Thu, 8 Aug 2024 03:27:10 -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 DACC5B99 for ; Thu, 8 Aug 2024 03:27:09 -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-646--SGbwvdpO3qb5EavBlFIHw-1; Thu, 08 Aug 2024 03:27:07 -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 085DE1955BCF for ; Thu, 8 Aug 2024 07:27:07 +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 1D4D7195605A for ; Thu, 8 Aug 2024 07:27:05 +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=1723102029; 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; bh=0xIEgK98HucW98IMtjvWcMkfcRbhrDlEU2oR9WXjyAw=; b=hHWOsGb1xmXxRQbd42hle+IFqBLERnkI9VgNDy5BOVYH8SQ2sPOVoIF8Mr9m+KBR80b0Ly w0K4mHPyt/iTrTpID4mYoFtKJZFGoTX2r+KN7N9IVRyn91KCxy+W5qWncMwBBzbuG+M1/4 9dwTMUNSnUwavk+qu9hWpgZbMSQeTLA= X-MC-Unique: -SGbwvdpO3qb5EavBlFIHw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH] qemuxmlconftest: Add test cases for broken and missing XML files Date: Thu, 8 Aug 2024 09:27:04 +0200 Message-ID: <82a299a6ad369c02d04a092812150a6c2f7f0d59.1723101959.git.pkrempa@redhat.com> 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: BHYNL5IANIJWRYOTO77CRKHW57XTPVMC X-Message-ID-Hash: BHYNL5IANIJWRYOTO77CRKHW57XTPVMC 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: 1723102060323116600 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 --- This patch is meant as an addendum to my review of: [PATCH] util: open XML files before calling libxml2 .../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 | 11 +++++++++++ 6 files changed, 24 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..601f547cc6 --- /dev/null +++ b/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err @@ -0,0 +1,3 @@ +/home/pipo/libvirt/tests/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; @@ -1233,6 +1235,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..b4113619e2 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,16 @@ static const char *exceptions_qemuxmlconfdata[] =3D { NULL }; +/* skip tests with completely broken XML */ +static const char *skip_qemuxmlconfdata[] =3D { + "broken-xml-invalid.xml" +}; + 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