aboutsummaryrefslogtreecommitdiffstats
path: root/lib/oeqa/utils/qemuzephyrrunner.py
diff options
context:
space:
mode:
authorJuro Bystricky <juro.bystricky@intel.com>2017-02-05 20:14:29 -0800
committerJuro Bystricky <juro.bystricky@intel.com>2017-02-05 20:54:03 -0800
commit32e3cf773e87673f6b5fc650e9cfce59c48db3cc (patch)
treed4805e3c2630c2c704b797b90715dc99c6af01a9 /lib/oeqa/utils/qemuzephyrrunner.py
parentc42423e29122c47264d4094070e4141cff814a73 (diff)
downloadmeta-zephyr-32e3cf773e87673f6b5fc650e9cfce59c48db3cc.tar.gz
meta-zephyr-32e3cf773e87673f6b5fc650e9cfce59c48db3cc.tar.bz2
meta-zephyr-32e3cf773e87673f6b5fc650e9cfce59c48db3cc.zip
testimage: performance improvements
Refactored processing of QEMU logs. The original code read QEMU logs every 30 seconds, which resulted in each test taking at least 30 seconds to finish. In reality, most tests take only a few seconds. Although the tests run in parallel, on systems with only a few CPUs this can make a very noticable difference. Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
Diffstat (limited to 'lib/oeqa/utils/qemuzephyrrunner.py')
-rw-r--r--lib/oeqa/utils/qemuzephyrrunner.py69
1 files changed, 46 insertions, 23 deletions
diff --git a/lib/oeqa/utils/qemuzephyrrunner.py b/lib/oeqa/utils/qemuzephyrrunner.py
index 2011434..9d7badb 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,21 +13,31 @@ import socket
import select
import bb
import tempfile
+import sys
from oeqa.utils.qemurunner import QemuRunner
class QemuZephyrRunner(QemuRunner):
- def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, kernel, boottime):
+ def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds, use_kvm):
QemuRunner.__init__(self, machine, rootfs, display, tmpdir,
deploy_dir_image, logfile, boottime, None,
- None, True)
+ None, use_kvm)
# Popen object for runqemu
self.socketfile = tempfile.NamedTemporaryFile()
self.runqemu = None
self.socketname = self.socketfile.name
self.server_socket = None
- self.kernel = kernel
+
+ self.kernel = rootfs
+ self.deploy_dir_image = deploy_dir_image
+ self.logfile = logfile
+ self.use_kvm = use_kvm
+
+ 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)
@@ -49,10 +59,10 @@ class QemuZephyrRunner(QemuRunner):
return False
return True
- def start(self, qemuparams = None, get_ip = True, extra_bootparams = None):
-
+ def start(self, params=None, extra_bootparams=None):
if not os.path.exists(self.tmpdir):
bb.error("Invalid TMPDIR path %s" % self.tmpdir)
+ #logger.error("Invalid TMPDIR path %s" % self.tmpdir)
return False
else:
os.environ["OE_TMPDIR"] = self.tmpdir
@@ -63,7 +73,7 @@ class QemuZephyrRunner(QemuRunner):
os.environ["DEPLOY_DIR_IMAGE"] = self.deploy_dir_image
if not os.path.exists(self.kernel):
- bb.error("Invalid kernel path: %s" % self.deploy_dir_image)
+ bb.error("Invalid kernel path: %s" % self.kernel)
return False
self.qemuparams = '-nographic -serial unix:%s,server' % (self.socketname)
@@ -117,20 +127,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