summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Esquivel <benjamin.esquivel@linux.intel.com>2016-07-21 12:02:05 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-01 11:47:10 +0100
commite91d0d5d1c7e28c5b1272df2b749d92279183d8a (patch)
treee2461e9a037376c93dd0d66d59395539041bdeca
parentcc3c276852a0eda15367df7dcae8b1889c2dca8e (diff)
downloadpoky-e91d0d5d1c7e28c5b1272df2b749d92279183d8a.tar.gz
oe-selftest: export test results via xmlrunner
if available, use the xmlrunner for exporting the test results to a dir named the same than the log where the text results are stored. this means creating a dir with the name of the log (without the .log) and dumping there the xml files that indicate the results of each of the tests. if xmlrunner is not available then it will behave the same as before, no xml exports. [YOCTO#9682] (From OE-Core rev: d51f9dd34d759c77b9e7050405cbb6a88a578f73) Signed-off-by: Benjamin Esquivel <benjamin.esquivel@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/oe-selftest33
1 files changed, 30 insertions, 3 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index 303b1d52ea..3188a410cb 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -48,8 +48,19 @@ import oeqa.utils.ftools as ftools
48from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer 48from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer
49from oeqa.selftest.base import oeSelfTest, get_available_machines 49from oeqa.selftest.base import oeSelfTest, get_available_machines
50 50
51try:
52 import xmlrunner
53 from xmlrunner.result import _XMLTestResult as TestResult
54 from xmlrunner import XMLTestRunner as _TestRunner
55except ImportError:
56 # use the base runner instead
57 from unittest import TextTestResult as TestResult
58 from unittest import TextTestRunner as _TestRunner
59
60log_prefix = "oe-selftest-" + t.strftime("%Y-%m-%d_%H:%M:%S")
61
51def logger_create(): 62def logger_create():
52 log_file = "oe-selftest-" + t.strftime("%Y-%m-%d_%H:%M:%S") + ".log" 63 log_file = log_prefix + ".log"
53 if os.path.exists("oe-selftest.log"): os.remove("oe-selftest.log") 64 if os.path.exists("oe-selftest.log"): os.remove("oe-selftest.log")
54 os.symlink(log_file, "oe-selftest.log") 65 os.symlink(log_file, "oe-selftest.log")
55 66
@@ -520,7 +531,8 @@ def main():
520 suite = unittest.TestSuite() 531 suite = unittest.TestSuite()
521 loader = unittest.TestLoader() 532 loader = unittest.TestLoader()
522 loader.sortTestMethodsUsing = None 533 loader.sortTestMethodsUsing = None
523 runner = unittest.TextTestRunner(verbosity=2, resultclass=buildResultClass(args)) 534 runner = TestRunner(verbosity=2,
535 resultclass=buildResultClass(args))
524 # we need to do this here, otherwise just loading the tests 536 # we need to do this here, otherwise just loading the tests
525 # will take 2 minutes (bitbake -e calls) 537 # will take 2 minutes (bitbake -e calls)
526 oeSelfTest.testlayer_path = get_test_layer() 538 oeSelfTest.testlayer_path = get_test_layer()
@@ -561,7 +573,7 @@ def buildResultClass(args):
561 """Build a Result Class to use in the testcase execution""" 573 """Build a Result Class to use in the testcase execution"""
562 import site 574 import site
563 575
564 class StampedResult(unittest.TextTestResult): 576 class StampedResult(TestResult):
565 """ 577 """
566 Custom TestResult that prints the time when a test starts. As oe-selftest 578 Custom TestResult that prints the time when a test starts. As oe-selftest
567 can take a long time (ie a few hours) to run, timestamps help us understand 579 can take a long time (ie a few hours) to run, timestamps help us understand
@@ -631,6 +643,21 @@ def buildResultClass(args):
631 643
632 return StampedResult 644 return StampedResult
633 645
646class TestRunner(_TestRunner):
647 """Test runner class aware of exporting tests."""
648 def __init__(self, *args, **kwargs):
649 try:
650 exportdir = os.path.join(os.getcwd(), log_prefix)
651 kwargsx = dict(**kwargs)
652 # argument specific to XMLTestRunner, if adding a new runner then
653 # also add logic to use other runner's args.
654 kwargsx['output'] = exportdir
655 kwargsx['descriptions'] = False
656 # done for the case where telling the runner where to export
657 super(TestRunner, self).__init__(*args, **kwargsx)
658 except TypeError:
659 log.info("test runner init'ed like unittest")
660 super(TestRunner, self).__init__(*args, **kwargs)
634 661
635if __name__ == "__main__": 662if __name__ == "__main__":
636 try: 663 try: