summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2017-03-24 01:45:02 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-27 08:15:06 +0100
commitc085688a5bd22bd368921a9cc38c0045720c1e78 (patch)
tree06417917bb0ce01ac17c3c5d5ee676311e67a0c2 /meta/lib/oeqa
parentb6f5a8ab6b69fea9c6ae71b5eb73f2c32d05b0fa (diff)
downloadpoky-c085688a5bd22bd368921a9cc38c0045720c1e78.tar.gz
targetcontrol.py: use logger.info to replace of bb.note
The bb.note prints multiple same lines when invoke this class again, but if we set mainlogger.propagate = False, nothing would be printed, according to logging's document: https://docs.python.org/3/library/logging.html Note If you attach a handler to a logger and one or more of its ancestors, it may emit the same record multiple times. In general, you should not need to attach a handler to more than one logger - if you just attach it to the appropriate logger which is highest in the logger hierarchy, then it will see all events logged by all descendant loggers, provided that their propagate setting is left set to True. A common scenario is to attach handlers only to the root logger, and to let propagation take care of the rest. We may need avoid using bb.note or bb.warn in oeqa since it attaches multiple log handlers which may cause confusions This patch only sets "mainlogger.propagate = False" in selftest/runqemu.py and use logger.info to replace bb.note in targetcontrol.py to minimize the impact. [YOCTO #10249] (From OE-Core rev: b139790422bc8e0d80bad063bb78bc1632731bc1) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/selftest/runqemu.py4
-rw-r--r--meta/lib/oeqa/targetcontrol.py13
2 files changed, 11 insertions, 6 deletions
diff --git a/meta/lib/oeqa/selftest/runqemu.py b/meta/lib/oeqa/selftest/runqemu.py
index c1d5c16e81..58c6f96f98 100644
--- a/meta/lib/oeqa/selftest/runqemu.py
+++ b/meta/lib/oeqa/selftest/runqemu.py
@@ -21,6 +21,10 @@ class RunqemuTests(oeSelfTest):
21 self.fstypes = "ext4 iso hddimg vmdk qcow2 vdi" 21 self.fstypes = "ext4 iso hddimg vmdk qcow2 vdi"
22 self.cmd_common = "runqemu nographic" 22 self.cmd_common = "runqemu nographic"
23 23
24 # Avoid emit the same record multiple times.
25 mainlogger = logging.getLogger("BitBake.Main")
26 mainlogger.propagate = False
27
24 self.write_config( 28 self.write_config(
25""" 29"""
26MACHINE = "%s" 30MACHINE = "%s"
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index ea89538002..40a2589cc9 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -18,6 +18,8 @@ from oeqa.utils.dump import TargetDumper
18from oeqa.controllers.testtargetloader import TestTargetLoader 18from oeqa.controllers.testtargetloader import TestTargetLoader
19from abc import ABCMeta, abstractmethod 19from abc import ABCMeta, abstractmethod
20 20
21logger = logging.getLogger('BitBake.QemuRunner')
22
21def get_target_controller(d): 23def get_target_controller(d):
22 testtarget = d.getVar("TEST_TARGET") 24 testtarget = d.getVar("TEST_TARGET")
23 # old, simple names 25 # old, simple names
@@ -63,7 +65,7 @@ class BaseTarget(object, metaclass=ABCMeta):
63 if os.path.islink(sshloglink): 65 if os.path.islink(sshloglink):
64 os.unlink(sshloglink) 66 os.unlink(sshloglink)
65 os.symlink(self.sshlog, sshloglink) 67 os.symlink(self.sshlog, sshloglink)
66 bb.note("SSH log file: %s" % self.sshlog) 68 logger.info("SSH log file: %s" % self.sshlog)
67 69
68 @abstractmethod 70 @abstractmethod
69 def start(self, params=None, ssh=True, extra_bootparams=None): 71 def start(self, params=None, ssh=True, extra_bootparams=None):
@@ -140,7 +142,6 @@ class QemuTarget(BaseTarget):
140 import oe.path 142 import oe.path
141 bb.utils.mkdirhier(self.testdir) 143 bb.utils.mkdirhier(self.testdir)
142 self.qemurunnerlog = os.path.join(self.testdir, 'qemurunner_log.%s' % self.datetime) 144 self.qemurunnerlog = os.path.join(self.testdir, 'qemurunner_log.%s' % self.datetime)
143 logger = logging.getLogger('BitBake.QemuRunner')
144 loggerhandler = logging.FileHandler(self.qemurunnerlog) 145 loggerhandler = logging.FileHandler(self.qemurunnerlog)
145 loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) 146 loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
146 logger.addHandler(loggerhandler) 147 logger.addHandler(loggerhandler)
@@ -177,8 +178,8 @@ class QemuTarget(BaseTarget):
177 os.unlink(qemuloglink) 178 os.unlink(qemuloglink)
178 os.symlink(self.qemulog, qemuloglink) 179 os.symlink(self.qemulog, qemuloglink)
179 180
180 bb.note("rootfs file: %s" % self.rootfs) 181 logger.info("rootfs file: %s" % self.rootfs)
181 bb.note("Qemu log file: %s" % self.qemulog) 182 logger.info("Qemu log file: %s" % self.qemulog)
182 super(QemuTarget, self).deploy() 183 super(QemuTarget, self).deploy()
183 184
184 def start(self, params=None, ssh=True, extra_bootparams='', runqemuparams='', launch_cmd=''): 185 def start(self, params=None, ssh=True, extra_bootparams='', runqemuparams='', launch_cmd=''):
@@ -230,14 +231,14 @@ class SimpleRemoteTarget(BaseTarget):
230 self.port = addr.split(":")[1] 231 self.port = addr.split(":")[1]
231 except IndexError: 232 except IndexError:
232 self.port = None 233 self.port = None
233 bb.note("Target IP: %s" % self.ip) 234 logger.info("Target IP: %s" % self.ip)
234 self.server_ip = d.getVar("TEST_SERVER_IP") 235 self.server_ip = d.getVar("TEST_SERVER_IP")
235 if not self.server_ip: 236 if not self.server_ip:
236 try: 237 try:
237 self.server_ip = subprocess.check_output(['ip', 'route', 'get', self.ip ]).split("\n")[0].split()[-1] 238 self.server_ip = subprocess.check_output(['ip', 'route', 'get', self.ip ]).split("\n")[0].split()[-1]
238 except Exception as e: 239 except Exception as e:
239 bb.fatal("Failed to determine the host IP address (alternatively you can set TEST_SERVER_IP with the IP address of this machine): %s" % e) 240 bb.fatal("Failed to determine the host IP address (alternatively you can set TEST_SERVER_IP with the IP address of this machine): %s" % e)
240 bb.note("Server IP: %s" % self.server_ip) 241 logger.info("Server IP: %s" % self.server_ip)
241 242
242 def deploy(self): 243 def deploy(self):
243 super(SimpleRemoteTarget, self).deploy() 244 super(SimpleRemoteTarget, self).deploy()