summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/testimage.bbclass4
-rw-r--r--meta/classes/testsdk.bbclass8
-rw-r--r--meta/lib/oeqa/core/context.py93
-rw-r--r--meta/lib/oeqa/core/runner.py88
4 files changed, 97 insertions, 96 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index fb214604a9..d42907cf80 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -292,8 +292,8 @@ def testimage_main(d):
# Show results (if we have them)
if not results:
bb.fatal('%s - FAILED - tests were interrupted during execution' % pn)
- tc.logSummary(results, pn)
- tc.logDetails()
+ results.logSummary(pn)
+ results.logDetails()
if not results.wasSuccessful():
bb.fatal('%s - FAILED - check the task log and the ssh log' % pn)
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
index 4740233910..edea89cbf4 100644
--- a/meta/classes/testsdk.bbclass
+++ b/meta/classes/testsdk.bbclass
@@ -70,8 +70,8 @@ def testsdk_main(d):
component = "%s %s" % (pn, OESDKTestContextExecutor.name)
context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
- tc.logSummary(result, component, context_msg)
- tc.logDetails()
+ result.logSummary(component, context_msg)
+ result.logDetails()
if not result.wasSuccessful():
fail = True
@@ -172,8 +172,8 @@ def testsdkext_main(d):
component = "%s %s" % (pn, OESDKExtTestContextExecutor.name)
context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
- tc.logSummary(result, component, context_msg)
- tc.logDetails()
+ result.logSummary(component, context_msg)
+ result.logDetails()
if not result.wasSuccessful():
fail = True
diff --git a/meta/lib/oeqa/core/context.py b/meta/lib/oeqa/core/context.py
index 2628651fa3..54958add07 100644
--- a/meta/lib/oeqa/core/context.py
+++ b/meta/lib/oeqa/core/context.py
@@ -7,10 +7,9 @@ import json
import time
import logging
import collections
-import re
from oeqa.core.loader import OETestLoader
-from oeqa.core.runner import OETestRunner, xmlEnabled
+from oeqa.core.runner import OETestRunner
class OETestContext(object):
loaderClass = OETestLoader
@@ -59,92 +58,6 @@ class OETestContext(object):
return result
- def logSummary(self, result, component, context_msg=''):
- self.logger.info("SUMMARY:")
- self.logger.info("%s (%s) - Ran %d test%s in %.3fs" % (component,
- context_msg, result.testsRun, result.testsRun != 1 and "s" or "",
- (self._run_end_time - self._run_start_time)))
-
- if result.wasSuccessful():
- msg = "%s - OK - All required tests passed" % component
- else:
- msg = "%s - FAIL - Required tests failed" % component
- skipped = len(self._results['skipped'])
- if skipped:
- msg += " (skipped=%d)" % skipped
- self.logger.info(msg)
-
- def _getDetailsNotPassed(self, case, type, desc):
- found = False
-
- for (scase, msg) in self._results[type]:
- # XXX: When XML reporting is enabled scase is
- # xmlrunner.result._TestInfo instance instead of
- # string.
- if xmlEnabled:
- if case.id() == scase.test_id:
- found = True
- break
- scase_str = scase.test_id
- else:
- if case == scase:
- found = True
- break
- scase_str = str(scase)
-
- # When fails at module or class level the class name is passed as string
- # so figure out to see if match
- m = re.search("^setUpModule \((?P<module_name>.*)\)$", scase_str)
- if m:
- if case.__class__.__module__ == m.group('module_name'):
- found = True
- break
-
- m = re.search("^setUpClass \((?P<class_name>.*)\)$", scase_str)
- if m:
- class_name = "%s.%s" % (case.__class__.__module__,
- case.__class__.__name__)
-
- if class_name == m.group('class_name'):
- found = True
- break
-
- if found:
- return (found, msg)
-
- return (found, None)
-
- def logDetails(self):
- self.logger.info("RESULTS:")
- for case_name in self._registry['cases']:
- case = self._registry['cases'][case_name]
-
- result_types = ['failures', 'errors', 'skipped', 'expectedFailures']
- result_desc = ['FAILED', 'ERROR', 'SKIPPED', 'EXPECTEDFAIL']
-
- fail = False
- desc = None
- for idx, name in enumerate(result_types):
- (fail, msg) = self._getDetailsNotPassed(case, result_types[idx],
- result_desc[idx])
- if fail:
- desc = result_desc[idx]
- break
-
- oeid = -1
- for d in case.decorators:
- if hasattr(d, 'oeid'):
- oeid = d.oeid
-
- if fail:
- self.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(),
- oeid, desc))
- if msg:
- self.logger.info(msg)
- else:
- self.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(),
- oeid, 'PASSED'))
-
class OETestContextExecutor(object):
_context_class = OETestContext
@@ -227,8 +140,8 @@ class OETestContextExecutor(object):
self.tc = self._context_class(**self.tc_kwargs['init'])
self.tc.loadTests(self.module_paths, **self.tc_kwargs['load'])
rc = self.tc.runTests(**self.tc_kwargs['run'])
- self.tc.logSummary(rc, self.name)
- self.tc.logDetails()
+ rc.logSummary(self.name)
+ rc.logDetails()
output_link = os.path.join(os.path.dirname(args.output_log),
"%s-results.log" % self.name)
diff --git a/meta/lib/oeqa/core/runner.py b/meta/lib/oeqa/core/runner.py
index 0b04e8d586..75058384ae 100644
--- a/meta/lib/oeqa/core/runner.py
+++ b/meta/lib/oeqa/core/runner.py
@@ -5,6 +5,7 @@ import os
import time
import unittest
import logging
+import re
xmlEnabled = False
try:
@@ -44,6 +45,93 @@ class OETestResult(_TestResult):
self.tc._results['skipped'] = self.skipped
self.tc._results['expectedFailures'] = self.expectedFailures
+ def logSummary(self, component, context_msg=''):
+ elapsed_time = self.tc._run_end_time - self.tc._run_start_time
+ self.tc.logger.info("SUMMARY:")
+ self.tc.logger.info("%s (%s) - Ran %d test%s in %.3fs" % (component,
+ context_msg, self.testsRun, self.testsRun != 1 and "s" or "",
+ elapsed_time))
+
+ if self.wasSuccessful():
+ msg = "%s - OK - All required tests passed" % component
+ else:
+ msg = "%s - FAIL - Required tests failed" % component
+ skipped = len(self.tc._results['skipped'])
+ if skipped:
+ msg += " (skipped=%d)" % skipped
+ self.tc.logger.info(msg)
+
+ def _getDetailsNotPassed(self, case, type, desc):
+ found = False
+
+ for (scase, msg) in self.tc._results[type]:
+ # XXX: When XML reporting is enabled scase is
+ # xmlrunner.result._TestInfo instance instead of
+ # string.
+ if xmlEnabled:
+ if case.id() == scase.test_id:
+ found = True
+ break
+ scase_str = scase.test_id
+ else:
+ if case == scase:
+ found = True
+ break
+ scase_str = str(scase)
+
+ # When fails at module or class level the class name is passed as string
+ # so figure out to see if match
+ m = re.search("^setUpModule \((?P<module_name>.*)\)$", scase_str)
+ if m:
+ if case.__class__.__module__ == m.group('module_name'):
+ found = True
+ break
+
+ m = re.search("^setUpClass \((?P<class_name>.*)\)$", scase_str)
+ if m:
+ class_name = "%s.%s" % (case.__class__.__module__,
+ case.__class__.__name__)
+
+ if class_name == m.group('class_name'):
+ found = True
+ break
+
+ if found:
+ return (found, msg)
+
+ return (found, None)
+
+ def logDetails(self):
+ self.tc.logger.info("RESULTS:")
+ for case_name in self.tc._registry['cases']:
+ case = self.tc._registry['cases'][case_name]
+
+ result_types = ['failures', 'errors', 'skipped', 'expectedFailures']
+ result_desc = ['FAILED', 'ERROR', 'SKIPPED', 'EXPECTEDFAIL']
+
+ fail = False
+ desc = None
+ for idx, name in enumerate(result_types):
+ (fail, msg) = self._getDetailsNotPassed(case, result_types[idx],
+ result_desc[idx])
+ if fail:
+ desc = result_desc[idx]
+ break
+
+ oeid = -1
+ for d in case.decorators:
+ if hasattr(d, 'oeid'):
+ oeid = d.oeid
+
+ if fail:
+ self.tc.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(),
+ oeid, desc))
+ if msg:
+ self.tc.logger.info(msg)
+ else:
+ self.tc.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(),
+ oeid, 'PASSED'))
+
class OETestRunner(_TestRunner):
streamLoggerClass = OEStreamLogger