Received: from eggs.gnu.org ([2001:4830:134:3::10]:42182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTZso-00076B-9V for qemu-devel@nongnu.org; Wed, 10 Feb 2016 13:52:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTZsj-00080v-5Y for qemu-devel@nongnu.org; Wed, 10 Feb 2016 13:52:58 -0500 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:38313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTZsi-0007zt-Re for qemu-devel@nongnu.org; Wed, 10 Feb 2016 13:52:53 -0500 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Feb 2016 18:52:49 -0000 From: Sascha Silbe In-Reply-To: <56BB68CA.6080508@redhat.com> References: <1455024190-105823-1-git-send-email-silbe@linux.vnet.ibm.com> <1455024190-105823-2-git-send-email-silbe@linux.vnet.ibm.com> <56BB68CA.6080508@redhat.com> Date: Wed, 10 Feb 2016 19:52:50 +0100 Message-ID: <87pow4cs8t.fsf@oc4731375738.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-iotests: add _filter_qmp_events() for filtering out QMP events List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org, Kevin Wolf , qemu-block@nongnu.org Cc: Tu Bo Dear Max, Max Reitz writes: >> +# remove QMP events from output >> +_filter_qmp_events() >> +{ >> + sed -e '/^{\(.*, \)"event": ".*}$/ d' >> +} > > There is a pretty good reason test 067 uses -qmp-pretty (as you yourself > say, the lines get pretty long otherwise, and if we have any change > within, the whole line needs to be changed). Additionally, it's a lot easier to read when indented properly, especially with the block info containing nested dicts. > Using the following ugly > piece of code here instead, we would still be able to use it: > > tr '\n' '\t' \ > | sed -e > 's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\= ?\s*}\s*//g' > \ > | tr '\t' '\n' Nice trick. Why didn't I come up with it? ;) It definitely is a bit ugly, though. We can't just drop the entire line (using "d") as the entire stream now is a single line. Matching parenthesis pairs is context sensitive, so we can't just use regular expressions to aggregate results into lines. And before I start implementing a JSON indenter in awk, I'd rather rewrite the whole test in Python. So if we stay with the shell test for now, we need something like your incantation above. It's not perfect, but good enough for now and I can't think of anything significantly simpler right now either. Will test your version and send a v2. Thanks for the suggestion! Sascha --=20 Softwareentwicklung Sascha Silbe, Niederhofenstra=C3=9Fe 5/1, 71229 Leonberg https://se-silbe.de/ USt-IdNr. DE281696641