Received: from eggs.gnu.org ([2001:4830:134:3::10]:54917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTuVr-0003Wr-JA for qemu-devel@nongnu.org; Thu, 11 Feb 2016 11:54:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTuVn-00078Z-IK for qemu-devel@nongnu.org; Thu, 11 Feb 2016 11:54:39 -0500 Received: from e06smtp05.uk.ibm.com ([195.75.94.101]:53393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTuVn-00078I-8X for qemu-devel@nongnu.org; Thu, 11 Feb 2016 11:54:35 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 11 Feb 2016 16:54:33 -0000 From: Sascha Silbe In-Reply-To: <56BBB64B.7060401@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> <87pow4cs8t.fsf@oc4731375738.ibm.com> <56BBB64B.7060401@redhat.com> Date: Thu, 11 Feb 2016 17:54:31 +0100 Message-ID: <87a8n7chmg.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: Eric Blake , Max Reitz , qemu-devel@nongnu.org, Kevin Wolf , qemu-block@nongnu.org Cc: Tu Bo Dear Eric, Eric Blake writes: >>> tr '\n' '\t' \ >>> | sed -e >>> 's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\= )\?\s*}\s*//g' >>> \ >>> | tr '\t' '\n' >>=20 >> Nice trick. Why didn't I come up with it? ;) > > Mishandles any event whose data includes nested dicts. But a little bit > more creativity can do it in two passes (the first modifies the stream > to mark the start of an event, the second then does multiline matching > to nuke the entire event): > > tr '\n' '\t' | > sed 's/^{\(\s*"timestamp":\s*{[^}]*},\s*"event":\)/{MARK\1/g' | > tr '\t' '\n' | > sed '/^{MARK/,/^}/d' This is starting to get too complex for my taste. If _filter_qmp_events() isn't generic enough to be used by other test cases, I can make it internal to 067. Alternatively I can port 067 to Python, which can handle JSON data types natively with no need for post-processing hacks. Sascha --=20 Softwareentwicklung Sascha Silbe, Niederhofenstra=C3=9Fe 5/1, 71229 Leonberg https://se-silbe.de/ USt-IdNr. DE281696641