summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2015-08-12 07:02:21 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-16 09:24:59 +0100
commitc0c463be28b731606f727ba85617c73796c05eab (patch)
treed31178a15973aa4719a1318b24e4169b0a53a20a /meta
parenta5bfa110f6bb24523bf78718552cb092d507bab6 (diff)
downloadpoky-c0c463be28b731606f727ba85617c73796c05eab.tar.gz
qemurunner.py: Added raw mode in run_serial
Raw mode allows to send the command without sending 'echo $?' for validation; Also this doesn't remove the command or the prompt from the output returned. In raw mode validation is done if there is output. This raw mode would be useful for validate the prompt when a user logs in. [YOCTO #8118] (From OE-Core rev: b8ead7c0929c4096e50b481a608f5d0c09eab29d) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index fc2e244a7f..3e604d8155 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -177,7 +177,7 @@ class QemuRunner:
177 self.stop() 177 self.stop()
178 return False 178 return False
179 179
180 (status, output) = self.run_serial("root\n") 180 (status, output) = self.run_serial("root\n", raw=True)
181 if re.search("root@[a-zA-Z0-9\-]+:~#", output): 181 if re.search("root@[a-zA-Z0-9\-]+:~#", output):
182 self.logged = True 182 self.logged = True
183 logger.info("Logged as root in serial console") 183 logger.info("Logged as root in serial console")
@@ -274,9 +274,11 @@ class QemuRunner:
274 if "qemu-system" in basecmd and "-serial tcp" in commands[p]: 274 if "qemu-system" in basecmd and "-serial tcp" in commands[p]:
275 return [int(p),commands[p]] 275 return [int(p),commands[p]]
276 276
277 def run_serial(self, command): 277 def run_serial(self, command, raw=False):
278 # We assume target system have echo to get command status 278 # We assume target system have echo to get command status
279 self.server_socket.sendall("%s; echo $?\n" % command) 279 if not raw:
280 command = "%s; echo $?\n" % command
281 self.server_socket.sendall(command)
280 data = '' 282 data = ''
281 status = 0 283 status = 0
282 stopread = False 284 stopread = False
@@ -291,15 +293,18 @@ class QemuRunner:
291 sock.close() 293 sock.close()
292 stopread = True 294 stopread = True
293 if data: 295 if data:
294 # Remove first line (command line) and last line (prompt) 296 if raw:
295 data = data[data.find('$?\r\n')+4:data.rfind('\r\n')]
296 index = data.rfind('\r\n')
297 if index == -1:
298 status_cmd = data
299 data = ""
300 else:
301 status_cmd = data[index+2:]
302 data = data[:index]
303 if (status_cmd == "0"):
304 status = 1 297 status = 1
298 else:
299 # Remove first line (command line) and last line (prompt)
300 data = data[data.find('$?\r\n')+4:data.rfind('\r\n')]
301 index = data.rfind('\r\n')
302 if index == -1:
303 status_cmd = data
304 data = ""
305 else:
306 status_cmd = data[index+2:]
307 data = data[:index]
308 if (status_cmd == "0"):
309 status = 1
305 return (status, str(data)) 310 return (status, str(data))