We can now write complex qtests with a high-level language (Python).
(partly copied from iotests::main)
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
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