diff options
Diffstat (limited to 'meta/lib/oeqa/core/threaded.py')
| -rw-r--r-- | meta/lib/oeqa/core/threaded.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/meta/lib/oeqa/core/threaded.py b/meta/lib/oeqa/core/threaded.py index e6f214088c..73b7f2fa64 100644 --- a/meta/lib/oeqa/core/threaded.py +++ b/meta/lib/oeqa/core/threaded.py | |||
| @@ -1,10 +1,13 @@ | |||
| 1 | # Copyright (C) 2017 Intel Corporation | 1 | # Copyright (C) 2017 Intel Corporation |
| 2 | # Released under the MIT license (see COPYING.MIT) | 2 | # Released under the MIT license (see COPYING.MIT) |
| 3 | 3 | ||
| 4 | import threading | ||
| 4 | import multiprocessing | 5 | import multiprocessing |
| 5 | 6 | ||
| 6 | from unittest.suite import TestSuite | 7 | from unittest.suite import TestSuite |
| 8 | |||
| 7 | from oeqa.core.loader import OETestLoader | 9 | from oeqa.core.loader import OETestLoader |
| 10 | from oeqa.core.runner import OEStreamLogger | ||
| 8 | 11 | ||
| 9 | class OETestLoaderThreaded(OETestLoader): | 12 | class OETestLoaderThreaded(OETestLoader): |
| 10 | def __init__(self, tc, module_paths, modules, tests, modules_required, | 13 | def __init__(self, tc, module_paths, modules, tests, modules_required, |
| @@ -89,3 +92,25 @@ class OETestLoaderThreaded(OETestLoader): | |||
| 89 | 92 | ||
| 90 | return suites | 93 | return suites |
| 91 | 94 | ||
| 95 | class OEStreamLoggerThreaded(OEStreamLogger): | ||
| 96 | _lock = threading.Lock() | ||
| 97 | buffers = {} | ||
| 98 | |||
| 99 | def write(self, msg): | ||
| 100 | tid = threading.get_ident() | ||
| 101 | |||
| 102 | if not tid in self.buffers: | ||
| 103 | self.buffers[tid] = "" | ||
| 104 | |||
| 105 | if msg: | ||
| 106 | self.buffers[tid] += msg | ||
| 107 | |||
| 108 | def finish(self): | ||
| 109 | tid = threading.get_ident() | ||
| 110 | |||
| 111 | self._lock.acquire() | ||
| 112 | self.logger.info('THREAD: %d' % tid) | ||
| 113 | self.logger.info('-' * 70) | ||
| 114 | for line in self.buffers[tid].split('\n'): | ||
| 115 | self.logger.info(line) | ||
| 116 | self._lock.release() | ||
