summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/commands.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-08 18:17:17 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-03-04 11:11:59 +0000
commit66f536ad57d00f05defbbbf8f7cc64822666ad82 (patch)
treef57c386c26a3951c6a255808033d174e10959ae6 /meta/lib/oeqa/utils/commands.py
parenta71e71f9c4d8c64fb27a03b5a048710c8aee01c1 (diff)
downloadpoky-66f536ad57d00f05defbbbf8f7cc64822666ad82.tar.gz
oeqa: Clean up logger handling
The logger handling in oeqa was confused at best. This patch: a) Passes in a logger through various qemu runner pieces b) Uses that logger consistently in the code c) Creates a logger for QemuRunner outside the bitbake namespace meaning we don't conflict with the tinfoil logging changes The result of this is more consistency. For runtime tests in testimage, the logs always contain the debug info, nothing is shwon on the console. For the oe-selftests, logs are intercepted and only shown if the test fails. (From OE-Core rev: ba8babc45141891d0624f9a181a580fa416e87ec) (From OE-Core rev: 22003f97ff7f53c32999dc466d26c1471ead9b6b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster@mvista.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/commands.py')
-rw-r--r--meta/lib/oeqa/utils/commands.py25
1 files changed, 8 insertions, 17 deletions
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 57286fcb10..ed925a4d92 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -233,6 +233,12 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
233 import bb.tinfoil 233 import bb.tinfoil
234 import bb.build 234 import bb.build
235 235
236 # Need a non-'BitBake' logger to capture the runner output
237 targetlogger = logging.getLogger('TargetRunner')
238 targetlogger.setLevel(logging.DEBUG)
239 handler = logging.StreamHandler(sys.stdout)
240 targetlogger.addHandler(handler)
241
236 tinfoil = bb.tinfoil.Tinfoil() 242 tinfoil = bb.tinfoil.Tinfoil()
237 tinfoil.prepare(config_only=False, quiet=True) 243 tinfoil.prepare(config_only=False, quiet=True)
238 try: 244 try:
@@ -250,31 +256,15 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
250 for key, value in overrides.items(): 256 for key, value in overrides.items():
251 recipedata.setVar(key, value) 257 recipedata.setVar(key, value)
252 258
253 # The QemuRunner log is saved out, but we need to ensure it is at the right
254 # log level (and then ensure that since it's a child of the BitBake logger,
255 # we disable propagation so we don't then see the log events on the console)
256 logger = logging.getLogger('BitBake.QemuRunner')
257 logger.setLevel(logging.DEBUG)
258 logger.propagate = False
259 logdir = recipedata.getVar("TEST_LOG_DIR") 259 logdir = recipedata.getVar("TEST_LOG_DIR")
260 260
261 qemu = oeqa.targetcontrol.QemuTarget(recipedata, image_fstype) 261 qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, image_fstype)
262 finally: 262 finally:
263 # We need to shut down tinfoil early here in case we actually want 263 # We need to shut down tinfoil early here in case we actually want
264 # to run tinfoil-using utilities with the running QEMU instance. 264 # to run tinfoil-using utilities with the running QEMU instance.
265 # Luckily QemuTarget doesn't need it after the constructor. 265 # Luckily QemuTarget doesn't need it after the constructor.
266 tinfoil.shutdown() 266 tinfoil.shutdown()
267 267
268 # Setup bitbake logger as console handler is removed by tinfoil.shutdown
269 bblogger = logging.getLogger('BitBake')
270 bblogger.setLevel(logging.INFO)
271 console = logging.StreamHandler(sys.stdout)
272 bbformat = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
273 if sys.stdout.isatty():
274 bbformat.enable_color()
275 console.setFormatter(bbformat)
276 bblogger.addHandler(console)
277
278 try: 268 try:
279 qemu.deploy() 269 qemu.deploy()
280 try: 270 try:
@@ -289,6 +279,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
289 qemu.stop() 279 qemu.stop()
290 except: 280 except:
291 pass 281 pass
282 targetlogger.removeHandler(handler)
292 283
293def updateEnv(env_file): 284def updateEnv(env_file):
294 """ 285 """