summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/qemurunner.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/utils/qemurunner.py')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 9ef7629c11..c0abb96546 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -416,7 +416,7 @@ class QemuRunner:
416 if "qemu-system" in basecmd and "-serial tcp" in commands[p]: 416 if "qemu-system" in basecmd and "-serial tcp" in commands[p]:
417 return [int(p),commands[p]] 417 return [int(p),commands[p]]
418 418
419 def run_serial(self, command, raw=False): 419 def run_serial(self, command, raw=False, timeout=5):
420 # We assume target system have echo to get command status 420 # We assume target system have echo to get command status
421 if not raw: 421 if not raw:
422 command = "%s; echo $?\n" % command 422 command = "%s; echo $?\n" % command
@@ -424,20 +424,23 @@ class QemuRunner:
424 data = '' 424 data = ''
425 status = 0 425 status = 0
426 self.server_socket.sendall(command.encode('utf-8')) 426 self.server_socket.sendall(command.encode('utf-8'))
427 keepreading = True 427 start = time.time()
428 while keepreading: 428 end = start + timeout
429 sread, _, _ = select.select([self.server_socket],[],[],5) 429 while True:
430 now = time.time()
431 if now >= end:
432 data += "<<< run_serial(): command timed out after %d seconds without output >>>\r\n\r\n" % timeout
433 break
434 sread, _, _ = select.select([self.server_socket],[],[], end - now)
430 if sread: 435 if sread:
431 answer = self.server_socket.recv(1024) 436 answer = self.server_socket.recv(1024)
432 if answer: 437 if answer:
433 data += answer.decode('utf-8') 438 data += answer.decode('utf-8')
434 # Search the prompt to stop 439 # Search the prompt to stop
435 if re.search("[a-zA-Z0-9]+@[a-zA-Z0-9\-]+:~#", data): 440 if re.search("[a-zA-Z0-9]+@[a-zA-Z0-9\-]+:~#", data):
436 keepreading = False 441 break
437 else: 442 else:
438 raise Exception("No data on serial console socket") 443 raise Exception("No data on serial console socket")
439 else:
440 keepreading = False
441 444
442 if data: 445 if data:
443 if raw: 446 if raw: