aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3/run-ptest
diff options
context:
space:
mode:
authorPaul Barker <paul@paulbarker.me.uk>2014-03-01 13:49:39 +0000
committerPaul Barker <paul@paulbarker.me.uk>2014-11-24 11:50:37 +0000
commit49194f148c7b74b7d567659a4525a6de3dd43884 (patch)
tree570785fbfeee0f9471ca362e1c2c58c15662c796 /meta/recipes-devtools/python/python3/run-ptest
parent323b2d27598df8fe18892559e093ae7281e99918 (diff)
downloadopenembedded-core-contrib-49194f148c7b74b7d567659a4525a6de3dd43884.tar.gz
openembedded-core-contrib-49194f148c7b74b7d567659a4525a6de3dd43884.tar.bz2
openembedded-core-contrib-49194f148c7b74b7d567659a4525a6de3dd43884.zip
python3: Add ptest supportpbarker/python3-ptest
A run-ptest script written in python is added which defines a new TestRunner subclass which prints test results in the required ptest format and then executes python's built-in testsuite using this new TestRunner subclass. The built-in testsuite is included in the python standard library and we ensure we have the complete library by adding ${PN}-modules and ${PN}-misc to the RDEPENDS for the ptest package. We also require libgcc for pthread support. Tested on qemux86. Several tests fail and many skip; further investigation should be done to check that the current status is acceptable. In addition, the testsuite causes an out-of-memory crash when qemu is configured with 256 MB of RAM. The testsuite completes without crashing with 1 GB RAM. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
Diffstat (limited to 'meta/recipes-devtools/python/python3/run-ptest')
-rw-r--r--meta/recipes-devtools/python/python3/run-ptest56
1 files changed, 56 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3/run-ptest b/meta/recipes-devtools/python/python3/run-ptest
new file mode 100644
index 0000000000..bd3ea1107c
--- /dev/null
+++ b/meta/recipes-devtools/python/python3/run-ptest
@@ -0,0 +1,56 @@
+#! /usr/bin/env python3
+
+from test import support
+from test import regrtest
+import unittest
+import sys
+
+# Define a test result class which outputs results in the desired format.
+class ptestResult(unittest.TestResult):
+ def __init__(self, runner):
+ super(ptestResult, self).__init__()
+ self.runner = runner
+
+ def addError(self, test, err):
+ super(ptestResult, self).addError(test, err)
+ self.runner.write("ERROR: %s: %s\n" % (str(test), str(err[1])))
+
+ def addSuccess(self, test):
+ super(ptestResult, self).addSuccess(test)
+ self.runner.write("PASS: %s\n" % str(test))
+
+ def addFailure(self, test, err):
+ super(ptestResult, self).addFailure(test, err)
+ self.runner.write("FAIL: %s: %s\n" % (str(test), str(err[1])))
+
+ def addSkip(self, test, reason):
+ super(ptestResult, self).addSkip(test, reason)
+ self.runner.write("SKIP: %s: %s\n" % (str(test), str(reason)))
+
+ def addExpectedFailure(self, test, err):
+ super(ptestResult, self).addExpectedFailure(test, err)
+ self.runner.write("XFAIL: %s\n" % (str(test)))
+
+ def addUnexpectedSuccess(self, test):
+ super(ptestResult, self).addUnexpectedSuccess(test)
+ self.runner.write("XPASS: %s\n" % str(test))
+
+# Define a test runner which uses the above output class.
+class ptestRunner:
+ def __init__(self, stream=sys.stderr):
+ self.stream = stream
+
+ def write(self, message):
+ self.stream.write(message)
+
+ def run(self, test):
+ result = ptestResult(self)
+ test(result)
+ return result
+
+# Replace the test runner in python's standard library 'test.support'.
+support.BasicTestRunner = ptestRunner
+
+# Run the python regression test suite - the replacement test runner will be
+# used.
+regrtest.main()