Skip to content

Commit

Permalink
qemu-iotests: Add VM.qmp_log()
Browse files Browse the repository at this point in the history
This adds a helper function that logs both the QMP request and the
received response before returning it.

Signed-off-by: Kevin Wolf <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
  • Loading branch information
kevmw committed May 30, 2018
1 parent 5ad1dbf commit e234398
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/qemu-iotests/iotests.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,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)
Expand Down Expand Up @@ -389,6 +393,13 @@ def get_qmp_events_filtered(self, wait=True):
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'([^\[]+)\[([^\]]+)\]')

Expand Down

0 comments on commit e234398

Please sign in to comment.