aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/044
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2018-10-22 14:53:01 +0100
committerEduardo Habkost <ehabkost@redhat.com>2018-10-30 21:11:52 -0300
commit8eb5e6746feaf9e021b69ea2521899f8dc889033 (patch)
treed583c2b1ff0c86cffda689278e9e176bb73c6274 /tests/qemu-iotests/044
parentf544adf736cb1b100a7fe926f3712157b22c3ddd (diff)
downloadqemu-8eb5e6746feaf9e021b69ea2521899f8dc889033.zip
qemu-8eb5e6746feaf9e021b69ea2521899f8dc889033.tar.gz
qemu-8eb5e6746feaf9e021b69ea2521899f8dc889033.tar.bz2
iotests: Use Python byte strings where appropriate
Since byte strings are no longer the default in Python 3, we have to explicitly use them where we need to, which is mostly when working with structures. It also means that we need to open a file in binary mode when we want to use structures. On the other hand, we have to accomodate for the fact that some functions (still) work with byte strings but we want to use unicode strings (in Python 3 at least, and it does not matter in Python 2). This includes base64 encoding, but it is most notable when working with the subprocess module: Either we set universal_newlines to True so that the default streams are opened in text mode (hence this parameter is aliased as "text" as of 3.7), or, if that is not possible, we have to decode the output to a normal string. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20181022135307.14398-4-mreitz@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/044')
-rwxr-xr-xtests/qemu-iotests/0448
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
index 11ea0f4..69e736f 100755
--- a/tests/qemu-iotests/044
+++ b/tests/qemu-iotests/044
@@ -53,21 +53,21 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
fd.seek(off_reftable)
for i in xrange(0, h.refcount_table_clusters):
- sector = ''.join(struct.pack('>Q',
+ sector = b''.join(struct.pack('>Q',
off_refblock + i * 64 * 512 + j * 512)
for j in xrange(0, 64))
fd.write(sector)
# Write the refcount blocks
assert(fd.tell() == off_refblock)
- sector = ''.join(struct.pack('>H', 1) for j in xrange(0, 64 * 256))
+ sector = b''.join(struct.pack('>H', 1) for j in range(0, 64 * 256))
for block in xrange(0, h.refcount_table_clusters):
fd.write(sector)
# Write the L1 table
assert(fd.tell() == off_l1)
assert(off_l2 + 512 * h.l1_size == off_data)
- table = ''.join(struct.pack('>Q', (1 << 63) | off_l2 + 512 * j)
+ table = b''.join(struct.pack('>Q', (1 << 63) | off_l2 + 512 * j)
for j in xrange(0, h.l1_size))
fd.write(table)
@@ -85,7 +85,7 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
remaining = remaining - 1024 * 512
off = off + 1024 * 512
- table = ''.join(struct.pack('>Q', (1 << 63) | off + 512 * j)
+ table = b''.join(struct.pack('>Q', (1 << 63) | off + 512 * j)
for j in xrange(0, remaining / 512))
fd.write(table)