summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/targetcontrol.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/targetcontrol.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/targetcontrol.py')
-rw-r--r--meta/lib/oeqa/targetcontrol.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index e17c89552f..f63936c3ec 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -18,19 +18,18 @@ 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
23class BaseTarget(object, metaclass=ABCMeta): 21class BaseTarget(object, metaclass=ABCMeta):
24 22
25 supported_image_fstypes = [] 23 supported_image_fstypes = []
26 24
27 def __init__(self, d): 25 def __init__(self, d, logger):
28 self.connection = None 26 self.connection = None
29 self.ip = None 27 self.ip = None
30 self.server_ip = None 28 self.server_ip = None
31 self.datetime = d.getVar('DATETIME') 29 self.datetime = d.getVar('DATETIME')
32 self.testdir = d.getVar("TEST_LOG_DIR") 30 self.testdir = d.getVar("TEST_LOG_DIR")
33 self.pn = d.getVar("PN") 31 self.pn = d.getVar("PN")
32 self.logger = logger
34 33
35 @abstractmethod 34 @abstractmethod
36 def deploy(self): 35 def deploy(self):
@@ -40,7 +39,7 @@ class BaseTarget(object, metaclass=ABCMeta):
40 if os.path.islink(sshloglink): 39 if os.path.islink(sshloglink):
41 os.unlink(sshloglink) 40 os.unlink(sshloglink)
42 os.symlink(self.sshlog, sshloglink) 41 os.symlink(self.sshlog, sshloglink)
43 logger.info("SSH log file: %s" % self.sshlog) 42 self.logger.info("SSH log file: %s" % self.sshlog)
44 43
45 @abstractmethod 44 @abstractmethod
46 def start(self, params=None, ssh=True, extra_bootparams=None): 45 def start(self, params=None, ssh=True, extra_bootparams=None):
@@ -90,7 +89,7 @@ class QemuTarget(BaseTarget):
90 89
91 supported_image_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic'] 90 supported_image_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic']
92 91
93 def __init__(self, d, image_fstype=None, logger=None): 92 def __init__(self, d, logger, image_fstype=None):
94 93
95 super(QemuTarget, self).__init__(d, logger) 94 super(QemuTarget, self).__init__(d, logger)
96 95
@@ -120,7 +119,7 @@ class QemuTarget(BaseTarget):
120 self.qemurunnerlog = os.path.join(self.testdir, 'qemurunner_log.%s' % self.datetime) 119 self.qemurunnerlog = os.path.join(self.testdir, 'qemurunner_log.%s' % self.datetime)
121 loggerhandler = logging.FileHandler(self.qemurunnerlog) 120 loggerhandler = logging.FileHandler(self.qemurunnerlog)
122 loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) 121 loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
123 logger.addHandler(loggerhandler) 122 self.logger.addHandler(loggerhandler)
124 oe.path.symlink(os.path.basename(self.qemurunnerlog), os.path.join(self.testdir, 'qemurunner_log'), force=True) 123 oe.path.symlink(os.path.basename(self.qemurunnerlog), os.path.join(self.testdir, 'qemurunner_log'), force=True)
125 124
126 if d.getVar("DISTRO") == "poky-tiny": 125 if d.getVar("DISTRO") == "poky-tiny":
@@ -131,7 +130,8 @@ class QemuTarget(BaseTarget):
131 display = d.getVar("BB_ORIGENV", False).getVar("DISPLAY"), 130 display = d.getVar("BB_ORIGENV", False).getVar("DISPLAY"),
132 logfile = self.qemulog, 131 logfile = self.qemulog,
133 kernel = self.kernel, 132 kernel = self.kernel,
134 boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT"))) 133 boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT")),
134 logger = logger)
135 else: 135 else:
136 self.runner = QemuRunner(machine=d.getVar("MACHINE"), 136 self.runner = QemuRunner(machine=d.getVar("MACHINE"),
137 rootfs=self.rootfs, 137 rootfs=self.rootfs,
@@ -142,7 +142,8 @@ class QemuTarget(BaseTarget):
142 boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT")), 142 boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT")),
143 use_kvm = use_kvm, 143 use_kvm = use_kvm,
144 dump_dir = dump_dir, 144 dump_dir = dump_dir,
145 dump_host_cmds = d.getVar("testimage_dump_host")) 145 dump_host_cmds = d.getVar("testimage_dump_host"),
146 logger = logger)
146 147
147 self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner) 148 self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner)
148 149
@@ -154,8 +155,8 @@ class QemuTarget(BaseTarget):
154 os.unlink(qemuloglink) 155 os.unlink(qemuloglink)
155 os.symlink(self.qemulog, qemuloglink) 156 os.symlink(self.qemulog, qemuloglink)
156 157
157 logger.info("rootfs file: %s" % self.rootfs) 158 self.logger.info("rootfs file: %s" % self.rootfs)
158 logger.info("Qemu log file: %s" % self.qemulog) 159 self.logger.info("Qemu log file: %s" % self.qemulog)
159 super(QemuTarget, self).deploy() 160 super(QemuTarget, self).deploy()
160 161
161 def start(self, params=None, ssh=True, extra_bootparams='', runqemuparams='', launch_cmd='', discard_writes=True): 162 def start(self, params=None, ssh=True, extra_bootparams='', runqemuparams='', launch_cmd='', discard_writes=True):
@@ -207,14 +208,14 @@ class SimpleRemoteTarget(BaseTarget):
207 self.port = addr.split(":")[1] 208 self.port = addr.split(":")[1]
208 except IndexError: 209 except IndexError:
209 self.port = None 210 self.port = None
210 logger.info("Target IP: %s" % self.ip) 211 self.logger.info("Target IP: %s" % self.ip)
211 self.server_ip = d.getVar("TEST_SERVER_IP") 212 self.server_ip = d.getVar("TEST_SERVER_IP")
212 if not self.server_ip: 213 if not self.server_ip:
213 try: 214 try:
214 self.server_ip = subprocess.check_output(['ip', 'route', 'get', self.ip ]).split("\n")[0].split()[-1] 215 self.server_ip = subprocess.check_output(['ip', 'route', 'get', self.ip ]).split("\n")[0].split()[-1]
215 except Exception as e: 216 except Exception as e:
216 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) 217 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)
217 logger.info("Server IP: %s" % self.server_ip) 218 self.logger.info("Server IP: %s" % self.server_ip)
218 219
219 def deploy(self): 220 def deploy(self):
220 super(SimpleRemoteTarget, self).deploy() 221 super(SimpleRemoteTarget, self).deploy()