summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/qemu-iotests/iotests.py6
-rwxr-xr-xtests/qemu-iotests/qcow2.py37
-rwxr-xr-xtests/qemu-iotests/qed.py17
3 files changed, 28 insertions, 32 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 33ad0ecb9..73733fc99 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -22,10 +22,10 @@ import subprocess
import string
import unittest
import sys; sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'QMP'))
-import qmp
+import qmp #pylint: disable=import-error
import struct
-__all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io',
+__all__ = ['imgfmt', 'imgproto', 'test_dir', 'qemu_img', 'qemu_io',
'VM', 'QMPTestCase', 'notrun', 'main']
# This will not work if arguments or path contain spaces but is necessary if we
@@ -234,7 +234,7 @@ def notrun(reason):
seq = os.path.basename(sys.argv[0])
open('%s.notrun' % seq, 'wb').write(reason + '\n')
- print '%s not run: %s' % (seq, reason)
+ print( '%s not run: %s' % (seq, reason))
sys.exit(0)
def main(supported_fmts=[]):
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
index 44a2b4564..a5c3982ee 100755
--- a/tests/qemu-iotests/qcow2.py
+++ b/tests/qemu-iotests/qcow2.py
@@ -42,7 +42,7 @@ class QcowHeader:
[ uint64_t, '%#x', 'autoclear_features' ],
[ uint32_t, '%d', 'refcount_order' ],
[ uint32_t, '%d', 'header_length' ],
- ];
+ ]
fmt = '>' + ''.join(field[0] for field in fields)
@@ -125,8 +125,7 @@ class QcowHeader:
def dump(self):
for f in QcowHeader.fields:
- print "%-25s" % f[2], f[1] % self.__dict__[f[2]]
- print ""
+ print( "%-25s" % f[2], f[1] % self.__dict__[f[2]])
def dump_extensions(self):
for ex in self.extensions:
@@ -137,11 +136,10 @@ class QcowHeader:
else:
data = "<binary>"
- print "Header extension:"
- print "%-25s %#x" % ("magic", ex.magic)
- print "%-25s %d" % ("length", ex.length)
- print "%-25s %s" % ("data", data)
- print ""
+ print( "Header extension:")
+ print("%-25s %#x" % ("magic", ex.magic))
+ print( "%-25s %d" % ("length", ex.length))
+ print( "%-25s %s" % ("data", data))
def cmd_dump_header(fd):
@@ -153,12 +151,12 @@ def cmd_set_header(fd, name, value):
try:
value = int(value, 0)
except:
- print "'%s' is not a valid number" % value
+ print( "'%s' is not a valid number" % value)
sys.exit(1)
fields = (field[2] for field in QcowHeader.fields)
if not name in fields:
- print "'%s' is not a known header field" % name
+ print( "'%s' is not a known header field" % name)
sys.exit(1)
h = QcowHeader(fd)
@@ -169,7 +167,7 @@ def cmd_add_header_ext(fd, magic, data):
try:
magic = int(magic, 0)
except:
- print "'%s' is not a valid magic number" % magic
+ print( "'%s' is not a valid magic number" % magic)
sys.exit(1)
h = QcowHeader(fd)
@@ -180,7 +178,7 @@ def cmd_del_header_ext(fd, magic):
try:
magic = int(magic, 0)
except:
- print "'%s' is not a valid magic number" % magic
+ print( "'%s' is not a valid magic number" % magic)
sys.exit(1)
h = QcowHeader(fd)
@@ -192,7 +190,7 @@ def cmd_del_header_ext(fd, magic):
h.extensions.remove(ex)
if not found:
- print "No such header extension"
+ print( "No such header extension")
return
h.update(fd)
@@ -203,7 +201,7 @@ def cmd_set_feature_bit(fd, group, bit):
if bit < 0 or bit >= 64:
raise ValueError
except:
- print "'%s' is not a valid bit number in range [0, 64)" % bit
+ print( "'%s' is not a valid bit number in range [0, 64)" % bit)
sys.exit(1)
h = QcowHeader(fd)
@@ -214,7 +212,7 @@ def cmd_set_feature_bit(fd, group, bit):
elif group == 'autoclear':
h.autoclear_features |= 1 << bit
else:
- print "'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group
+ print( "'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group)
sys.exit(1)
h.update(fd)
@@ -239,16 +237,15 @@ def main(filename, cmd, args):
else:
handler(fd, *args)
return
- print "Unknown command '%s'" % cmd
+ print( "Unknown command '%s'" % cmd)
finally:
fd.close()
def usage():
- print "Usage: %s <file> <cmd> [<arg>, ...]" % sys.argv[0]
- print ""
- print "Supported commands:"
+ print( "Usage: %s <file> <cmd> [<arg>, ...]" % sys.argv[0])
+ print( "Supported commands:")
for name, handler, num_args, desc in cmds:
- print " %-20s - %s" % (name, desc)
+ print( " %-20s - %s" % (name, desc))
if __name__ == '__main__':
if len(sys.argv) < 3:
diff --git a/tests/qemu-iotests/qed.py b/tests/qemu-iotests/qed.py
index 52ff84559..2077228a8 100755
--- a/tests/qemu-iotests/qed.py
+++ b/tests/qemu-iotests/qed.py
@@ -108,12 +108,12 @@ def corrupt_table_invalidate(qed, table):
def cmd_show(qed, *args):
'''show [header|l1|l2 <offset>]- Show header or l1/l2 tables'''
if not args or args[0] == 'header':
- print qed.header
+ print( qed.header)
elif args[0] == 'l1':
- print qed.l1_table
+ print( qed.l1_table)
elif len(args) == 2 and args[0] == 'l2':
offset = int(args[1])
- print qed.read_table(offset)
+ print (qed.read_table(offset))
else:
err('unrecognized sub-command')
@@ -146,7 +146,7 @@ def cmd_invalidate(qed, table_level):
def cmd_need_check(qed, *args):
'''need-check [on|off] - Test, set, or clear the QED_F_NEED_CHECK header bit'''
if not args:
- print bool(qed.header['features'] & QED_F_NEED_CHECK)
+ print (bool(qed.header['features'] & QED_F_NEED_CHECK))
return
if args[0] == 'on':
@@ -208,17 +208,16 @@ def cmd_copy_metadata(qed, outfile):
out.close()
def usage():
- print 'Usage: %s <file> <cmd> [<arg>, ...]' % sys.argv[0]
- print
- print 'Supported commands:'
+ print ('Usage: %s <file> <cmd> [<arg>, ...]' % sys.argv[0])
+ print ('Supported commands:')
for cmd in sorted(x for x in globals() if x.startswith('cmd_')):
- print globals()[cmd].__doc__
+ print (globals()[cmd].__doc__)
sys.exit(1)
def main():
if len(sys.argv) < 3:
usage()
- filename, cmd = sys.argv[1:3]
+ filename, cmd = sys.argv[1:3] #pylint: disable=unbalanced-tuple-unpacking
cmd = 'cmd_' + cmd.replace('-', '_')
if cmd not in globals():