summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
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
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')
-rw-r--r--meta/lib/oeqa/utils/commands.py25
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py7
-rw-r--r--meta/lib/oeqa/utils/qemutinyrunner.py3
3 files changed, 12 insertions, 23 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 """
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 32148871ff..82335d8456 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -28,7 +28,7 @@ re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
28 28
29class QemuRunner: 29class QemuRunner:
30 30
31 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds, use_kvm): 31 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds, use_kvm, logger):
32 32
33 # Popen object for runqemu 33 # Popen object for runqemu
34 self.runqemu = None 34 self.runqemu = None
@@ -57,9 +57,7 @@ class QemuRunner:
57 self.qemu_pidfile = 'pidfile_'+str(os.getpid()) 57 self.qemu_pidfile = 'pidfile_'+str(os.getpid())
58 self.host_dumper = HostDumper(dump_host_cmds, dump_dir) 58 self.host_dumper = HostDumper(dump_host_cmds, dump_dir)
59 59
60 self.logger = logging.getLogger("BitBake.QemuRunner") 60 self.logger = logger
61 self.handler = logging.StreamHandler(sys.stdout)
62 self.logger.addHandler(self.handler)
63 61
64 def create_socket(self): 62 def create_socket(self):
65 try: 63 try:
@@ -371,7 +369,6 @@ class QemuRunner:
371 self.ip = None 369 self.ip = None
372 if os.path.exists(self.qemu_pidfile): 370 if os.path.exists(self.qemu_pidfile):
373 os.remove(self.qemu_pidfile) 371 os.remove(self.qemu_pidfile)
374 self.logger.removeHandler(self.handler)
375 372
376 def stop_qemu_system(self): 373 def stop_qemu_system(self):
377 if self.qemupid: 374 if self.qemupid:
diff --git a/meta/lib/oeqa/utils/qemutinyrunner.py b/meta/lib/oeqa/utils/qemutinyrunner.py
index 1bf59007ff..63b5d1648b 100644
--- a/meta/lib/oeqa/utils/qemutinyrunner.py
+++ b/meta/lib/oeqa/utils/qemutinyrunner.py
@@ -17,7 +17,7 @@ from .qemurunner import QemuRunner
17 17
18class QemuTinyRunner(QemuRunner): 18class QemuTinyRunner(QemuRunner):
19 19
20 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, kernel, boottime): 20 def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, kernel, boottime, logger):
21 21
22 # Popen object for runqemu 22 # Popen object for runqemu
23 self.runqemu = None 23 self.runqemu = None
@@ -40,6 +40,7 @@ class QemuTinyRunner(QemuRunner):
40 self.socketfile = "console.sock" 40 self.socketfile = "console.sock"
41 self.server_socket = None 41 self.server_socket = None
42 self.kernel = kernel 42 self.kernel = kernel
43 self.logger = logger
43 44
44 45
45 def create_socket(self): 46 def create_socket(self):