iotests: Remove explicit checks for qemu_img() == 0
qemu_img() returning zero ought to be the rule, not the exception. Remove all explicit checks against the condition in preparation for making non-zero returns an Exception. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220321201618.903471-4-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
This commit is contained in:
parent
062fd1dad2
commit
fc272d3ce0
@ -107,8 +107,7 @@ class ShrinkBaseClass(iotests.QMPTestCase):
|
||||
|
||||
if iotests.imgfmt == 'raw':
|
||||
return
|
||||
self.assertEqual(qemu_img('check', test_img), 0,
|
||||
"Verifying image corruption")
|
||||
qemu_img('check', test_img)
|
||||
|
||||
def test_empty_image(self):
|
||||
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
|
||||
@ -130,8 +129,7 @@ class ShrinkBaseClass(iotests.QMPTestCase):
|
||||
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
|
||||
self.shrink_size)
|
||||
|
||||
self.assertEqual(qemu_img("compare", test_img, check_img), 0,
|
||||
"Verifying image content")
|
||||
qemu_img("compare", test_img, check_img)
|
||||
|
||||
self.image_verify()
|
||||
|
||||
@ -146,8 +144,7 @@ class ShrinkBaseClass(iotests.QMPTestCase):
|
||||
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
|
||||
self.shrink_size)
|
||||
|
||||
self.assertEqual(qemu_img("compare", test_img, check_img), 0,
|
||||
"Verifying image content")
|
||||
qemu_img("compare", test_img, check_img)
|
||||
|
||||
self.image_verify()
|
||||
|
||||
|
@ -51,10 +51,10 @@ with iotests.FilePath('base.img') as base_img_path, \
|
||||
log('--- Setting up images ---')
|
||||
log('')
|
||||
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
|
||||
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,
|
||||
'-F', iotests.imgfmt, top_img_path) == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||
'-F', iotests.imgfmt, top_img_path)
|
||||
assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
|
||||
|
||||
log('Done')
|
||||
|
@ -145,7 +145,7 @@ log('')
|
||||
with iotests.VM() as vm, \
|
||||
iotests.FilePath('src.img') as src_img_path:
|
||||
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M')
|
||||
assert qemu_io_silent('-f', iotests.imgfmt, src_img_path,
|
||||
'-c', 'write -P 42 0M 64M') == 0
|
||||
|
||||
|
@ -47,12 +47,11 @@ for filter_node_name in False, True:
|
||||
iotests.FilePath('top.img') as top_img_path, \
|
||||
iotests.VM() as vm:
|
||||
|
||||
assert qemu_img('create', '-f', iotests.imgfmt,
|
||||
base_img_path, '64M') == 0
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||
'-F', iotests.imgfmt, mid_img_path) == 0
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
|
||||
'-F', iotests.imgfmt, top_img_path) == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||
'-F', iotests.imgfmt, mid_img_path)
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
|
||||
'-F', iotests.imgfmt, top_img_path)
|
||||
|
||||
# Something to commit
|
||||
assert qemu_io_silent(mid_img_path, '-c', 'write -P 1 0 1M') == 0
|
||||
|
@ -54,11 +54,11 @@ with iotests.FilePath('base.img') as base_img_path, \
|
||||
iotests.FilePath('top.img') as top_img_path, \
|
||||
iotests.VM() as vm:
|
||||
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
|
||||
# Choose a funny way to describe the backing filename
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, '-b',
|
||||
'file:' + base_img_path, '-F', iotests.imgfmt,
|
||||
top_img_path) == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b',
|
||||
'file:' + base_img_path, '-F', iotests.imgfmt,
|
||||
top_img_path)
|
||||
|
||||
vm.launch()
|
||||
|
||||
@ -172,8 +172,8 @@ with iotests.FilePath('base.img') as base_img_path, \
|
||||
# (because qemu cannot "canonicalize"/"resolve" the backing
|
||||
# filename unless the backing file is opened implicitly with the
|
||||
# overlay)
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||
'-F', iotests.imgfmt, top_img_path) == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||
'-F', iotests.imgfmt, top_img_path)
|
||||
|
||||
# You can only reliably override backing options by using a node
|
||||
# reference (or by specifying file.filename, but, well...)
|
||||
|
@ -240,8 +240,7 @@ def compare_images(image, reference, baseimg=None, expected_match=True):
|
||||
"""
|
||||
expected_ret = 0 if expected_match else 1
|
||||
if baseimg:
|
||||
assert qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt,
|
||||
image) == 0
|
||||
qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt, image)
|
||||
ret = qemu_img("compare", image, reference)
|
||||
log('qemu_img compare "{:s}" "{:s}" ==> {:s}, {:s}'.format(
|
||||
image, reference,
|
||||
|
@ -75,13 +75,13 @@ def test_concurrent_finish(write_to_stream_node):
|
||||
|
||||
# It is important to use raw for the base layer (so that
|
||||
# permissions are just handed through to the protocol layer)
|
||||
assert qemu_img('create', '-f', 'raw', node0_path, '64M') == 0
|
||||
qemu_img('create', '-f', 'raw', node0_path, '64M')
|
||||
|
||||
stream_throttle=None
|
||||
commit_throttle=None
|
||||
|
||||
for path in [node1_path, node2_path, node3_path, node4_path]:
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, path, '64M') == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, path, '64M')
|
||||
|
||||
if write_to_stream_node:
|
||||
# This is what (most of the time) makes commit finish
|
||||
|
@ -43,15 +43,15 @@ with iotests.FilePath('base.img') as base_img_path, \
|
||||
log('--- Setting up images ---')
|
||||
log('')
|
||||
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
|
||||
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
|
||||
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') == 0
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||
'-F', iotests.imgfmt, mid_img_path) == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||
'-F', iotests.imgfmt, mid_img_path)
|
||||
assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0
|
||||
assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
|
||||
'-F', iotests.imgfmt, top_img_path) == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
|
||||
'-F', iotests.imgfmt, top_img_path)
|
||||
assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
|
||||
|
||||
# 0 1 2 3 4
|
||||
@ -105,8 +105,7 @@ with iotests.FilePath('base.img') as base_img_path, \
|
||||
log('')
|
||||
|
||||
# Detach backing to check that we can read the data from the top level now
|
||||
assert qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt,
|
||||
top_img_path) == 0
|
||||
qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, top_img_path)
|
||||
|
||||
assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0
|
||||
assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
|
||||
|
@ -35,8 +35,7 @@ nbd_sock = os.path.join(iotests.sock_dir, 'nbd.sock')
|
||||
class TestBscWithNbd(iotests.QMPTestCase):
|
||||
def setUp(self) -> None:
|
||||
"""Just create an empty image with a read-only NBD server on it"""
|
||||
assert qemu_img_create('-f', iotests.imgfmt, test_img,
|
||||
str(image_size)) == 0
|
||||
qemu_img_create('-f', iotests.imgfmt, test_img, str(image_size))
|
||||
|
||||
# Pass --allocation-depth to enable the qemu:allocation-depth context,
|
||||
# which we are going to query to provoke a block-status inquiry with
|
||||
|
@ -34,16 +34,15 @@ def do_qemu_img_bench() -> None:
|
||||
"""
|
||||
Do some I/O requests on `nbd_sock`.
|
||||
"""
|
||||
assert qemu_img('bench', '-f', 'raw', '-c', '2000000',
|
||||
f'nbd+unix:///node0?socket={nbd_sock}') == 0
|
||||
qemu_img('bench', '-f', 'raw', '-c', '2000000',
|
||||
f'nbd+unix:///node0?socket={nbd_sock}')
|
||||
|
||||
|
||||
class TestGraphChangesWhileIO(QMPTestCase):
|
||||
def setUp(self) -> None:
|
||||
# Create an overlay that can be added at runtime on top of the
|
||||
# null-co block node that will receive I/O
|
||||
assert qemu_img_create('-f', imgfmt, '-F', 'raw', '-b', 'null-co://',
|
||||
top) == 0
|
||||
qemu_img_create('-f', imgfmt, '-F', 'raw', '-b', 'null-co://', top)
|
||||
|
||||
# QSD instance with a null-co block node in an I/O thread,
|
||||
# exported over NBD (on `nbd_sock`, export name "node0")
|
||||
|
@ -63,18 +63,18 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path,
|
||||
log('--- Setting up images ---')
|
||||
log('')
|
||||
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
|
||||
if bitmap:
|
||||
assert qemu_img('bitmap', '--add', base_img_path, 'bitmap0') == 0
|
||||
qemu_img('bitmap', '--add', base_img_path, 'bitmap0')
|
||||
|
||||
if use_snapshot_access_filter:
|
||||
assert use_cbw
|
||||
assert qemu_img('create', '-f', 'raw', fleece_img_path, '64M') == 0
|
||||
qemu_img('create', '-f', 'raw', fleece_img_path, '64M')
|
||||
else:
|
||||
assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0
|
||||
qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M')
|
||||
|
||||
if push_backup:
|
||||
assert qemu_img('create', '-f', 'qcow2', target_img_path, '64M') == 0
|
||||
qemu_img('create', '-f', 'qcow2', target_img_path, '64M')
|
||||
|
||||
for p in patterns:
|
||||
qemu_io('-f', iotests.imgfmt,
|
||||
|
@ -31,10 +31,8 @@ target = os.path.join(iotests.test_dir, 'target.img')
|
||||
|
||||
class TestMirrorReadyCancelError(iotests.QMPTestCase):
|
||||
def setUp(self) -> None:
|
||||
assert iotests.qemu_img_create('-f', iotests.imgfmt, source,
|
||||
str(image_size)) == 0
|
||||
assert iotests.qemu_img_create('-f', iotests.imgfmt, target,
|
||||
str(image_size)) == 0
|
||||
iotests.qemu_img_create('-f', iotests.imgfmt, source, str(image_size))
|
||||
iotests.qemu_img_create('-f', iotests.imgfmt, target, str(image_size))
|
||||
|
||||
# Ensure that mirror will copy something before READY so the
|
||||
# target format layer will forward the pre-READY flush to its
|
||||
|
@ -34,8 +34,7 @@ source = os.path.join(iotests.test_dir, 'source.img')
|
||||
|
||||
class TestMirrorTopPerms(iotests.QMPTestCase):
|
||||
def setUp(self):
|
||||
assert qemu_img('create', '-f', iotests.imgfmt, source,
|
||||
str(image_size)) == 0
|
||||
qemu_img('create', '-f', iotests.imgfmt, source, str(image_size))
|
||||
self.vm = iotests.VM()
|
||||
self.vm.add_drive(source)
|
||||
self.vm.add_blockdev(f'null-co,node-name=null,size={image_size}')
|
||||
|
@ -27,11 +27,11 @@ iotests.script_initialize(supported_fmts=['qcow2'],
|
||||
top, base = iotests.file_path('top', 'base')
|
||||
size = '1M'
|
||||
|
||||
assert qemu_img_create('-f', iotests.imgfmt, base, size) == 0
|
||||
assert qemu_img_create('-f', iotests.imgfmt, '-b', base,
|
||||
'-F', iotests.imgfmt, top, size) == 0
|
||||
qemu_img_create('-f', iotests.imgfmt, base, size)
|
||||
qemu_img_create('-f', iotests.imgfmt, '-b', base,
|
||||
'-F', iotests.imgfmt, top, size)
|
||||
|
||||
assert qemu_img('bitmap', '--add', base, 'bitmap0') == 0
|
||||
qemu_img('bitmap', '--add', base, 'bitmap0')
|
||||
# Just assert that our method of checking bitmaps in the image works.
|
||||
assert 'bitmaps' in qemu_img_pipe('info', base)
|
||||
|
||||
|
@ -54,9 +54,9 @@ class TestStreamErrorOnReset(QMPTestCase):
|
||||
to it will result in an error
|
||||
- top image is attached to a virtio-scsi device
|
||||
"""
|
||||
assert qemu_img_create('-f', imgfmt, base, str(image_size)) == 0
|
||||
qemu_img_create('-f', imgfmt, base, str(image_size))
|
||||
assert qemu_io_silent('-c', f'write 0 {data_size}', base) == 0
|
||||
assert qemu_img_create('-f', imgfmt, top, str(image_size)) == 0
|
||||
qemu_img_create('-f', imgfmt, top, str(image_size))
|
||||
|
||||
self.vm = iotests.VM()
|
||||
self.vm.add_args('-accel', 'tcg') # Make throttling work properly
|
||||
|
Loading…
x
Reference in New Issue
Block a user