]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Ensure test files are newline-terminated
authorAndrea Bolognani <abologna@redhat.com>
Fri, 5 Jan 2024 11:02:43 +0000 (12:02 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 5 Jan 2024 13:38:49 +0000 (14:38 +0100)
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=1 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 <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
22 files changed:
tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-create.json
tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-define.json
tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-create.json
tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-define.json
tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-create.json
tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-define.json
tests/qemunbdkitdata/disk-cdrom-network.args.disk1.pipe.778
tests/qemunbdkitdata/disk-cdrom-network.args.disk2.pipe.780
tests/qemunbdkitdata/disk-network-http.args.disk2.pipe.778
tests/qemunbdkitdata/disk-network-http.args.disk3.pipe.780
tests/qemunbdkitdata/disk-network-source-curl-nbdkit-backing.args.disk0.pipe.778
tests/qemunbdkitdata/disk-network-source-curl.args.disk0.pipe.778
tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.780
tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.782
tests/qemunbdkitdata/disk-network-source-curl.args.disk2.pipe.784
tests/qemunbdkitdata/disk-network-ssh-password.args.disk0.pipe.778
tests/testutils.c
tests/virhostcpudata/linux-ppc64-deconf-cpus.signature
tests/virhostcpudata/linux-ppc64-subcores1.signature
tests/virhostcpudata/linux-ppc64-subcores2.signature
tests/virhostcpudata/linux-ppc64-subcores3.signature
tests/virhostcpudata/linux-s390x-with-frequency.signature

index bfc6dcace3dea1dd06fafeeba9d9eaaa103bb6b0..80f3b6cb2e3b8ebd2d984aba6ec61564f27bc391 100644 (file)
@@ -1 +1 @@
-{"mdev_type":"i915-GVTg_V5_8","start":"manual"}
\ No newline at end of file
+{"mdev_type":"i915-GVTg_V5_8","start":"manual"}
index bfc6dcace3dea1dd06fafeeba9d9eaaa103bb6b0..80f3b6cb2e3b8ebd2d984aba6ec61564f27bc391 100644 (file)
@@ -1 +1 @@
-{"mdev_type":"i915-GVTg_V5_8","start":"manual"}
\ No newline at end of file
+{"mdev_type":"i915-GVTg_V5_8","start":"manual"}
index e5b22b2c4411d2025877edc4d938edde029c2d0f..4fba307865453ca508fc26e54995e66572e0af7a 100644 (file)
@@ -1 +1 @@
-{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute-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-attribute-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]}
index e5b22b2c4411d2025877edc4d938edde029c2d0f..4fba307865453ca508fc26e54995e66572e0af7a 100644 (file)
@@ -1 +1 @@
-{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute-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-attribute-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]}
index 2e03d0bd8e0dadf38384dd8e6537b971b5224b62..22d4a2e58637abc048c2bffadccea35af097c44a 100644 (file)
@@ -1 +1 @@
-{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute":"attribute-value"}]}
\ No newline at end of file
+{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute":"attribute-value"}]}
index 2e03d0bd8e0dadf38384dd8e6537b971b5224b62..22d4a2e58637abc048c2bffadccea35af097c44a 100644 (file)
@@ -1 +1 @@
-{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute":"attribute-value"}]}
\ No newline at end of file
+{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute":"attribute-value"}]}
index ccdd4033fc96778e87cb5f439e5bf77ad24392cb..dd67dde67bd4e37f4651f054c3cbd6628fc8d8eb 100644 (file)
@@ -1 +1 @@
-iscsi-mycluster_myname-secret
\ No newline at end of file
+iscsi-mycluster_myname-secret
index ccdd4033fc96778e87cb5f439e5bf77ad24392cb..dd67dde67bd4e37f4651f054c3cbd6628fc8d8eb 100644 (file)
@@ -1 +1 @@
-iscsi-mycluster_myname-secret
\ No newline at end of file
+iscsi-mycluster_myname-secret
index 2c42c95930ce273f4679bf6b99511888d5c487d0..3751afd16beef4856c722557886660b9e9ab7ceb 100644 (file)
@@ -1 +1 @@
-test=testcookievalue; test2="blurb"
\ No newline at end of file
+test=testcookievalue; test2="blurb"
index 2c42c95930ce273f4679bf6b99511888d5c487d0..3751afd16beef4856c722557886660b9e9ab7ceb 100644 (file)
@@ -1 +1 @@
-test=testcookievalue; test2="blurb"
\ No newline at end of file
+test=testcookievalue; test2="blurb"
index 20af4ae383ed02ef6f0d71b5f7da46c0d7248e8b..e72f706c3bbd05dc5441534cd5f5ff6cfc1ce1f3 100644 (file)
@@ -1 +1 @@
-cookie1=cookievalue1; cookie2=cookievalue2
\ No newline at end of file
+cookie1=cookievalue1; cookie2=cookievalue2
index 20af4ae383ed02ef6f0d71b5f7da46c0d7248e8b..e72f706c3bbd05dc5441534cd5f5ff6cfc1ce1f3 100644 (file)
@@ -1 +1 @@
-cookie1=cookievalue1; cookie2=cookievalue2
\ No newline at end of file
+cookie1=cookievalue1; cookie2=cookievalue2
index ccdd4033fc96778e87cb5f439e5bf77ad24392cb..dd67dde67bd4e37f4651f054c3cbd6628fc8d8eb 100644 (file)
@@ -1 +1 @@
-iscsi-mycluster_myname-secret
\ No newline at end of file
+iscsi-mycluster_myname-secret
index 20af4ae383ed02ef6f0d71b5f7da46c0d7248e8b..e72f706c3bbd05dc5441534cd5f5ff6cfc1ce1f3 100644 (file)
@@ -1 +1 @@
-cookie1=cookievalue1; cookie2=cookievalue2
\ No newline at end of file
+cookie1=cookievalue1; cookie2=cookievalue2
index 5c035e84c54de4be555d6eca56fd3b25a99c6fcf..af98693472df6dd0a18e155cd46b6b046b63251f 100644 (file)
@@ -1 +1 @@
-cookie1=cookievalue1; cookie2=cookievalue2; cookie3=cookievalue3
\ No newline at end of file
+cookie1=cookievalue1; cookie2=cookievalue2; cookie3=cookievalue3
index ccdd4033fc96778e87cb5f439e5bf77ad24392cb..dd67dde67bd4e37f4651f054c3cbd6628fc8d8eb 100644 (file)
@@ -1 +1 @@
-iscsi-mycluster_myname-secret
\ No newline at end of file
+iscsi-mycluster_myname-secret
index b20e447b99a86050602af26f88936c5a1ce20b9a..6ee78cca3c4439690470ce0476be83e549ee8a3a 100644 (file)
@@ -582,6 +582,7 @@ virTestCompareToFileFull(const char *actual,
     g_autofree char *filecontent = NULL;
     g_autofree char *fixedcontent = NULL;
     const char *cmpcontent = actual;
+    size_t cmpcontentLen;
 
     if (!cmpcontent)
         cmpcontent = "";
@@ -594,16 +595,12 @@ virTestCompareToFileFull(const char *actual,
             return -1;
     }
 
-    if (filecontent) {
-        size_t filecontentLen = strlen(filecontent);
-        size_t cmpcontentLen = strlen(cmpcontent);
+    cmpcontentLen = strlen(cmpcontent);
 
-        if (filecontentLen > 0 &&
-            filecontent[filecontentLen - 1] == '\n' &&
-            (cmpcontentLen == 0 || cmpcontent[cmpcontentLen - 1] != '\n')) {
-            fixedcontent = g_strdup_printf("%s\n", cmpcontent);
-            cmpcontent = fixedcontent;
-        }
+    if (cmpcontentLen > 0 &&
+        cmpcontent[cmpcontentLen - 1] != '\n') {
+        fixedcontent = g_strdup_printf("%s\n", cmpcontent);
+        cmpcontent = fixedcontent;
     }
 
     if (STRNEQ_NULLABLE(cmpcontent, filecontent)) {
index 7adf19db2fbaa359119e7f9d153457c2c9ed2774..f7c21761e0bf91bb2662d84118fc49e27acb6d58 100644 (file)
@@ -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)
index 7adf19db2fbaa359119e7f9d153457c2c9ed2774..f7c21761e0bf91bb2662d84118fc49e27acb6d58 100644 (file)
@@ -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)
index 7adf19db2fbaa359119e7f9d153457c2c9ed2774..f7c21761e0bf91bb2662d84118fc49e27acb6d58 100644 (file)
@@ -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)
index 7adf19db2fbaa359119e7f9d153457c2c9ed2774..f7c21761e0bf91bb2662d84118fc49e27acb6d58 100644 (file)
@@ -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)
index 70bb28a15456a3dd5c0628f70e7829e142a881b1..6c8ec5a05e254d651cada5998bff474fb3f9f69d 100644 (file)
@@ -1 +1 @@
-IBM/S390, version = 00,  identification = 145F07,  machine = 2964, facilities: 0 1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 31 32 33 34 35 36 37 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 = 00,  identification = 145F07,  machine = 2964, facilities: 0 1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 31 32 33 34 35 36 37 40 41 42 43 44 45 46 47 48 49 50 51 52 53 55 57 64 65 66 67 68 69 70 71 72 73 75 76 77 78 80 128 129 131 132 142 143