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

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