diff --git a/lib/oeqa/controllers/zephyrtargetconrol.py b/lib/oeqa/controllers/zephyrtargetcontrol.py similarity index 93% rename from lib/oeqa/controllers/zephyrtargetconrol.py rename to lib/oeqa/controllers/zephyrtargetcontrol.py index 94bf183..8400bd1 100644 --- a/lib/oeqa/controllers/zephyrtargetconrol.py +++ b/lib/oeqa/controllers/zephyrtargetcontrol.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2016 Intel Corporation +# Copyright (C) 2013-2017 Intel Corporation # # Released under the MIT license (see COPYING.MIT) @@ -62,5 +62,5 @@ class QemuTargetZephyr(QemuTarget): bb.note("Qemu log file: %s" % self.qemulog) super(QemuTarget, self).deploy() - def wait_for_serial(self, func_timeout, data_timeout): - return self.runner.wait_for_serial(func_timeout, data_timeout) + def serial_readline(self): + return self.runner.serial_readline() diff --git a/lib/oeqa/runtime/zephyr.py b/lib/oeqa/runtime/zephyr.py index 94601b8..6670d96 100644 --- a/lib/oeqa/runtime/zephyr.py +++ b/lib/oeqa/runtime/zephyr.py @@ -5,19 +5,24 @@ class ZephyrTest(oeRuntimeTest): def test_boot_zephyr(self): success = False - logfile = self.target.wait_for_serial(180, 30) + logfile = self.target.qemurunnerlog + while True: + line = self.target.serial_readline().decode("utf-8") - with open(logfile) as f: - for line in f: - # All good - if "PROJECT EXECUTION SUCCESSFUL" in line: - success = True - break - # Most likely cause for faults is incorrectly compiled code - if "***** USAGE FAULT *****" in line: - success = False - self.assertTrue(success, msg='***** USAGE FAULT *****" in file:///%s' % logfile) - break + # All good + if "PROJECT EXECUTION SUCCESSFUL" in line: + success = True + break + + if "PROJECT EXECUTION FAILED" in line: + success = False + self.assertTrue(success, msg='PROJECT EXECUTION FAILED in file:///%s' % logfile) + break + # Most likely cause for faults is incorrectly compiled code + if "***** USAGE FAULT *****" in line: + success = False + self.assertTrue(success, msg='***** USAGE FAULT *****" in file:///%s' % logfile) + break # test program finished, complain if no success message self.assertTrue(success, msg='"PROJECT EXECUTION SUCCESSFUL" not in file:///%s' % logfile) diff --git a/lib/oeqa/utils/qemuzephyrrunner.py b/lib/oeqa/utils/qemuzephyrrunner.py index 2011434..d4b6c8e 100644 --- a/lib/oeqa/utils/qemuzephyrrunner.py +++ b/lib/oeqa/utils/qemuzephyrrunner.py @@ -1,8 +1,8 @@ -# Copyright (C) 2015-2016 Intel Corporation +# Copyright (C) 2015-2017 Intel Corporation # # Released under the MIT license (see COPYING.MIT) -# This module provides a class for starting qemu images of poky tiny. +# This module provides a class for starting qemu images. # It's used by testimage.bbclass. import subprocess @@ -13,6 +13,7 @@ import socket import select import bb import tempfile +import sys from oeqa.utils.qemurunner import QemuRunner class QemuZephyrRunner(QemuRunner): @@ -28,6 +29,10 @@ class QemuZephyrRunner(QemuRunner): self.socketname = self.socketfile.name self.server_socket = None self.kernel = kernel + self.buffers = b'' + self._rbufsize = 4096 + # 5 minutes timeout... + self.endtime = time.time() + 60*5 def create_socket(self): bb.note("waiting at most %s seconds for qemu pid" % self.runqemutime) @@ -117,20 +122,33 @@ class QemuZephyrRunner(QemuRunner): bb.note("qemu started, pid is %s" % self.runqemu.pid) return self.create_socket() - def wait_for_serial(self, func_timeout, data_timeout): - stopread = False - check_endtime = False - self.server_socket.setblocking(0) - endtime = time.time() + func_timeout + def _readline(self): + nl = self.buffers.find(b'\n') + if nl >= 0: + nl += 1 + line = self.buffers[:nl] + newbuf = self.buffers[nl:] + self.buffers = newbuf + return line + return None + + def serial_readline(self): + line = self._readline() + if line is None: + while True: + if time.time() >= self.endtime: + bb.warn("Timeout!") + raise Exception("Timeout") + data = self.server_socket.recv(self._rbufsize) + if data is None: + raise Exception("No data on read ready socket") + + self.buffers = self.buffers + data + line = self._readline() + if line is not None: + break + + self.log(line) + return line - while time.time() < endtime: - sread, _, _ = select.select([self.server_socket],[],[],data_timeout) - if not sread: - break - answer = self.server_socket.recv(1024) - if answer: - self.log(answer) - else: - break - return self.logfile