summary refs log tree commit diff stats
path: root/tests/qemu-iotests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qemu-iotests')
-rwxr-xr-xtests/qemu-iotests/0932
-rwxr-xr-xtests/qemu-iotests/0964
-rwxr-xr-xtests/qemu-iotests/11824
-rwxr-xr-xtests/qemu-iotests/1362
-rwxr-xr-xtests/qemu-iotests/1493
-rwxr-xr-xtests/qemu-iotests/1653
-rw-r--r--tests/qemu-iotests/iotests.py5
-rwxr-xr-xtests/qemu-iotests/nbd-fault-injector.py7
-rwxr-xr-xtests/qemu-iotests/qcow2.py39
-rwxr-xr-xtests/qemu-iotests/qed.py17
10 files changed, 56 insertions, 50 deletions
diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
index c3404a3171..68e344f8c1 100755
--- a/tests/qemu-iotests/093
+++ b/tests/qemu-iotests/093
@@ -237,7 +237,7 @@ class ThrottleTestGroupNames(iotests.QMPTestCase):
                 if name:
                     self.assertEqual(info["group"], name)
                 else:
-                    self.assertFalse(info.has_key('group'))
+                    self.assertFalse('group' in info)
                 return
 
         raise Exception("No group information found for '%s'" % device)
diff --git a/tests/qemu-iotests/096 b/tests/qemu-iotests/096
index aeeb3753cf..a69439602d 100755
--- a/tests/qemu-iotests/096
+++ b/tests/qemu-iotests/096
@@ -53,9 +53,9 @@ class TestLiveSnapshot(iotests.QMPTestCase):
                 self.assertEqual(r['iops'], self.iops)
                 self.assertEqual(r['iops_size'], self.iops_size)
             else:
-                self.assertFalse(r.has_key('group'))
+                self.assertFalse('group' in r)
                 self.assertEqual(r['iops'], 0)
-                self.assertFalse(r.has_key('iops_size'))
+                self.assertFalse('iops_size' in r)
 
     def testSnapshot(self):
         self.checkConfig('base')
diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118
index a0469b570e..ff3b2ae3e7 100755
--- a/tests/qemu-iotests/118
+++ b/tests/qemu-iotests/118
@@ -390,14 +390,14 @@ class TestChangeReadOnly(ChangeBaseClass):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.chmod(old_img, 0666)
-        os.chmod(new_img, 0666)
+        os.chmod(old_img, 0o666)
+        os.chmod(new_img, 0o666)
         os.remove(old_img)
         os.remove(new_img)
 
     def test_ro_ro_retain(self):
-        os.chmod(old_img, 0444)
-        os.chmod(new_img, 0444)
+        os.chmod(old_img, 0o444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -417,7 +417,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_ro_rw_retain(self):
-        os.chmod(old_img, 0444)
+        os.chmod(old_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -437,7 +437,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_rw_ro_retain(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -459,7 +459,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
     def test_ro_rw(self):
-        os.chmod(old_img, 0444)
+        os.chmod(old_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -480,7 +480,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_rw_ro(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -521,7 +521,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_make_ro_rw(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -542,7 +542,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
     def test_make_rw_ro_by_retain(self):
-        os.chmod(old_img, 0444)
+        os.chmod(old_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -562,7 +562,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_make_ro_rw_by_retain(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -582,7 +582,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
     def test_rw_ro_cycle(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136
index 88b97ea7c6..a154d8ef9d 100755
--- a/tests/qemu-iotests/136
+++ b/tests/qemu-iotests/136
@@ -203,7 +203,7 @@ sector = "%d"
         if (self.accounted_ops(read = True, write = True, flush = True) != 0):
             self.assertLess(0, stats['idle_time_ns'])
         else:
-            self.assertFalse(stats.has_key('idle_time_ns'))
+            self.assertFalse('idle_time_ns' in stats)
 
         # This test does not alter these, so they must be all 0
         self.assertEqual(0, stats['rd_merged'])
diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
index 223cd68ad5..d3ffa259db 100755
--- a/tests/qemu-iotests/149
+++ b/tests/qemu-iotests/149
@@ -20,6 +20,7 @@
 # Exercise the QEMU 'luks' block driver to validate interoperability
 # with the Linux dm-crypt + cryptsetup implementation
 
+from __future__ import print_function
 import subprocess
 import os
 import os.path
@@ -376,7 +377,7 @@ def test_once(config, qemu_img=False):
     finally:
         iotests.log("# Delete image")
         delete_image(config)
-        print
+        print()
 
 
 # Obviously we only work with the luks image format
diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165
index 2936929627..88f62d3c6d 100755
--- a/tests/qemu-iotests/165
+++ b/tests/qemu-iotests/165
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import print_function
 import os
 import re
 import iotests
@@ -85,7 +86,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase):
         log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log)
         log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log)
         if log:
-            print log
+            print(log)
 
         self.vm = self.mkVm()
         self.vm.launch()
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 2f22fab2a7..4e67fbbe96 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
 # Common utilities and Python wrappers for qemu-iotests
 #
 # Copyright (C) 2012 IBM Corp.
@@ -248,7 +249,7 @@ def filter_img_info(output, filename):
 def log(msg, filters=[]):
     for flt in filters:
         msg = flt(msg)
-    print msg
+    print(msg)
 
 class Timeout:
     def __init__(self, seconds, errmsg = "Timeout"):
@@ -613,7 +614,7 @@ def notrun(reason):
     seq = os.path.basename(sys.argv[0])
 
     open('%s/%s.notrun' % (output_dir, seq), 'wb').write(reason + '\n')
-    print '%s not run: %s' % (seq, reason)
+    print('%s not run: %s' % (seq, reason))
     sys.exit(0)
 
 def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py
index 8a04d979aa..f9193c0fae 100755
--- a/tests/qemu-iotests/nbd-fault-injector.py
+++ b/tests/qemu-iotests/nbd-fault-injector.py
@@ -43,6 +43,7 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+from __future__ import print_function
 import sys
 import socket
 import struct
@@ -110,7 +111,7 @@ class FaultInjectionSocket(object):
         for rule in self.rules:
             if rule.match(event, io):
                 if rule.when == 0 or bufsize is None:
-                    print 'Closing connection on rule match %s' % rule.name
+                    print('Closing connection on rule match %s' % rule.name)
                     sys.exit(0)
                 if rule.when != -1:
                     return rule.when
@@ -182,7 +183,7 @@ def handle_connection(conn, use_export):
         elif req.type == NBD_CMD_DISC:
             break
         else:
-            print 'unrecognized command type %#02x' % req.type
+            print('unrecognized command type %#02x' % req.type)
             break
     conn.close()
 
@@ -242,7 +243,7 @@ def open_socket(path):
         sock = socket.socket(socket.AF_UNIX)
         sock.bind(path)
     sock.listen(0)
-    print 'Listening on %s' % path
+    print('Listening on %s' % path)
     sys.stdout.flush() # another process may be waiting, show message now
     return sock
 
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
index 9cc4cf7d08..b95a837759 100755
--- a/tests/qemu-iotests/qcow2.py
+++ b/tests/qemu-iotests/qcow2.py
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+from __future__ import print_function
 import sys
 import struct
 import string
@@ -129,8 +130,8 @@ 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]])
+        print("")
 
     def dump_extensions(self):
         for ex in self.extensions:
@@ -141,11 +142,11 @@ 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))
+            print("")
 
 
 def cmd_dump_header(fd):
@@ -157,12 +158,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)
@@ -173,7 +174,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)
@@ -188,7 +189,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)
@@ -200,7 +201,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)
@@ -211,7 +212,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)
@@ -222,7 +223,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)
@@ -248,16 +249,16 @@ 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("")
+    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 748068d7fe..ea469b9c48 100755
--- a/tests/qemu-iotests/qed.py
+++ b/tests/qemu-iotests/qed.py
@@ -10,6 +10,7 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+from __future__ import print_function
 import sys
 import struct
 import random
@@ -108,12 +109,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 +147,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,11 +209,11 @@ 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()
+    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():