[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 2/3] iotests: _filter_qmp for pretty JSON out
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2 2/3] iotests: _filter_qmp for pretty JSON output |
Date: |
Fri, 14 Nov 2014 06:29:18 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
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 <address@hidden>
> ---
> 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
signature.asc
Description: OpenPGP digital signature