diff options
| -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)) | ||
