aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/242
diff options
context:
space:
mode:
authorAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>2019-02-26 19:11:35 +0300
committerEric Blake <eblake@redhat.com>2019-02-26 10:37:06 -0600
commit42eb4591febefad29fc995785ce11a475fb47d90 (patch)
tree3ab5b5b68dfd015d85dac96dead2e08d21c8d6e1 /tests/qemu-iotests/242
parentd88d85f1f0625d57e9f354aa0874c4c8b5d1fb47 (diff)
downloadqemu-42eb4591febefad29fc995785ce11a475fb47d90.zip
qemu-42eb4591febefad29fc995785ce11a475fb47d90.tar.gz
qemu-42eb4591febefad29fc995785ce11a475fb47d90.tar.bz2
iotests: handle TypeError for Python 3 in test 242
The data type for bytes in Python 3 differs from the one in Python 2. The type cast that is compatible with both versions was applied. Signed-off-by: Nir Soffer <nsoffer@redhat.com> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> Reported-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <1551197495-24425-1-git-send-email-andrey.shinkevich@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/242')
-rwxr-xr-xtests/qemu-iotests/2428
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
index 16c65ed..c176e92 100755
--- a/tests/qemu-iotests/242
+++ b/tests/qemu-iotests/242
@@ -20,6 +20,7 @@
import iotests
import json
+import struct
from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \
file_path, img_info_log, log, filter_qemu_io
@@ -64,10 +65,11 @@ def write_to_disk(offset, size):
def toggle_flag(offset):
with open(disk, "r+b") as f:
f.seek(offset, 0)
- c = f.read(1)
- toggled = chr(ord(c) ^ bitmap_flag_unknown)
+ # Read one byte in a way compatible with Python 2
+ flags = struct.unpack("B", f.read(1))
+ toggled = flags[0] ^ bitmap_flag_unknown
f.seek(-1, 1)
- f.write(toggled)
+ f.write(struct.pack("B", toggled))
qemu_img_create('-f', iotests.imgfmt, disk, '1M')