[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/6] qtest.py: add a simple main() which calls unitt
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-devel] [PATCH 5/6] qtest.py: add a simple main() which calls unittest.main() |
Date: |
Wed, 13 Dec 2017 18:35:56 -0300 |
We can now write complex qtests with a high-level language (Python).
(partly copied from iotests::main)
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
scripts/qtest.py | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/scripts/qtest.py b/scripts/qtest.py
index 429eb67c2a..581451836c 100644
--- a/scripts/qtest.py
+++ b/scripts/qtest.py
@@ -226,3 +226,36 @@ def verify_machine(supported_machines):
if True not in [x in machines for x in supported_machines]:
notrun('not machine suitable for this test')
+
+def main(supported_oses=['linux'], supported_machines=['any']):
+ '''Run tests'''
+
+ global debug
+
+ verify_platform(supported_oses)
+ verify_machine(supported_machines)
+
+ verbosity = 0
+ level = logging.WARN
+ if '-d' in sys.argv:
+ verbosity = 2
+ level = logging.DEBUG
+ if '-v' in sys.argv:
+ verbosity = 1
+ level = logging.INFO
+ if '-q' in sys.argv:
+ level = logging.NOTSET
+
+ import StringIO
+ output = sys.stdout if verbosity else StringIO.StringIO()
+
+ logging.basicConfig(level=level)
+
+ class MyTestRunner(unittest.TextTestRunner):
+ 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
+ unittest.main(testRunner=MyTestRunner)
--
2.15.1
- [Qemu-devel] [PATCH 0/6] QTests: use Python to run complex tests, Philippe Mathieu-Daudé, 2017/12/13
- [Qemu-devel] [PATCH 1/6] iotests.py: split BlockQMPTestCase class of QMPTestCase, Philippe Mathieu-Daudé, 2017/12/13
- [Qemu-devel] [PATCH 2/6] iotests.py: move the generic QMPTestCase to qtest.py, Philippe Mathieu-Daudé, 2017/12/13
- [Qemu-devel] [PATCH 3/6] qtest.py: use TMPDIR/TEMP if the TEST_DIR env var is missing, Philippe Mathieu-Daudé, 2017/12/13
- [Qemu-devel] [PATCH 4/6] qtest.py: add verify_machine(supported_machines), Philippe Mathieu-Daudé, 2017/12/13
- [Qemu-devel] [PATCH 5/6] qtest.py: add a simple main() which calls unittest.main(),
Philippe Mathieu-Daudé <=
- [Qemu-devel] [PATCH 6/6] tests: add a Makefile rule to run Python qtests, Philippe Mathieu-Daudé, 2017/12/13
- Re: [Qemu-devel] [PATCH 0/6] QTests: use Python to run complex tests, Stefan Hajnoczi, 2017/12/14
- Re: [Qemu-devel] [PATCH 0/6] QTests: use Python to run complex tests, Paolo Bonzini, 2017/12/14
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/6] QTests: use Python to run complex tests, Nir Soffer, 2017/12/14
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/6] QTests: use Python to run complex tests, Philippe Mathieu-Daudé, 2017/12/14
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/6] QTests: use Python to run complex tests, Markus Armbruster, 2017/12/14
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/6] QTests: use Python to run complex tests, Paolo Bonzini, 2017/12/14
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/6] QTests: use Python to run complex tests, Peter Maydell, 2017/12/14
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/6] QTests: use Python to run complex tests, Paolo Bonzini, 2017/12/14
Re: [Qemu-devel] [PATCH 0/6] QTests: use Python to run complex tests, Philippe Mathieu-Daudé, 2017/12/14