From 0c5bae9e2abd50b5fbe71dbb614b586c675d77d3 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 26 Jun 2018 09:48:42 +0200 Subject: [PATCH 134/268] qemu-iotests: Add VM.qmp_log() RH-Author: Kevin Wolf Message-id: <20180626094856.6924-60-kwolf@redhat.com> Patchwork-id: 81067 O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 59/73] qemu-iotests: Add VM.qmp_log() Bugzilla: 1513543 RH-Acked-by: Jeffrey Cody RH-Acked-by: Max Reitz RH-Acked-by: Fam Zheng This adds a helper function that logs both the QMP request and the received response before returning it. Signed-off-by: Kevin Wolf Reviewed-by: Jeff Cody Reviewed-by: Max Reitz (cherry picked from commit e234398a8e142fd0cfe571f7efb0e6a2f34fe73d) Signed-off-by: Kevin Wolf Signed-off-by: Miroslav Rezanina --- tests/qemu-iotests/iotests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 8c08d05..e3de6b0 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -216,6 +216,10 @@ def filter_qmp_event(event): event['timestamp']['microseconds'] = 'USECS' return event +def filter_testfiles(msg): + prefix = os.path.join(test_dir, "%s-" % (os.getpid())) + return msg.replace(prefix, 'TEST_DIR/PID-') + def log(msg, filters=[]): for flt in filters: msg = flt(msg) @@ -399,6 +403,13 @@ class VM(qtest.QEMUQtestMachine): result.append(filter_qmp_event(ev)) return result + def qmp_log(self, cmd, filters=[filter_testfiles], **kwargs): + logmsg = "{'execute': '%s', 'arguments': %s}" % (cmd, kwargs) + log(logmsg, filters) + result = self.qmp(cmd, **kwargs) + log(str(result), filters) + return result + index_re = re.compile(r'([^\[]+)\[([^\]]+)\]') -- 1.8.3.1