From nobody Sun Dec 22 01:39:57 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1704460050784203.78514994303464; Fri, 5 Jan 2024 05:07:30 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 89EFA18CA; Fri, 5 Jan 2024 08:07:29 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0D789191A; Fri, 5 Jan 2024 08:03:00 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 78ADE1893; Fri, 5 Jan 2024 08:02:54 -0500 (EST) 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 4FE0017E8 for ; Fri, 5 Jan 2024 08:02:53 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-446--Co7DhvaOzuVQq5WU2x8pQ-1; Fri, 05 Jan 2024 08:02:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C170846D56 for ; Fri, 5 Jan 2024 13:02:51 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.225.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5E5440C6EB9 for ; Fri, 5 Jan 2024 13:02:50 +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=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: -Co7DhvaOzuVQq5WU2x8pQ-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 2/2] tests: Ensure test files are newline-terminated Date: Fri, 5 Jan 2024 14:02:47 +0100 Message-ID: <20240105130247.567365-3-abologna@redhat.com> In-Reply-To: <20240105130247.567365-1-abologna@redhat.com> References: <20240105130247.567365-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 6OSEPECURJITKHTYMDHXPB6FRXV42HIQ X-Message-ID-Hash: 6OSEPECURJITKHTYMDHXPB6FRXV42HIQ X-MailFrom: abologna@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: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1704460052656100001 Currently we only append a newline to 'actual' if 'expected' (as loaded from file) already ends in a newline, but that results in inconsistent behavior. For example, some of the test files used by virhostcputest are newline-terminated and some aren't. If we were to remove existing newlines from those files or add them where they aren't present, the test would still pass, and even using VIR_TEST_REGENERATE_OUTPUT=3D1 wouldn't change them back. Make things consistent by ensuring that 'actual' is always newline-terminated. The only exception is when 'actual' is completely empty: in that case, we want the file to be actually empty, not contain a single empty line. query-jobs-empty.result in qemumonitorjsondata/ is an example of this being used. Signed-off-by: Andrea Bolognani --- ...69d019_36ea_4111_8f0a_8c9a70e21366-create.json | 2 +- ...69d019_36ea_4111_8f0a_8c9a70e21366-define.json | 2 +- ...441d39_495e_4243_ad9f_beb3f14c23d9-create.json | 2 +- ...441d39_495e_4243_ad9f_beb3f14c23d9-define.json | 2 +- ...dc4916_1ca8_49ac_b176_871d16c13076-create.json | 2 +- ...dc4916_1ca8_49ac_b176_871d16c13076-define.json | 2 +- .../disk-cdrom-network.args.disk1.pipe.778 | 2 +- .../disk-cdrom-network.args.disk2.pipe.780 | 2 +- .../disk-network-http.args.disk2.pipe.778 | 2 +- .../disk-network-http.args.disk3.pipe.780 | 2 +- ...source-curl-nbdkit-backing.args.disk0.pipe.778 | 2 +- .../disk-network-source-curl.args.disk0.pipe.778 | 2 +- .../disk-network-source-curl.args.disk1.pipe.780 | 2 +- .../disk-network-source-curl.args.disk1.pipe.782 | 2 +- .../disk-network-source-curl.args.disk2.pipe.784 | 2 +- .../disk-network-ssh-password.args.disk0.pipe.778 | 2 +- tests/testutils.c | 15 ++++++--------- .../linux-ppc64-deconf-cpus.signature | 2 +- .../linux-ppc64-subcores1.signature | 2 +- .../linux-ppc64-subcores2.signature | 2 +- .../linux-ppc64-subcores3.signature | 2 +- .../linux-s390x-with-frequency.signature | 2 +- 22 files changed, 27 insertions(+), 30 deletions(-) diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2= 1366-create.json b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c= 9a70e21366-create.json index bfc6dcace3..80f3b6cb2e 100644 --- a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-cr= eate.json +++ b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-cr= eate.json @@ -1 +1 @@ -{"mdev_type":"i915-GVTg_V5_8","start":"manual"} \ No newline at end of file +{"mdev_type":"i915-GVTg_V5_8","start":"manual"} diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2= 1366-define.json b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c= 9a70e21366-define.json index bfc6dcace3..80f3b6cb2e 100644 --- a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-de= fine.json +++ b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-de= fine.json @@ -1 +1 @@ -{"mdev_type":"i915-GVTg_V5_8","start":"manual"} \ No newline at end of file +{"mdev_type":"i915-GVTg_V5_8","start":"manual"} diff --git a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c= 23d9-create.json b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_be= b3f14c23d9-create.json index e5b22b2c44..4fba307865 100644 --- a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-cr= eate.json +++ b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-cr= eate.json @@ -1 +1 @@ -{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]} \ No newline at end of file +{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]} diff --git a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c= 23d9-define.json b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_be= b3f14c23d9-define.json index e5b22b2c44..4fba307865 100644 --- a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-de= fine.json +++ b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-de= fine.json @@ -1 +1 @@ -{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]} \ No newline at end of file +{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]} diff --git a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1= 3076-create.json b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_87= 1d16c13076-create.json index 2e03d0bd8e..22d4a2e586 100644 --- a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-cr= eate.json +++ b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-cr= eate.json @@ -1 +1 @@ -{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e":"attribute-value"}]} \ No newline at end of file +{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e":"attribute-value"}]} diff --git a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1= 3076-define.json b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_87= 1d16c13076-define.json index 2e03d0bd8e..22d4a2e586 100644 --- a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-de= fine.json +++ b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-de= fine.json @@ -1 +1 @@ -{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e":"attribute-value"}]} \ No newline at end of file +{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e":"attribute-value"}]} diff --git a/tests/qemunbdkitdata/disk-cdrom-network.args.disk1.pipe.778 b/= tests/qemunbdkitdata/disk-cdrom-network.args.disk1.pipe.778 index ccdd4033fc..dd67dde67b 100644 --- a/tests/qemunbdkitdata/disk-cdrom-network.args.disk1.pipe.778 +++ b/tests/qemunbdkitdata/disk-cdrom-network.args.disk1.pipe.778 @@ -1 +1 @@ -iscsi-mycluster_myname-secret \ No newline at end of file +iscsi-mycluster_myname-secret diff --git a/tests/qemunbdkitdata/disk-cdrom-network.args.disk2.pipe.780 b/= tests/qemunbdkitdata/disk-cdrom-network.args.disk2.pipe.780 index ccdd4033fc..dd67dde67b 100644 --- a/tests/qemunbdkitdata/disk-cdrom-network.args.disk2.pipe.780 +++ b/tests/qemunbdkitdata/disk-cdrom-network.args.disk2.pipe.780 @@ -1 +1 @@ -iscsi-mycluster_myname-secret \ No newline at end of file +iscsi-mycluster_myname-secret diff --git a/tests/qemunbdkitdata/disk-network-http.args.disk2.pipe.778 b/t= ests/qemunbdkitdata/disk-network-http.args.disk2.pipe.778 index 2c42c95930..3751afd16b 100644 --- a/tests/qemunbdkitdata/disk-network-http.args.disk2.pipe.778 +++ b/tests/qemunbdkitdata/disk-network-http.args.disk2.pipe.778 @@ -1 +1 @@ -test=3Dtestcookievalue; test2=3D"blurb" \ No newline at end of file +test=3Dtestcookievalue; test2=3D"blurb" diff --git a/tests/qemunbdkitdata/disk-network-http.args.disk3.pipe.780 b/t= ests/qemunbdkitdata/disk-network-http.args.disk3.pipe.780 index 2c42c95930..3751afd16b 100644 --- a/tests/qemunbdkitdata/disk-network-http.args.disk3.pipe.780 +++ b/tests/qemunbdkitdata/disk-network-http.args.disk3.pipe.780 @@ -1 +1 @@ -test=3Dtestcookievalue; test2=3D"blurb" \ No newline at end of file +test=3Dtestcookievalue; test2=3D"blurb" diff --git a/tests/qemunbdkitdata/disk-network-source-curl-nbdkit-backing.a= rgs.disk0.pipe.778 b/tests/qemunbdkitdata/disk-network-source-curl-nbdkit-b= acking.args.disk0.pipe.778 index 20af4ae383..e72f706c3b 100644 --- a/tests/qemunbdkitdata/disk-network-source-curl-nbdkit-backing.args.dis= k0.pipe.778 +++ b/tests/qemunbdkitdata/disk-network-source-curl-nbdkit-backing.args.dis= k0.pipe.778 @@ -1 +1 @@ -cookie1=3Dcookievalue1; cookie2=3Dcookievalue2 \ No newline at end of file +cookie1=3Dcookievalue1; cookie2=3Dcookievalue2 diff --git a/tests/qemunbdkitdata/disk-network-source-curl.args.disk0.pipe.= 778 b/tests/qemunbdkitdata/disk-network-source-curl.args.disk0.pipe.778 index 20af4ae383..e72f706c3b 100644 --- a/tests/qemunbdkitdata/disk-network-source-curl.args.disk0.pipe.778 +++ b/tests/qemunbdkitdata/disk-network-source-curl.args.disk0.pipe.778 @@ -1 +1 @@ -cookie1=3Dcookievalue1; cookie2=3Dcookievalue2 \ No newline at end of file +cookie1=3Dcookievalue1; cookie2=3Dcookievalue2 diff --git a/tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.= 780 b/tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.780 index ccdd4033fc..dd67dde67b 100644 --- a/tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.780 +++ b/tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.780 @@ -1 +1 @@ -iscsi-mycluster_myname-secret \ No newline at end of file +iscsi-mycluster_myname-secret diff --git a/tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.= 782 b/tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.782 index 20af4ae383..e72f706c3b 100644 --- a/tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.782 +++ b/tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.782 @@ -1 +1 @@ -cookie1=3Dcookievalue1; cookie2=3Dcookievalue2 \ No newline at end of file +cookie1=3Dcookievalue1; cookie2=3Dcookievalue2 diff --git a/tests/qemunbdkitdata/disk-network-source-curl.args.disk2.pipe.= 784 b/tests/qemunbdkitdata/disk-network-source-curl.args.disk2.pipe.784 index 5c035e84c5..af98693472 100644 --- a/tests/qemunbdkitdata/disk-network-source-curl.args.disk2.pipe.784 +++ b/tests/qemunbdkitdata/disk-network-source-curl.args.disk2.pipe.784 @@ -1 +1 @@ -cookie1=3Dcookievalue1; cookie2=3Dcookievalue2; cookie3=3Dcookievalue3 \ No newline at end of file +cookie1=3Dcookievalue1; cookie2=3Dcookievalue2; cookie3=3Dcookievalue3 diff --git a/tests/qemunbdkitdata/disk-network-ssh-password.args.disk0.pipe= .778 b/tests/qemunbdkitdata/disk-network-ssh-password.args.disk0.pipe.778 index ccdd4033fc..dd67dde67b 100644 --- a/tests/qemunbdkitdata/disk-network-ssh-password.args.disk0.pipe.778 +++ b/tests/qemunbdkitdata/disk-network-ssh-password.args.disk0.pipe.778 @@ -1 +1 @@ -iscsi-mycluster_myname-secret \ No newline at end of file +iscsi-mycluster_myname-secret diff --git a/tests/testutils.c b/tests/testutils.c index b20e447b99..6ee78cca3c 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -582,6 +582,7 @@ virTestCompareToFileFull(const char *actual, g_autofree char *filecontent =3D NULL; g_autofree char *fixedcontent =3D NULL; const char *cmpcontent =3D actual; + size_t cmpcontentLen; =20 if (!cmpcontent) cmpcontent =3D ""; @@ -594,16 +595,12 @@ virTestCompareToFileFull(const char *actual, return -1; } =20 - if (filecontent) { - size_t filecontentLen =3D strlen(filecontent); - size_t cmpcontentLen =3D strlen(cmpcontent); + cmpcontentLen =3D strlen(cmpcontent); =20 - if (filecontentLen > 0 && - filecontent[filecontentLen - 1] =3D=3D '\n' && - (cmpcontentLen =3D=3D 0 || cmpcontent[cmpcontentLen - 1] !=3D = '\n')) { - fixedcontent =3D g_strdup_printf("%s\n", cmpcontent); - cmpcontent =3D fixedcontent; - } + if (cmpcontentLen > 0 && + cmpcontent[cmpcontentLen - 1] !=3D '\n') { + fixedcontent =3D g_strdup_printf("%s\n", cmpcontent); + cmpcontent =3D fixedcontent; } =20 if (STRNEQ_NULLABLE(cmpcontent, filecontent)) { diff --git a/tests/virhostcpudata/linux-ppc64-deconf-cpus.signature b/tests= /virhostcpudata/linux-ppc64-deconf-cpus.signature index 7adf19db2f..f7c21761e0 100644 --- a/tests/virhostcpudata/linux-ppc64-deconf-cpus.signature +++ b/tests/virhostcpudata/linux-ppc64-deconf-cpus.signature @@ -1 +1 @@ -POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201) \ No newline at end of file +POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201) diff --git a/tests/virhostcpudata/linux-ppc64-subcores1.signature b/tests/v= irhostcpudata/linux-ppc64-subcores1.signature index 7adf19db2f..f7c21761e0 100644 --- a/tests/virhostcpudata/linux-ppc64-subcores1.signature +++ b/tests/virhostcpudata/linux-ppc64-subcores1.signature @@ -1 +1 @@ -POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201) \ No newline at end of file +POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201) diff --git a/tests/virhostcpudata/linux-ppc64-subcores2.signature b/tests/v= irhostcpudata/linux-ppc64-subcores2.signature index 7adf19db2f..f7c21761e0 100644 --- a/tests/virhostcpudata/linux-ppc64-subcores2.signature +++ b/tests/virhostcpudata/linux-ppc64-subcores2.signature @@ -1 +1 @@ -POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201) \ No newline at end of file +POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201) diff --git a/tests/virhostcpudata/linux-ppc64-subcores3.signature b/tests/v= irhostcpudata/linux-ppc64-subcores3.signature index 7adf19db2f..f7c21761e0 100644 --- a/tests/virhostcpudata/linux-ppc64-subcores3.signature +++ b/tests/virhostcpudata/linux-ppc64-subcores3.signature @@ -1 +1 @@ -POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201) \ No newline at end of file +POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201) diff --git a/tests/virhostcpudata/linux-s390x-with-frequency.signature b/te= sts/virhostcpudata/linux-s390x-with-frequency.signature index 70bb28a154..6c8ec5a05e 100644 --- a/tests/virhostcpudata/linux-s390x-with-frequency.signature +++ b/tests/virhostcpudata/linux-s390x-with-frequency.signature @@ -1 +1 @@ -IBM/S390, version =3D 00, identification =3D 145F07, machine =3D 2964, f= acilities: 0 1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2= 5 26 27 28 30 31 32 33 34 35 36 37 40 41 42 43 44 45 46 47 48 49 50 51 52 5= 3 55 57 64 65 66 67 68 69 70 71 72 73 75 76 77 78 80 128 129 131 132 142 143 \ No newline at end of file +IBM/S390, version =3D 00, identification =3D 145F07, machine =3D 2964, f= acilities: 0 1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2= 5 26 27 28 30 31 32 33 34 35 36 37 40 41 42 43 44 45 46 47 48 49 50 51 52 5= 3 55 57 64 65 66 67 68 69 70 71 72 73 75 76 77 78 80 128 129 131 132 142 143 --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org