summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-02-13 11:02:12 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-15 16:28:44 +0000
commit0ade65834b6c3d6e6a28ed551497a58f31a8d348 (patch)
tree31c5c94d5518ea8cf78454e2477741fd1bf94f61 /meta/lib/oeqa/utils
parentd083fec6d1211183f76b49025b10bc8faf5df010 (diff)
downloadpoky-0ade65834b6c3d6e6a28ed551497a58f31a8d348.tar.gz
qemurunner: add parameter to method 'start'
QemuRunner requires pair of ip addresses provided through kernel commandline for method 'start' to work. These ip addresses are used to connect to the image using ssh and run tests there. However, this functionality should not be mandatory as testing doesn't always require ssh connection. Some tests can be run using serial console. Added new parameter 'get_ip' to QemuRunner.start to make it possible to skip getting pair of ip addresses from kernel command line. This should allow oe-selftest to test images without modifying kernel command line. [YOCTO #8498] (From OE-Core rev: 3f8b734ebb81d035849288091bb0b97b9c4fba34) (From OE-Core rev: 4c90daaeb946f1adf58b2f71f1af8eb7f5906474) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py45
1 files changed, 23 insertions, 22 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index def8acedcb..784cf964f5 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -91,7 +91,7 @@ class QemuRunner:
91 self._dump_host() 91 self._dump_host()
92 raise SystemExit 92 raise SystemExit
93 93
94 def start(self, qemuparams = None): 94 def start(self, qemuparams = None, get_ip = True):
95 if self.display: 95 if self.display:
96 os.environ["DISPLAY"] = self.display 96 os.environ["DISPLAY"] = self.display
97 # Set this flag so that Qemu doesn't do any grabs as SDL grabs 97 # Set this flag so that Qemu doesn't do any grabs as SDL grabs
@@ -178,27 +178,28 @@ class QemuRunner:
178 178
179 if self.is_alive(): 179 if self.is_alive():
180 logger.info("qemu started - qemu procces pid is %s" % self.qemupid) 180 logger.info("qemu started - qemu procces pid is %s" % self.qemupid)
181 cmdline = '' 181 if get_ip:
182 with open('/proc/%s/cmdline' % self.qemupid) as p: 182 cmdline = ''
183 cmdline = p.read() 183 with open('/proc/%s/cmdline' % self.qemupid) as p:
184 # It is needed to sanitize the data received 184 cmdline = p.read()
185 # because is possible to have control characters 185 # It is needed to sanitize the data received
186 cmdline = re_control_char.sub('', cmdline) 186 # because is possible to have control characters
187 try: 187 cmdline = re_control_char.sub('', cmdline)
188 ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1]) 188 try:
189 if not ips or len(ips) != 3: 189 ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
190 raise ValueError 190 if not ips or len(ips) != 3:
191 else: 191 raise ValueError
192 self.ip = ips[0] 192 else:
193 self.server_ip = ips[1] 193 self.ip = ips[0]
194 except IndexError, ValueError: 194 self.server_ip = ips[1]
195 logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, self.getOutput(output))) 195 except IndexError, ValueError:
196 self._dump_host() 196 logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, self.getOutput(output)))
197 self.stop() 197 self._dump_host()
198 return False 198 self.stop()
199 logger.info("qemu cmdline used:\n{}".format(cmdline)) 199 return False
200 logger.info("Target IP: %s" % self.ip) 200 logger.info("qemu cmdline used:\n{}".format(cmdline))
201 logger.info("Server IP: %s" % self.server_ip) 201 logger.info("Target IP: %s" % self.ip)
202 logger.info("Server IP: %s" % self.server_ip)
202 203
203 self.thread = LoggingThread(self.log, threadsock, logger) 204 self.thread = LoggingThread(self.log, threadsock, logger)
204 self.thread.start() 205 self.thread.start()