Blame SOURCES/kvm-qemu-iotests-Add-iotests.img_info_log.patch

357786
From ca9184bc1b0c0748b2c2e1395518f402be6f69e3 Mon Sep 17 00:00:00 2001
357786
From: Kevin Wolf <kwolf@redhat.com>
357786
Date: Tue, 26 Jun 2018 09:48:43 +0200
357786
Subject: [PATCH 74/89] qemu-iotests: Add iotests.img_info_log()
357786
357786
RH-Author: Kevin Wolf <kwolf@redhat.com>
357786
Message-id: <20180626094856.6924-61-kwolf@redhat.com>
357786
Patchwork-id: 81082
357786
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 60/73] qemu-iotests: Add iotests.img_info_log()
357786
Bugzilla: 1513543
357786
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
357786
RH-Acked-by: Max Reitz <mreitz@redhat.com>
357786
RH-Acked-by: Fam Zheng <famz@redhat.com>
357786
357786
This adds a filter function to postprocess 'qemu-img info' input
357786
(similar to what _img_info does), and an img_info_log() function that
357786
calls 'qemu-img info' and logs the filtered output.
357786
357786
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
357786
Reviewed-by: Max Reitz <mreitz@redhat.com>
357786
Reviewed-by: Jeff Cody <jcody@redhat.com>
357786
(cherry picked from commit 6b605adec4d7491488d9cfb50bc256e667d8caf1)
357786
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 tests/qemu-iotests/iotests.py | 18 ++++++++++++++++++
357786
 1 file changed, 18 insertions(+)
357786
357786
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
357786
index bc5731a..4b0760f 100644
357786
--- a/tests/qemu-iotests/iotests.py
357786
+++ b/tests/qemu-iotests/iotests.py
357786
@@ -109,6 +109,12 @@ def qemu_img_pipe(*args):
357786
         sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args))))
357786
     return subp.communicate()[0]
357786
 
357786
+def img_info_log(filename, filter_path=None):
357786
+    output = qemu_img_pipe('info', '-f', imgfmt, filename)
357786
+    if not filter_path:
357786
+        filter_path = filename
357786
+    log(filter_img_info(output, filter_path))
357786
+
357786
 def qemu_io(*args):
357786
     '''Run qemu-io and return the stdout data'''
357786
     args = qemu_io_args + list(args)
357786
@@ -219,6 +225,18 @@ def filter_testfiles(msg):
357786
     prefix = os.path.join(test_dir, "%s-" % (os.getpid()))
357786
     return msg.replace(prefix, 'TEST_DIR/PID-')
357786
 
357786
+def filter_img_info(output, filename):
357786
+    lines = []
357786
+    for line in output.split('\n'):
357786
+        if 'disk size' in line or 'actual-size' in line:
357786
+            continue
357786
+        line = line.replace(filename, 'TEST_IMG') \
357786
+                   .replace(imgfmt, 'IMGFMT')
357786
+        line = re.sub('iters: [0-9]+', 'iters: XXX', line)
357786
+        line = re.sub('uuid: [-a-f0-9]+', 'uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', line)
357786
+        lines.append(line)
357786
+    return '\n'.join(lines)
357786
+
357786
 def log(msg, filters=[]):
357786
     for flt in filters:
357786
         msg = flt(msg)
357786
-- 
357786
1.8.3.1
357786