Blame SOURCES/kvm-iotests-Let-216-make-use-of-qemu-io-s-exit-code.patch

ae23c9
From 3fd5087a6d6d8c366ab68ff804f975ef0c77b796 Mon Sep 17 00:00:00 2001
ae23c9
From: Max Reitz <mreitz@redhat.com>
ae23c9
Date: Mon, 18 Jun 2018 16:43:12 +0200
ae23c9
Subject: [PATCH 053/268] iotests: Let 216 make use of qemu-io's exit code
ae23c9
ae23c9
RH-Author: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: <20180618164312.24423-6-mreitz@redhat.com>
ae23c9
Patchwork-id: 80776
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 5/5] iotests: Let 216 make use of qemu-io's exit code
ae23c9
Bugzilla: 1519617
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
ae23c9
As a showcase of how you can use qemu-io's exit code to determine
ae23c9
success or failure (same for qemu-img), this test is changed to use
ae23c9
qemu_io_silent() instead of qemu_io(), and to assert the exit code
ae23c9
instead of logging the filtered result.
ae23c9
ae23c9
One real advantage of this is that in case of an error, you get a
ae23c9
backtrace that helps you locate the issue in the test file quickly.
ae23c9
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Reviewed-by: Eric Blake <eblake@redhat.com>
ae23c9
Message-id: 20180509194302.21585-6-mreitz@redhat.com
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
(cherry picked from commit e4ca4e981a0a389d6af5dc5d8b5fbdd1a05276a0)
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 tests/qemu-iotests/216     | 23 ++++++++++++-----------
ae23c9
 tests/qemu-iotests/216.out | 17 ++---------------
ae23c9
 2 files changed, 14 insertions(+), 26 deletions(-)
ae23c9
ae23c9
diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216
ae23c9
index ca9b47a..3c0ae54 100755
ae23c9
--- a/tests/qemu-iotests/216
ae23c9
+++ b/tests/qemu-iotests/216
ae23c9
@@ -20,7 +20,7 @@
ae23c9
 # Creator/Owner: Max Reitz <mreitz@redhat.com>
ae23c9
 
ae23c9
 import iotests
ae23c9
-from iotests import log, qemu_img_pipe, qemu_io, filter_qemu_io
ae23c9
+from iotests import log, qemu_img, qemu_io_silent
ae23c9
 
ae23c9
 # Need backing file support
ae23c9
 iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'])
ae23c9
@@ -50,14 +50,13 @@ with iotests.FilePath('base.img') as base_img_path, \
ae23c9
     log('--- Setting up images ---')
ae23c9
     log('')
ae23c9
 
ae23c9
-    qemu_img_pipe('create', '-f', iotests.imgfmt, base_img_path, '64M')
ae23c9
+    assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
ae23c9
+    assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
ae23c9
+    assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
ae23c9
+                    top_img_path) == 0
ae23c9
+    assert qemu_io_silent(top_img_path,  '-c', 'write -P 2 1M 1M') == 0
ae23c9
 
ae23c9
-    log(filter_qemu_io(qemu_io(base_img_path, '-c', 'write -P 1 0M 1M')))
ae23c9
-
ae23c9
-    qemu_img_pipe('create', '-f', iotests.imgfmt, '-b', base_img_path,
ae23c9
-                  top_img_path)
ae23c9
-
ae23c9
-    log(filter_qemu_io(qemu_io(top_img_path,  '-c', 'write -P 2 1M 1M')))
ae23c9
+    log('Done')
ae23c9
 
ae23c9
     log('')
ae23c9
     log('--- Doing COR ---')
ae23c9
@@ -110,6 +109,8 @@ with iotests.FilePath('base.img') as base_img_path, \
ae23c9
     log('--- Checking COR result ---')
ae23c9
     log('')
ae23c9
 
ae23c9
-    log(filter_qemu_io(qemu_io(base_img_path, '-c', 'discard 0 64M')))
ae23c9
-    log(filter_qemu_io(qemu_io(top_img_path,  '-c', 'read -P 1 0M 1M')))
ae23c9
-    log(filter_qemu_io(qemu_io(top_img_path,  '-c', 'read -P 2 1M 1M')))
ae23c9
+    assert qemu_io_silent(base_img_path, '-c', 'discard 0 64M') == 0
ae23c9
+    assert qemu_io_silent(top_img_path,  '-c', 'read -P 1 0M 1M') == 0
ae23c9
+    assert qemu_io_silent(top_img_path,  '-c', 'read -P 2 1M 1M') == 0
ae23c9
+
ae23c9
+    log('Done')
ae23c9
diff --git a/tests/qemu-iotests/216.out b/tests/qemu-iotests/216.out
ae23c9
index d3fc590..45ea857 100644
ae23c9
--- a/tests/qemu-iotests/216.out
ae23c9
+++ b/tests/qemu-iotests/216.out
ae23c9
@@ -3,12 +3,7 @@
ae23c9
 
ae23c9
 --- Setting up images ---
ae23c9
 
ae23c9
-wrote 1048576/1048576 bytes at offset 0
ae23c9
-1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
-
ae23c9
-wrote 1048576/1048576 bytes at offset 1048576
ae23c9
-1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
-
ae23c9
+Done
ae23c9
 
ae23c9
 --- Doing COR ---
ae23c9
 
ae23c9
@@ -17,12 +12,4 @@ wrote 1048576/1048576 bytes at offset 1048576
ae23c9
 
ae23c9
 --- Checking COR result ---
ae23c9
 
ae23c9
-discard 67108864/67108864 bytes at offset 0
ae23c9
-64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
-
ae23c9
-read 1048576/1048576 bytes at offset 0
ae23c9
-1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
-
ae23c9
-read 1048576/1048576 bytes at offset 1048576
ae23c9
-1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
-
ae23c9
+Done
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9