[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: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 2/3] iotests: _filter_qmp for pretty JSON output |
Date: |
Tue, 11 Nov 2014 21:47:58 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
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 :)
But - is it really worth doing this in shell? Why not just do it in sed?
sed -e ... \
-e 's#\\#\\\\#g' \
-e '/ "QMP": {/,/ }/ c\' \
-e ' QMP_VERSION'
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature