diff mbox series

[v2,2/2] tests: Collapse echoed JSON input to a single line

Message ID 20201221134931.1194806-3-david.edmondson@oracle.com (mailing list archive)
State New, archived
Headers show
Series block: report errno when flock fcntl fails | expand

Commit Message

David Edmondson Dec. 21, 2020, 1:49 p.m. UTC
When sending JSON to running qemu, qemu-io, etc. instances, flatten
the echoed input to a single line to ensure that comparisons with the
expected input (which is always a single line) are successful.

Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
 tests/qemu-iotests/common.filter | 6 ++++++
 tests/qemu-iotests/common.qemu   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Max Reitz Jan. 6, 2021, 9:49 a.m. UTC | #1
On 21.12.20 14:49, David Edmondson wrote:
> When sending JSON to running qemu, qemu-io, etc. instances, flatten
> the echoed input to a single line to ensure that comparisons with the
> expected input (which is always a single line) are successful.
> 
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
>   tests/qemu-iotests/common.filter | 6 ++++++
>   tests/qemu-iotests/common.qemu   | 2 +-
>   2 files changed, 7 insertions(+), 1 deletion(-)

I think this is superseded now by commit 0e72078128229bf9efb54.

Max
David Edmondson Jan. 6, 2021, 5:20 p.m. UTC | #2
On Wednesday, 2021-01-06 at 10:49:06 +01, Max Reitz wrote:

> On 21.12.20 14:49, David Edmondson wrote:
>> When sending JSON to running qemu, qemu-io, etc. instances, flatten
>> the echoed input to a single line to ensure that comparisons with the
>> expected input (which is always a single line) are successful.
>> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
>> ---
>>   tests/qemu-iotests/common.filter | 6 ++++++
>>   tests/qemu-iotests/common.qemu   | 2 +-
>>   2 files changed, 7 insertions(+), 1 deletion(-)
>
> I think this is superseded now by commit 0e72078128229bf9efb54.

Yes, agreed.

dme.
diff mbox series

Patch

diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index 172ea5752e..d51df59769 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -332,5 +332,11 @@  for fname in fnames:
 sys.stdout.write(result)'
 }
 
+# Convert multi-line input to a single line.
+_filter_collapse_lines()
+{
+    (tr -d '\n'; echo)
+}
+
 # make sure this script returns success
 true
diff --git a/tests/qemu-iotests/common.qemu b/tests/qemu-iotests/common.qemu
index de680cf1c7..9604c78b8a 100644
--- a/tests/qemu-iotests/common.qemu
+++ b/tests/qemu-iotests/common.qemu
@@ -159,7 +159,7 @@  _send_qemu_cmd()
     # input back to output); decide based on leading '{'
     if [ -z "$silent" ] && [ -z "$mismatch_only" ] &&
             [ "$cmd" != "${cmd#\{}" ]; then
-        echo "${cmd}" | _filter_testdir | _filter_imgfmt
+        echo "${cmd}" | _filter_testdir | _filter_imgfmt | _filter_collapse_lines
     fi
     while [ ${count} -gt 0 ]
     do