qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output
Date: Wed, 12 Nov 2014 09:33:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 2014-11-12 at 05:47, Eric Blake wrote:
On 11/11/2014 06:34 AM, Max Reitz wrote:
_filter_qmp should be able to correctly filter out the QMP version
object for pretty JSON output.

Signed-off-by: Max Reitz <address@hidden>
---
  tests/qemu-iotests/common.filter | 16 +++++++++++++++-
  1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index 3acdb30..e24dab4 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -165,9 +165,23 @@ _filter_qemu()
  # replace problematic QMP output like timestamps
  _filter_qmp()
  {
+    discard=0
+
      _filter_win32 | \
      sed -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
-        -e 's#^{"QMP":.*}$#QMP_VERSION#'
+        -e 's#^{"QMP":.*}$#QMP_VERSION#' \
+        -e 's#\\#\\\\#g' | \
+        while IFS='' read line; do
+            if [[ $line == '    "QMP": {' ]]; then
Good that this is a /bin/bash script and not /bin/sh :)

Ah, right, yes, I just copied the code I had written for filtering out the image-specific information from the qemu-img info output.

But - is it really worth doing this in shell?  Why not just do it in sed?

Because I don't know sed well enough. ;-)

sed -e ... \
     -e 's#\\#\\\\#g' \
     -e '/    "QMP": {/,/    }/ c\' \
     -e '    QMP_VERSION'

Will do, thanks.

Max



reply via email to

[Prev in Thread] Current Thread [Next in Thread]