qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/3] iotests: Enable -d for Python non-unittest test


From: Kevin Wolf
Subject: [Qemu-devel] [PATCH 2/3] iotests: Enable -d for Python non-unittest tests
Date: Thu, 1 Aug 2019 17:17:43 +0200

The part of iotests.main() that is related to the implementation of the
debug option -d and enables QEMU and QMP logging is not only useful in
tests that use the Python unittest framework, but also in tests that
work by comparing with a reference output.

Factor these parts out into iotests.init() and call it from the test
cases that currently lack support for debug output.

Signed-off-by: Kevin Wolf <address@hidden>
---
 tests/qemu-iotests/194        |  1 +
 tests/qemu-iotests/202        |  1 +
 tests/qemu-iotests/203        |  2 ++
 tests/qemu-iotests/206        |  1 +
 tests/qemu-iotests/207        |  1 +
 tests/qemu-iotests/208        |  1 +
 tests/qemu-iotests/210        |  1 +
 tests/qemu-iotests/211        |  1 +
 tests/qemu-iotests/212        |  1 +
 tests/qemu-iotests/213        |  1 +
 tests/qemu-iotests/216        |  2 ++
 tests/qemu-iotests/218        |  1 +
 tests/qemu-iotests/219        |  1 +
 tests/qemu-iotests/222        |  1 +
 tests/qemu-iotests/224        |  2 ++
 tests/qemu-iotests/228        |  2 ++
 tests/qemu-iotests/234        |  2 ++
 tests/qemu-iotests/236        |  1 +
 tests/qemu-iotests/237        |  1 +
 tests/qemu-iotests/246        |  1 +
 tests/qemu-iotests/255        |  1 +
 tests/qemu-iotests/256        |  1 +
 tests/qemu-iotests/iotests.py | 23 +++++++++++++++--------
 23 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194
index d746ab1e21..cd6928fbd9 100755
--- a/tests/qemu-iotests/194
+++ b/tests/qemu-iotests/194
@@ -21,6 +21,7 @@
 
 import iotests
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2', 'qed', 'raw'])
 iotests.verify_platform(['linux'])
 
diff --git a/tests/qemu-iotests/202 b/tests/qemu-iotests/202
index 581ca34d79..86a3b94586 100755
--- a/tests/qemu-iotests/202
+++ b/tests/qemu-iotests/202
@@ -24,6 +24,7 @@
 
 import iotests
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 iotests.verify_platform(['linux'])
 
diff --git a/tests/qemu-iotests/203 b/tests/qemu-iotests/203
index 4874a1a0d8..fe25c249fb 100755
--- a/tests/qemu-iotests/203
+++ b/tests/qemu-iotests/203
@@ -27,6 +27,8 @@ import iotests
 iotests.verify_image_format(supported_fmts=['qcow2'])
 iotests.verify_platform(['linux'])
 
+iotests.init()
+
 with iotests.FilePath('disk0.img') as disk0_img_path, \
      iotests.FilePath('disk1.img') as disk1_img_path, \
      iotests.VM() as vm:
diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
index 5bb738bf23..481e4b98ea 100755
--- a/tests/qemu-iotests/206
+++ b/tests/qemu-iotests/206
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 
 def blockdev_create(vm, options):
diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207
index ec8c1d06f0..57c1e900d2 100755
--- a/tests/qemu-iotests/207
+++ b/tests/qemu-iotests/207
@@ -24,6 +24,7 @@ import iotests
 import subprocess
 import re
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['raw'])
 iotests.verify_protocol(supported=['ssh'])
 
diff --git a/tests/qemu-iotests/208 b/tests/qemu-iotests/208
index 1e202388dc..3b2c732cd4 100755
--- a/tests/qemu-iotests/208
+++ b/tests/qemu-iotests/208
@@ -22,6 +22,7 @@
 
 import iotests
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['generic'])
 
 with iotests.FilePath('disk.img') as disk_img_path, \
diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210
index 565e3b7b9b..a90db1c067 100755
--- a/tests/qemu-iotests/210
+++ b/tests/qemu-iotests/210
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['luks'])
 iotests.verify_protocol(supported=['file'])
 
diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211
index 6afc894f76..e6a0bef332 100755
--- a/tests/qemu-iotests/211
+++ b/tests/qemu-iotests/211
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['vdi'])
 iotests.verify_protocol(supported=['file'])
 
diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212
index 42b74f208b..865674191c 100755
--- a/tests/qemu-iotests/212
+++ b/tests/qemu-iotests/212
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['parallels'])
 iotests.verify_protocol(supported=['file'])
 
diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213
index 5604f3cebb..8fb94147ff 100755
--- a/tests/qemu-iotests/213
+++ b/tests/qemu-iotests/213
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['vhdx'])
 iotests.verify_protocol(supported=['file'])
 
diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216
index 3c0ae54b44..adcb487fb4 100755
--- a/tests/qemu-iotests/216
+++ b/tests/qemu-iotests/216
@@ -22,6 +22,8 @@
 import iotests
 from iotests import log, qemu_img, qemu_io_silent
 
+iotests.init()
+
 # Need backing file support
 iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'])
 iotests.verify_platform(['linux'])
diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218
index 2554d84581..18639020ee 100755
--- a/tests/qemu-iotests/218
+++ b/tests/qemu-iotests/218
@@ -29,6 +29,7 @@
 import iotests
 from iotests import log, qemu_img, qemu_io_silent
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2', 'raw'])
 
 
diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219
index e0c51662c0..c7265d12c5 100755
--- a/tests/qemu-iotests/219
+++ b/tests/qemu-iotests/219
@@ -21,6 +21,7 @@
 
 import iotests
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 
 img_size = 4 * 1024 * 1024
diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222
index 0ead56d574..bb2b8cc78a 100644
--- a/tests/qemu-iotests/222
+++ b/tests/qemu-iotests/222
@@ -24,6 +24,7 @@
 import iotests
 from iotests import log, qemu_img, qemu_io, qemu_io_silent
 
+iotests.init()
 iotests.verify_platform(['linux'])
 iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk',
                                             'vhdx', 'raw'])
diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224
index b4dfaa639f..00013473a8 100755
--- a/tests/qemu-iotests/224
+++ b/tests/qemu-iotests/224
@@ -25,6 +25,8 @@ from iotests import log, qemu_img, qemu_io_silent, 
filter_qmp_testfiles, \
                     filter_qmp_imgfmt
 import json
 
+iotests.init()
+
 # Need backing file support (for arbitrary backing formats)
 iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed'])
 iotests.verify_platform(['linux'])
diff --git a/tests/qemu-iotests/228 b/tests/qemu-iotests/228
index 9a50afd205..9b9acf8be5 100755
--- a/tests/qemu-iotests/228
+++ b/tests/qemu-iotests/228
@@ -24,6 +24,8 @@ import iotests
 from iotests import log, qemu_img, filter_testfiles, filter_imgfmt, \
         filter_qmp_testfiles, filter_qmp_imgfmt
 
+iotests.init()
+
 # Need backing file and change-backing-file support
 iotests.verify_image_format(supported_fmts=['qcow2', 'qed'])
 iotests.verify_platform(['linux'])
diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234
index 34c818c485..17c03d2f6a 100755
--- a/tests/qemu-iotests/234
+++ b/tests/qemu-iotests/234
@@ -26,6 +26,8 @@ import os
 iotests.verify_image_format(supported_fmts=['qcow2'])
 iotests.verify_platform(['linux'])
 
+iotests.init()
+
 with iotests.FilePath('img') as img_path, \
      iotests.FilePath('backing') as backing_path, \
      iotests.FilePath('mig_fifo_a') as fifo_a, \
diff --git a/tests/qemu-iotests/236 b/tests/qemu-iotests/236
index 79a6381f8e..15ef48f0b6 100755
--- a/tests/qemu-iotests/236
+++ b/tests/qemu-iotests/236
@@ -22,6 +22,7 @@
 import iotests
 from iotests import log
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['generic'])
 size = 64 * 1024 * 1024
 granularity = 64 * 1024
diff --git a/tests/qemu-iotests/237 b/tests/qemu-iotests/237
index 06897f8c87..cbaaeed9eb 100755
--- a/tests/qemu-iotests/237
+++ b/tests/qemu-iotests/237
@@ -24,6 +24,7 @@ import math
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['vmdk'])
 
 def blockdev_create(vm, options):
diff --git a/tests/qemu-iotests/246 b/tests/qemu-iotests/246
index b0997a392f..7f6da5dced 100755
--- a/tests/qemu-iotests/246
+++ b/tests/qemu-iotests/246
@@ -22,6 +22,7 @@
 import iotests
 from iotests import log
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 size = 64 * 1024 * 1024 * 1024
 gran_small = 32 * 1024
diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255
index 3632d507d0..099617ab59 100755
--- a/tests/qemu-iotests/255
+++ b/tests/qemu-iotests/255
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 
 def blockdev_create(vm, options):
diff --git a/tests/qemu-iotests/256 b/tests/qemu-iotests/256
index c594a43205..e15f1b1a8a 100755
--- a/tests/qemu-iotests/256
+++ b/tests/qemu-iotests/256
@@ -23,6 +23,7 @@ import os
 import iotests
 from iotests import log
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 size = 64 * 1024 * 1024
 
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 91172c39a5..f2ad2b9749 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -858,10 +858,7 @@ def skip_if_unsupported(required_formats=[], 
read_only=False):
         return func_wrapper
     return skip_test_decorator
 
-def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
-         unsupported_fmts=[]):
-    '''Run tests'''
-
+def init():
     global debug
 
     # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to
@@ -873,7 +870,19 @@ def main(supported_fmts=[], supported_oses=['linux'], 
supported_cache_modes=[],
         sys.exit(os.EX_USAGE)
 
     debug = '-d' in sys.argv
-    verbosity = 1
+    if debug:
+        sys.argv.remove('-d')
+
+    logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
+
+def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
+         unsupported_fmts=[]):
+    '''Run tests'''
+
+    global debug
+
+    init()
+
     verify_image_format(supported_fmts, unsupported_fmts)
     verify_platform(supported_oses)
     verify_cache_mode(supported_cache_modes)
@@ -881,8 +890,8 @@ def main(supported_fmts=[], supported_oses=['linux'], 
supported_cache_modes=[],
     if debug:
         output = sys.stdout
         verbosity = 2
-        sys.argv.remove('-d')
     else:
+        verbosity = 1
         # We need to filter out the time taken from the output so that
         # qemu-iotest can reliably diff the results against master output.
         if sys.version_info.major >= 3:
@@ -892,8 +901,6 @@ def main(supported_fmts=[], supported_oses=['linux'], 
supported_cache_modes=[],
             # 2.x's test runner emits.
             output = io.BytesIO()
 
-    logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
-
     class MyTestRunner(unittest.TextTestRunner):
         def __init__(self, stream=output, descriptions=True, 
verbosity=verbosity):
             unittest.TextTestRunner.__init__(self, stream, descriptions, 
verbosity)
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]