Ala Hino has uploaded a new change for review. Change subject: tests: Change offset and len arguments type ......................................................................
tests: Change offset and len arguments type Change offset and len arguments type from string to integer. Change-Id: I0118332c75db873c3fb8c54fc0bced208d9c50e9 Signed-off-by: Ala Hino <ah...@redhat.com> --- M tests/qemuimg_test.py M tests/storagetestlib.py M tests/storagetestlib_test.py 3 files changed, 17 insertions(+), 16 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/65174/1 diff --git a/tests/qemuimg_test.py b/tests/qemuimg_test.py index f6e8b35..238985f 100644 --- a/tests/qemuimg_test.py +++ b/tests/qemuimg_test.py @@ -408,14 +408,14 @@ op.wait_for_completion() for i in range(base, top + 1): - offset = "{}k".format(i) + offset = i * 1024 pattern = 0xf0 + i # The base volume must have the data from all the volumes # merged into it. format = (qemuimg.FORMAT.RAW if i == 0 else qemuimg.FORMAT.QCOW2) qemu_pattern_verify(base_vol, format, offset=offset, - len='1k', pattern=pattern) + len=1024, pattern=pattern) if i > base: # internal and top volumes should keep the data, we # may want to wipe this data when deleting the volumes @@ -440,5 +440,6 @@ def make_image(path, size, format, index, qcow2_compat, backing=None): qemuimg.create(path, size=size, format=format, qcow2Compat=qcow2_compat, backing=backing) - qemu_pattern_write(path, format, offset="%dk" % index, len='1k', + offset = index * 1024 + qemu_pattern_write(path, format, offset=offset, len=1024, pattern=0xf0 + index) diff --git a/tests/storagetestlib.py b/tests/storagetestlib.py index 24cd27e..959a5fa 100644 --- a/tests/storagetestlib.py +++ b/tests/storagetestlib.py @@ -272,16 +272,16 @@ pass -def qemu_pattern_write(path, format, offset='512', len='1k', pattern=5): - write_cmd = 'write -P %d %s %s' % (pattern, offset, len) +def qemu_pattern_write(path, format, offset=512, len=1024, pattern=5): + write_cmd = 'write -P %d %d %d' % (pattern, offset, len) cmd = ['qemu-io', '-f', format, '-c', write_cmd, path] rc, out, err = commands.execCmd(cmd, raw=True) if rc != 0: raise cmdutils.Error(cmd, rc, out, err) -def qemu_pattern_verify(path, format, offset='512', len='1k', pattern=5): - read_cmd = 'read -P %d -s 0 -l %s %s %s' % (pattern, len, offset, len) +def qemu_pattern_verify(path, format, offset=512, len=1024, pattern=5): + read_cmd = 'read -P %d -s 0 -l %d %d %d' % (pattern, len, offset, len) cmd = ['qemu-io', '-f', format, '-c', read_cmd, path] rc, out, err = commands.execCmd(cmd, raw=True) if rc != 0: @@ -304,10 +304,10 @@ # This allows us to verify the integrity of the whole chain. for i, vol in enumerate(vol_list): vol_fmt = sc.fmt2str(vol.getFormat()) - offset = "{}k".format(i) + offset = i * 1024 pattern = 0xf0 + i qemu_pattern_write(vol.volumePath, vol_fmt, offset=offset, - len='1k', pattern=pattern) + len=1024, pattern=pattern) def verify_qemu_chain(vol_list): @@ -317,24 +317,24 @@ top_vol = vol_list[-1] top_vol_fmt = sc.fmt2str(top_vol.getFormat()) for i, vol in enumerate(vol_list): - offset = "{}k".format(i) + offset = i * 1024 pattern = 0xf0 + i # Check that the correct pattern can be read through the top volume qemu_pattern_verify(top_vol.volumePath, top_vol_fmt, offset=offset, - len='1k', pattern=pattern) + len=1024, pattern=pattern) # Check the volume where the pattern was originally written vol_fmt = sc.fmt2str(vol.getFormat()) - qemu_pattern_verify(vol.volumePath, vol_fmt, offset=offset, len='1k', + qemu_pattern_verify(vol.volumePath, vol_fmt, offset=offset, len=1024, pattern=pattern) # Check that the next offset contains zeroes. If we know this layer # has zeroes at next_offset we can be sure that data read at the same # offset in the next layer belongs to that layer. - next_offset = "{}K".format(i + 1) + next_offset = (i + 1) * 1024 qemu_pattern_verify(vol.volumePath, vol_fmt, offset=next_offset, - len='1k', pattern=0) + len=1024, pattern=0) def make_qemu_chain(env, size, base_vol_fmt, chain_len): diff --git a/tests/storagetestlib_test.py b/tests/storagetestlib_test.py index a7d6a2c..170082d 100644 --- a/tests/storagetestlib_test.py +++ b/tests/storagetestlib_test.py @@ -218,8 +218,8 @@ qemu_pattern_verify(path, img_format) @permutations(( - ('0', '128'), - ('10k', '5k') + (0, 128), + (10*1024, 5*1024) )) def test_match_custom_offset_and_len(self, offset, len): with namedTemporaryDir() as tmpdir: -- To view, visit https://gerrit.ovirt.org/65174 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0118332c75db873c3fb8c54fc0bced208d9c50e9 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Ala Hino <ah...@redhat.com> _______________________________________________ vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org