qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/3] iotests: _filter_qmp for pretty JSON output
Date: Fri, 14 Nov 2014 06:29:18 -0700	[thread overview]
Message-ID: <546603AE.90509@redhat.com> (raw)
In-Reply-To: <1415955731-11787-3-git-send-email-mreitz@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1442 bytes --]

On 11/14/2014 02:02 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 <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/common.filter | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
> index 3acdb30..63d15b3 100644
> --- a/tests/qemu-iotests/common.filter
> +++ b/tests/qemu-iotests/common.filter
> @@ -165,9 +165,12 @@ _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 '/^    "QMP": {\s*$/, /^    }\s*$/ c\    QMP_VERSION'

Technically, portable sed requires a newline between the initial 'c\'
and the first line of replacement.  Use of multiple -e is the easiest
way to provide newlines (sed concatenates separate -e strings with an
implicit newline).  Even though GNU sed doesn't barf on your variant,
I'd still prefer:

-e '/^    "QMP": {/, /^    }/ c\' \
-e '    QMP_VERSION'

written as two lines, to ensure we don't upset BSD sed.


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

  parent reply	other threads:[~2014-11-14 13:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14  9:02 [Qemu-devel] [PATCH v2 0/3] chardev: Add -qmp-pretty Max Reitz
2014-11-14  9:02 ` [Qemu-devel] [PATCH v2 1/3] " Max Reitz
2014-11-14  9:02 ` [Qemu-devel] [PATCH v2 2/3] iotests: _filter_qmp for pretty JSON output Max Reitz
2014-11-14  9:02   ` Max Reitz
2014-11-14 13:29   ` Eric Blake [this message]
2014-11-14  9:02 ` [Qemu-devel] [PATCH v2 3/3] iotests: Use -qmp-pretty in 067 Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=546603AE.90509@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).