yeahuh / rpms / qemu-kvm

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