diff mbox series

[09/67] iotests.py: Add @hide_fields to img_info_log

Message ID 20191001194715.2796-10-mreitz@redhat.com
State New
Headers show
Series iotests: Honor $IMGOPTS in Python tests | expand

Commit Message

Max Reitz Oct. 1, 2019, 7:46 p.m. UTC
You can specify fields here that should be hidden from the output.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 9737dd881b..f3c80ba4e9 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -201,7 +201,8 @@  def qemu_img_log(*args):
     log(result, filters=[filter_testfiles])
     return result
 
-def img_info_log(filename, filter_path=None, imgopts=False, extra_args=[]):
+def img_info_log(filename, filter_path=None, imgopts=False, extra_args=[],
+                 hide_fields=[]):
     args = [ 'info' ]
     if imgopts:
         args.append('--image-opts')
@@ -210,7 +211,13 @@  def img_info_log(filename, filter_path=None, imgopts=False, extra_args=[]):
     args += extra_args
     args.append(filename)
 
-    output = qemu_img_pipe(*args)
+    output = qemu_img_pipe(*args).splitlines(keepends=True)
+
+    output = [line for line in output
+              if not any(line.strip().startswith(field)
+                         for field in hide_fields)]
+    output = ''.join(output)
+
     if not filter_path:
         filter_path = filename
     log(filter_img_info(output, filter_path))