summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/core/threaded.py73
1 files changed, 72 insertions, 1 deletions
diff --git a/meta/lib/oeqa/core/threaded.py b/meta/lib/oeqa/core/threaded.py
index 73b7f2fa64..f216685f46 100644
--- a/meta/lib/oeqa/core/threaded.py
+++ b/meta/lib/oeqa/core/threaded.py
@@ -7,7 +7,7 @@ import multiprocessing
7from unittest.suite import TestSuite 7from unittest.suite import TestSuite
8 8
9from oeqa.core.loader import OETestLoader 9from oeqa.core.loader import OETestLoader
10from oeqa.core.runner import OEStreamLogger 10from oeqa.core.runner import OEStreamLogger, OETestResult
11 11
12class OETestLoaderThreaded(OETestLoader): 12class OETestLoaderThreaded(OETestLoader):
13 def __init__(self, tc, module_paths, modules, tests, modules_required, 13 def __init__(self, tc, module_paths, modules, tests, modules_required,
@@ -114,3 +114,74 @@ class OEStreamLoggerThreaded(OEStreamLogger):
114 for line in self.buffers[tid].split('\n'): 114 for line in self.buffers[tid].split('\n'):
115 self.logger.info(line) 115 self.logger.info(line)
116 self._lock.release() 116 self._lock.release()
117
118class OETestResultThreadedInternal(OETestResult):
119 def _tc_map_results(self):
120 tid = threading.get_ident()
121
122 # PyUnit generates a result for every test module run, test
123 # if the thread already has an entry to avoid lose the previous
124 # test module results.
125 if not tid in self.tc._results:
126 self.tc._results[tid] = {}
127 self.tc._results[tid]['failures'] = self.failures
128 self.tc._results[tid]['errors'] = self.errors
129 self.tc._results[tid]['skipped'] = self.skipped
130 self.tc._results[tid]['expectedFailures'] = self.expectedFailures
131
132class OETestResultThreaded(object):
133 _results = {}
134 _lock = threading.Lock()
135
136 def __init__(self, tc):
137 self.tc = tc
138
139 def _fill_tc_results(self):
140 tids = list(self.tc._results.keys())
141 fields = ['failures', 'errors', 'skipped', 'expectedFailures']
142
143 for tid in tids:
144 result = self.tc._results[tid]
145 for field in fields:
146 if not field in self.tc._results:
147 self.tc._results[field] = []
148 self.tc._results[field].extend(result[field])
149
150 def addResult(self, result, run_start_time, run_end_time):
151 tid = threading.get_ident()
152
153 self._lock.acquire()
154 self._results[tid] = {}
155 self._results[tid]['result'] = result
156 self._results[tid]['run_start_time'] = run_start_time
157 self._results[tid]['run_end_time'] = run_end_time
158 self._results[tid]['result'] = result
159 self._lock.release()
160
161 def wasSuccessful(self):
162 wasSuccessful = True
163 for tid in self._results.keys():
164 wasSuccessful = wasSuccessful and \
165 self._results[tid]['result'].wasSuccessful()
166 return wasSuccessful
167
168 def stop(self):
169 for tid in self._results.keys():
170 self._results[tid]['result'].stop()
171
172 def logSummary(self, component, context_msg=''):
173 elapsed_time = (self.tc._run_end_time - self.tc._run_start_time)
174
175 self.tc.logger.info("SUMMARY:")
176 self.tc.logger.info("%s (%s) - Ran %d tests in %.3fs" % (component,
177 context_msg, len(self.tc._registry['cases']), elapsed_time))
178 if self.wasSuccessful():
179 msg = "%s - OK - All required tests passed" % component
180 else:
181 msg = "%s - FAIL - Required tests failed" % component
182 self.tc.logger.info(msg)
183
184 def logDetails(self):
185 tid = list(self._results)[0]
186 result = self._results[tid]['result']
187 result.logDetails()