mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 01:50:43 +00:00
iotests: Let 216 make use of qemu-io's exit code
As a showcase of how you can use qemu-io's exit code to determine success or failure (same for qemu-img), this test is changed to use qemu_io_silent() instead of qemu_io(), and to assert the exit code instead of logging the filtered result. One real advantage of this is that in case of an error, you get a backtrace that helps you locate the issue in the test file quickly. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20180509194302.21585-6-mreitz@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
745f2bf4a5
commit
e4ca4e981a
@ -20,7 +20,7 @@
|
|||||||
# Creator/Owner: Max Reitz <mreitz@redhat.com>
|
# Creator/Owner: Max Reitz <mreitz@redhat.com>
|
||||||
|
|
||||||
import iotests
|
import iotests
|
||||||
from iotests import log, qemu_img_pipe, qemu_io, filter_qemu_io
|
from iotests import log, qemu_img, qemu_io_silent
|
||||||
|
|
||||||
# Need backing file support
|
# Need backing file support
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'])
|
iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'])
|
||||||
@ -50,14 +50,13 @@ with iotests.FilePath('base.img') as base_img_path, \
|
|||||||
log('--- Setting up images ---')
|
log('--- Setting up images ---')
|
||||||
log('')
|
log('')
|
||||||
|
|
||||||
qemu_img_pipe('create', '-f', iotests.imgfmt, base_img_path, '64M')
|
assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
|
||||||
|
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
|
||||||
|
assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||||
|
top_img_path) == 0
|
||||||
|
assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
|
||||||
|
|
||||||
log(filter_qemu_io(qemu_io(base_img_path, '-c', 'write -P 1 0M 1M')))
|
log('Done')
|
||||||
|
|
||||||
qemu_img_pipe('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
|
||||||
top_img_path)
|
|
||||||
|
|
||||||
log(filter_qemu_io(qemu_io(top_img_path, '-c', 'write -P 2 1M 1M')))
|
|
||||||
|
|
||||||
log('')
|
log('')
|
||||||
log('--- Doing COR ---')
|
log('--- Doing COR ---')
|
||||||
@ -110,6 +109,8 @@ with iotests.FilePath('base.img') as base_img_path, \
|
|||||||
log('--- Checking COR result ---')
|
log('--- Checking COR result ---')
|
||||||
log('')
|
log('')
|
||||||
|
|
||||||
log(filter_qemu_io(qemu_io(base_img_path, '-c', 'discard 0 64M')))
|
assert qemu_io_silent(base_img_path, '-c', 'discard 0 64M') == 0
|
||||||
log(filter_qemu_io(qemu_io(top_img_path, '-c', 'read -P 1 0M 1M')))
|
assert qemu_io_silent(top_img_path, '-c', 'read -P 1 0M 1M') == 0
|
||||||
log(filter_qemu_io(qemu_io(top_img_path, '-c', 'read -P 2 1M 1M')))
|
assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
|
||||||
|
|
||||||
|
log('Done')
|
||||||
|
@ -3,12 +3,7 @@
|
|||||||
|
|
||||||
--- Setting up images ---
|
--- Setting up images ---
|
||||||
|
|
||||||
wrote 1048576/1048576 bytes at offset 0
|
Done
|
||||||
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
||||||
|
|
||||||
wrote 1048576/1048576 bytes at offset 1048576
|
|
||||||
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
||||||
|
|
||||||
|
|
||||||
--- Doing COR ---
|
--- Doing COR ---
|
||||||
|
|
||||||
@ -17,12 +12,4 @@ wrote 1048576/1048576 bytes at offset 1048576
|
|||||||
|
|
||||||
--- Checking COR result ---
|
--- Checking COR result ---
|
||||||
|
|
||||||
discard 67108864/67108864 bytes at offset 0
|
Done
|
||||||
64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
||||||
|
|
||||||
read 1048576/1048576 bytes at offset 0
|
|
||||||
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
||||||
|
|
||||||
read 1048576/1048576 bytes at offset 1048576
|
|
||||||
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user