mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
tests: Ensure test files are newline-terminated
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>
This commit is contained in:
parent
2439e7135c
commit
8a743a598b
@ -1 +1 @@
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual"}
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual"}
|
||||
|
@ -1 +1 @@
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual"}
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual"}
|
||||
|
@ -1 +1 @@
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]}
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]}
|
||||
|
@ -1 +1 @@
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]}
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]}
|
||||
|
@ -1 +1 @@
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute":"attribute-value"}]}
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute":"attribute-value"}]}
|
||||
|
@ -1 +1 @@
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute":"attribute-value"}]}
|
||||
{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribute":"attribute-value"}]}
|
||||
|
@ -1 +1 @@
|
||||
iscsi-mycluster_myname-secret
|
||||
iscsi-mycluster_myname-secret
|
||||
|
@ -1 +1 @@
|
||||
iscsi-mycluster_myname-secret
|
||||
iscsi-mycluster_myname-secret
|
||||
|
@ -1 +1 @@
|
||||
test=testcookievalue; test2="blurb"
|
||||
test=testcookievalue; test2="blurb"
|
||||
|
@ -1 +1 @@
|
||||
test=testcookievalue; test2="blurb"
|
||||
test=testcookievalue; test2="blurb"
|
||||
|
@ -1 +1 @@
|
||||
cookie1=cookievalue1; cookie2=cookievalue2
|
||||
cookie1=cookievalue1; cookie2=cookievalue2
|
||||
|
@ -1 +1 @@
|
||||
cookie1=cookievalue1; cookie2=cookievalue2
|
||||
cookie1=cookievalue1; cookie2=cookievalue2
|
||||
|
@ -1 +1 @@
|
||||
iscsi-mycluster_myname-secret
|
||||
iscsi-mycluster_myname-secret
|
||||
|
@ -1 +1 @@
|
||||
cookie1=cookievalue1; cookie2=cookievalue2
|
||||
cookie1=cookievalue1; cookie2=cookievalue2
|
||||
|
@ -1 +1 @@
|
||||
cookie1=cookievalue1; cookie2=cookievalue2; cookie3=cookievalue3
|
||||
cookie1=cookievalue1; cookie2=cookievalue2; cookie3=cookievalue3
|
||||
|
@ -1 +1 @@
|
||||
iscsi-mycluster_myname-secret
|
||||
iscsi-mycluster_myname-secret
|
||||
|
@ -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)) {
|
||||
|
@ -1 +1 @@
|
||||
POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201)
|
||||
POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201)
|
||||
|
@ -1 +1 @@
|
||||
POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201)
|
||||
POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201)
|
||||
|
@ -1 +1 @@
|
||||
POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201)
|
||||
POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201)
|
||||
|
@ -1 +1 @@
|
||||
POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201)
|
||||
POWER8E (raw), altivec supported, rev 2.1 (pvr 004b 0201)
|
||||
|
@ -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
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user