summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorYeoh Ee Peng <ee.peng.yeoh@intel.com>2018-10-18 17:11:05 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-18 23:26:35 +0100
commit2ddacd7106b803fe639d5ae821f8f191f3fcbc91 (patch)
tree4b3497f4921f70e4b1560939dd3e3834f1c10ad2 /meta
parent07fab73745eed8ce9dd0790d77f58ac98be49cec (diff)
downloadpoky-2ddacd7106b803fe639d5ae821f8f191f3fcbc91.tar.gz
oeqa/core/runner: refactor for OEQA to write json testresult
Refactor the original _getDetailsNotPassed method to return testresult details (test status and log), which will be reused by future OEQA code to write json testresult. Take the opportunity to consolidate and simplify the logic used to gather test status and log within the TestResult instance. (From OE-Core rev: 79ee7d1c371a86edeb61c99679985118da657e5d) Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/core/runner.py70
1 files changed, 29 insertions, 41 deletions
diff --git a/meta/lib/oeqa/core/runner.py b/meta/lib/oeqa/core/runner.py
index eeb625b7ff..f1dd08014c 100644
--- a/meta/lib/oeqa/core/runner.py
+++ b/meta/lib/oeqa/core/runner.py
@@ -76,40 +76,43 @@ class OETestResult(_TestResult):
76 else: 76 else:
77 msg = "%s - FAIL - Required tests failed" % component 77 msg = "%s - FAIL - Required tests failed" % component
78 skipped = len(self.skipped) 78 skipped = len(self.skipped)
79 if skipped: 79 if skipped:
80 msg += " (skipped=%d)" % skipped 80 msg += " (skipped=%d)" % skipped
81 self.tc.logger.info(msg) 81 self.tc.logger.info(msg)
82 82
83 def _getDetailsNotPassed(self, case, type, desc): 83 def _getTestResultDetails(self, case):
84 found = False 84 result_types = {'failures': 'FAILED', 'errors': 'ERROR', 'skipped': 'SKIPPED',
85 'expectedFailures': 'EXPECTEDFAIL', 'successes': 'PASSED'}
85 86
86 for (scase, msg) in getattr(self, type): 87 for rtype in result_types:
87 if case.id() == scase.id(): 88 found = False
88 found = True 89 for (scase, msg) in getattr(self, rtype):
89 break 90 if case.id() == scase.id():
90 scase_str = str(scase.id())
91
92 # When fails at module or class level the class name is passed as string
93 # so figure out to see if match
94 m = re.search("^setUpModule \((?P<module_name>.*)\)$", scase_str)
95 if m:
96 if case.__class__.__module__ == m.group('module_name'):
97 found = True 91 found = True
98 break 92 break
93 scase_str = str(scase.id())
99 94
100 m = re.search("^setUpClass \((?P<class_name>.*)\)$", scase_str) 95 # When fails at module or class level the class name is passed as string
101 if m: 96 # so figure out to see if match
102 class_name = "%s.%s" % (case.__class__.__module__, 97 m = re.search("^setUpModule \((?P<module_name>.*)\)$", scase_str)
103 case.__class__.__name__) 98 if m:
99 if case.__class__.__module__ == m.group('module_name'):
100 found = True
101 break
104 102
105 if class_name == m.group('class_name'): 103 m = re.search("^setUpClass \((?P<class_name>.*)\)$", scase_str)
106 found = True 104 if m:
107 break 105 class_name = "%s.%s" % (case.__class__.__module__,
106 case.__class__.__name__)
107
108 if class_name == m.group('class_name'):
109 found = True
110 break
108 111
109 if found: 112 if found:
110 return (found, msg) 113 return result_types[rtype], msg
111 114
112 return (found, None) 115 return 'UNKNOWN', None
113 116
114 def addSuccess(self, test): 117 def addSuccess(self, test):
115 #Added so we can keep track of successes too 118 #Added so we can keep track of successes too
@@ -121,17 +124,7 @@ class OETestResult(_TestResult):
121 for case_name in self.tc._registry['cases']: 124 for case_name in self.tc._registry['cases']:
122 case = self.tc._registry['cases'][case_name] 125 case = self.tc._registry['cases'][case_name]
123 126
124 result_types = ['failures', 'errors', 'skipped', 'expectedFailures', 'successes'] 127 (status, log) = self._getTestResultDetails(case)
125 result_desc = ['FAILED', 'ERROR', 'SKIPPED', 'EXPECTEDFAIL', 'PASSED']
126
127 fail = False
128 desc = None
129 for idx, name in enumerate(result_types):
130 (fail, msg) = self._getDetailsNotPassed(case, result_types[idx],
131 result_desc[idx])
132 if fail:
133 desc = result_desc[idx]
134 break
135 128
136 oeid = -1 129 oeid = -1
137 if hasattr(case, 'decorators'): 130 if hasattr(case, 'decorators'):
@@ -143,12 +136,7 @@ class OETestResult(_TestResult):
143 if case.id() in self.starttime and case.id() in self.endtime: 136 if case.id() in self.starttime and case.id() in self.endtime:
144 t = " (" + "{0:.2f}".format(self.endtime[case.id()] - self.starttime[case.id()]) + "s)" 137 t = " (" + "{0:.2f}".format(self.endtime[case.id()] - self.starttime[case.id()]) + "s)"
145 138
146 if fail: 139 self.tc.logger.info("RESULTS - %s - Testcase %s: %s%s" % (case.id(), oeid, status, t))
147 self.tc.logger.info("RESULTS - %s - Testcase %s: %s%s" % (case.id(),
148 oeid, desc, t))
149 else:
150 self.tc.logger.info("RESULTS - %s - Testcase %s: %s%s" % (case.id(),
151 oeid, 'UNKNOWN', t))
152 140
153class OEListTestsResult(object): 141class OEListTestsResult(object):
154 def wasSuccessful(self): 142 def wasSuccessful(self):