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>2017-11-09 12:24:24 +0000
commit0e198a7311fe341c5bc20a697e90da2928c44262 (patch)
tree9d864cb840bb6295b28d93159c17384e2d5505e7 /meta/lib/oeqa/utils/commands.py
parent7608f33f0f0c6c1c61c80a77e12270d06b236d84 (diff)
downloadpoky-0e198a7311fe341c5bc20a697e90da2928c44262.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: 4ff678137a55b93c9ba2cbffda34335ba859f704) 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 5e5345434d..0bb90028dc 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -296,6 +296,12 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
296 import bb.tinfoil 296 import bb.tinfoil
297 import bb.build 297 import bb.build
298 298
299 # Need a non-'BitBake' logger to capture the runner output
300 targetlogger = logging.getLogger('TargetRunner')
301 targetlogger.setLevel(logging.DEBUG)
302 handler = logging.StreamHandler(sys.stdout)
303 targetlogger.addHandler(handler)
304
299 tinfoil = bb.tinfoil.Tinfoil() 305 tinfoil = bb.tinfoil.Tinfoil()
300 tinfoil.prepare(config_only=False, quiet=True) 306 tinfoil.prepare(config_only=False, quiet=True)
301 try: 307 try:
@@ -313,31 +319,15 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
313 for key, value in overrides.items(): 319 for key, value in overrides.items():
314 recipedata.setVar(key, value) 320 recipedata.setVar(key, value)
315 321
316 # The QemuRunner log is saved out, but we need to ensure it is at the right
317 # log level (and then ensure that since it's a child of the BitBake logger,
318 # we disable propagation so we don't then see the log events on the console)
319 logger = logging.getLogger('BitBake.QemuRunner')
320 logger.setLevel(logging.DEBUG)
321 logger.propagate = False
322 logdir = recipedata.getVar("TEST_LOG_DIR") 322 logdir = recipedata.getVar("TEST_LOG_DIR")
323 323
324 qemu = oeqa.targetcontrol.QemuTarget(recipedata, image_fstype) 324 qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, image_fstype)
325 finally: 325 finally:
326 # We need to shut down tinfoil early here in case we actually want 326 # We need to shut down tinfoil early here in case we actually want
327 # to run tinfoil-using utilities with the running QEMU instance. 327 # to run tinfoil-using utilities with the running QEMU instance.
328 # Luckily QemuTarget doesn't need it after the constructor. 328 # Luckily QemuTarget doesn't need it after the constructor.
329 tinfoil.shutdown() 329 tinfoil.shutdown()
330 330
331 # Setup bitbake logger as console handler is removed by tinfoil.shutdown
332 bblogger = logging.getLogger('BitBake')
333 bblogger.setLevel(logging.INFO)
334 console = logging.StreamHandler(sys.stdout)
335 bbformat = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
336 if sys.stdout.isatty():
337 bbformat.enable_color()
338 console.setFormatter(bbformat)
339 bblogger.addHandler(console)
340
341 try: 331 try:
342 qemu.deploy() 332 qemu.deploy()
343 try: 333 try:
@@ -352,6 +342,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
352 qemu.stop() 342 qemu.stop()
353 except: 343 except:
354 pass 344 pass
345 targetlogger.removeHandler(handler)
355 346
356def updateEnv(env_file): 347def updateEnv(env_file):
357 """ 348 """