summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2017-05-26 15:37:34 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-02 13:36:13 +0100
commitce422c7008aa394755c45a466c1a165dbbc1d356 (patch)
treefa810791bd157a7b853a5668f1503499fa2e699b
parentc118f80f17a93a425b256d64cd7c1d5fcb5fc127 (diff)
downloadpoky-ce422c7008aa394755c45a466c1a165dbbc1d356.tar.gz
oeqa/core/threaded: Add OEStreamLoggerThreaded class
The OEStreamLoggerThreaded overrides OEStreamLogger to redirect the PyUnit output to a logger. Instead of log every line when comes the OEStreamLoggerThreaded will buffer the PyUnit output and write everything at end of every suite execution to don't have mixed suite outputs. [YOCTO #11450] (From OE-Core rev: 87d3e5b70c52e5c7439afe4af5aa002522043e81) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/core/threaded.py25
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
4import threading
4import multiprocessing 5import multiprocessing
5 6
6from unittest.suite import TestSuite 7from unittest.suite import TestSuite
8
7from oeqa.core.loader import OETestLoader 9from oeqa.core.loader import OETestLoader
10from oeqa.core.runner import OEStreamLogger
8 11
9class OETestLoaderThreaded(OETestLoader): 12class 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
95class 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()