diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2015-08-11 13:24:44 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-16 09:24:59 +0100 |
commit | 78e1c4f146e8536513ff3301f054e66c2fea00a4 (patch) | |
tree | 7b1ff99253bf861614a5c8c9417184c4315858f4 /meta | |
parent | 7ffb6602ff2075ed8d6edc9282c47e63ea0f0994 (diff) | |
download | poky-78e1c4f146e8536513ff3301f054e66c2fea00a4.tar.gz |
qemurunner.py: Add method run_serial
The only need for the console before this patch was
to check if the target has booted. This allows to send
commands to the terminal.
This new method is based on the method with the same name
of the QemuTinyRunner class. The difference here is it will
remove the command and the prompt. The other diference is
it will send an echo $? to check if the last command was
successful.
[YOCTO #8118]
(From OE-Core rev: a82711fe4520538a732a16795d50573b6f1d4463)
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.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 9bb1f4bb2d..81ca32e11b 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -262,3 +262,33 @@ class QemuRunner: | |||
262 | basecmd = os.path.basename(basecmd) | 262 | basecmd = os.path.basename(basecmd) |
263 | if "qemu-system" in basecmd and "-serial tcp" in commands[p]: | 263 | if "qemu-system" in basecmd and "-serial tcp" in commands[p]: |
264 | return [int(p),commands[p]] | 264 | return [int(p),commands[p]] |
265 | |||
266 | def run_serial(self, command): | ||
267 | # We assume target system have echo to get command status | ||
268 | self.server_socket.sendall("%s; echo $?\n" % command) | ||
269 | data = '' | ||
270 | status = 0 | ||
271 | stopread = False | ||
272 | endtime = time.time()+5 | ||
273 | while time.time()<endtime and not stopread: | ||
274 | sread, _, _ = select.select([self.server_socket],[],[],5) | ||
275 | for sock in sread: | ||
276 | answer = sock.recv(1024) | ||
277 | if answer: | ||
278 | data += answer | ||
279 | else: | ||
280 | sock.close() | ||
281 | stopread = True | ||
282 | if data: | ||
283 | # Remove first line (command line) and last line (prompt) | ||
284 | data = data[data.find('$?\r\n')+4:data.rfind('\r\n')] | ||
285 | index = data.rfind('\r\n') | ||
286 | if index == -1: | ||
287 | status_cmd = data | ||
288 | data = "" | ||
289 | else: | ||
290 | status_cmd = data[index+2:] | ||
291 | data = data[:index] | ||
292 | if (status_cmd == "0"): | ||
293 | status = 1 | ||
294 | return (status, str(data)) | ||