[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/2] tests: Collapse echoed JSON input to a single line
From: |
David Edmondson |
Subject: |
[PATCH v2 2/2] tests: Collapse echoed JSON input to a single line |
Date: |
Mon, 21 Dec 2020 13:49:31 +0000 |
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(-)
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
--
2.29.2