summaryrefslogtreecommitdiffstats
path: root/tests/qemu-iotests/iotests.py
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2015-05-18 09:39:12 +0800
committerKevin Wolf <kwolf@redhat.com>2015-05-22 17:08:01 +0200
commitaa4f592a1dd9aea5f5c36f6ff4b22b5bd208162a (patch)
tree1838a06658cfa428e481df9b84a9304912cd7bcd /tests/qemu-iotests/iotests.py
parentb93bbf4ee9035ae077679482305d5beb38df4d7d (diff)
downloadhqemu-aa4f592a1dd9aea5f5c36f6ff4b22b5bd208162a.zip
hqemu-aa4f592a1dd9aea5f5c36f6ff4b22b5bd208162a.tar.gz
qemu-iotests: Make debugging python tests easier
Adding "-d" option. The output goes to "tee" so it appears in your console. Also, raise the verbosity of unnitest runner. When testing a topic branch, it's possible that a bug introduced by a code change makes the python test case hang, with debug output, it is much easier to locate the problem. This can also be helpful if you want to watch the progress of a python test, it offers you a way to sense the speed of each test case method you're writing. Note: because there is no easy way to get *both* the verbose output and the output expected by ./check comparison, the case would always fail with an "output mismatch". The sole purpose of using this option is giving developers a quick way to debug when things go wrong. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/iotests.py')
-rw-r--r--tests/qemu-iotests/iotests.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index e93e623..04a294d 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -338,6 +338,8 @@ def notrun(reason):
def main(supported_fmts=[], supported_oses=['linux']):
'''Run tests'''
+ debug = '-d' in sys.argv
+ verbosity = 1
if supported_fmts and (imgfmt not in supported_fmts):
notrun('not suitable for this image format: %s' % imgfmt)
@@ -347,14 +349,20 @@ def main(supported_fmts=[], supported_oses=['linux']):
# We need to filter out the time taken from the output so that qemu-iotest
# can reliably diff the results against master output.
import StringIO
- output = StringIO.StringIO()
+ if debug:
+ output = sys.stdout
+ verbosity = 2
+ sys.argv.remove('-d')
+ else:
+ output = StringIO.StringIO()
class MyTestRunner(unittest.TextTestRunner):
- def __init__(self, stream=output, descriptions=True, verbosity=1):
+ def __init__(self, stream=output, descriptions=True, verbosity=verbosity):
unittest.TextTestRunner.__init__(self, stream, descriptions, verbosity)
# unittest.main() will use sys.exit() so expect a SystemExit exception
try:
unittest.main(testRunner=MyTestRunner)
finally:
- sys.stderr.write(re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', output.getvalue()))
+ if not debug:
+ sys.stderr.write(re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', output.getvalue()))
OpenPOWER on IntegriCloud