aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/qemurunner.py
diff options
context:
space:
mode:
authorStefan Stanacar <stefanx.stanacar@intel.com>2013-11-26 11:18:22 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-03 12:51:57 +0000
commita7820350fa3271d78ed7476e02f4aef593be1125 (patch)
tree20561420d3cd1a5607f6fafe2d0f5f58d3035d42 /meta/lib/oeqa/utils/qemurunner.py
parentb7a0e1c351e396af6470e59c428128789295bd96 (diff)
downloadopenembedded-core-contrib-a7820350fa3271d78ed7476e02f4aef593be1125.tar.gz
testimage: use the new targetcontrol.py module for running tests
This patch makes the necessary changes for using the targetcontrol.py module so that one can run the same tests on a qemu instance or a remote machine based on the value of TEST_TARGET variable: "qemu" or "simpleremote". The default value is "qemu" which starts a qemu instance and it's the with what we currently have. With "simpleremote", the remote machine must be up with network and ssh and you need to set TEST_TARGET_IP with the IP address of the remote machine (it can still be a qemu instance that was manually started). Basically testimage.bbclass now does something along the lines of: - load tests -> deploy (prepare) / start target -> run tests. There were a couple of changes necessary for tests and also some cleanups/renames that were needed to adjust this change. (use ip everywhere when refering to target and server_ip when refering to host/build machine) Also two unnecessary and unsed methods were dropped from sshcontrol. [ YOCTO #5554 ] Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/qemurunner.py')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py50
1 files changed, 30 insertions, 20 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 256cf3c6a8..5366a635fe 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -16,25 +16,30 @@ import bb
class QemuRunner:
- def __init__(self, machine, rootfs, display = None, tmpdir = None, deploy_dir_image = None, logfile = None, boottime = 400, runqemutime = 60):
- # Popen object
- self.runqemu = None
-
- self.machine = machine
- self.rootfs = rootfs
+ def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime):
+ # Popen object for runqemu
+ self.runqemu = None
+ # pid of the qemu process that runqemu will start
self.qemupid = None
+ # target ip - from the command line
self.ip = None
+ # host ip - where qemu is running
+ self.server_ip = None
+ self.machine = machine
+ self.rootfs = rootfs
self.display = display
self.tmpdir = tmpdir
self.deploy_dir_image = deploy_dir_image
self.logfile = logfile
self.boottime = boottime
- self.runqemutime = runqemutime
+
+ self.runqemutime = 60
self.create_socket()
+
def create_socket(self):
self.bootlog = ''
@@ -57,7 +62,7 @@ class QemuRunner:
with open(self.logfile, "a") as f:
f.write("%s" % msg)
- def launch(self, qemuparams = None):
+ def start(self, qemuparams = None):
if self.display:
os.environ["DISPLAY"] = self.display
@@ -96,14 +101,19 @@ class QemuRunner:
if self.is_alive():
bb.note("qemu started - qemu procces pid is %s" % self.qemupid)
- cmdline = open('/proc/%s/cmdline' % self.qemupid).read()
- self.ip, _, self.host_ip = cmdline.split('ip=')[1].split(' ')[0].split(':')[0:3]
- if not re.search("^((?:[0-9]{1,3}\.){3}[0-9]{1,3})$", self.ip):
- bb.note("Couldn't get ip from qemu process arguments, I got '%s'" % self.ip)
- bb.note("Here is the ps output:\n%s" % cmdline)
- self.kill()
+ cmdline = ''
+ with open('/proc/%s/cmdline' % self.qemupid) as p:
+ cmdline = p.read()
+ ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
+ if not ips or len(ips) != 3:
+ bb.note("Couldn't get ip from qemu process arguments! Here is the qemu command line used: %s" % cmdline)
+ self.stop()
return False
- bb.note("IP found: %s" % self.ip)
+ else:
+ self.ip = ips[0]
+ self.server_ip = ips[1]
+ bb.note("Target IP: %s" % self.ip)
+ bb.note("Server IP: %s" % self.server_ip)
bb.note("Waiting at most %d seconds for login banner" % self.boottime )
endtime = time.time() + self.boottime
socklist = [self.server_socket]
@@ -138,18 +148,18 @@ class QemuRunner:
lines = "\n".join(self.bootlog.splitlines()[-5:])
bb.note("Last 5 lines of text:\n%s" % lines)
bb.note("Check full boot log: %s" % self.logfile)
- self.kill()
+ self.stop()
return False
else:
bb.note("Qemu pid didn't appeared in %s seconds" % self.runqemutime)
output = self.runqemu.stdout
- self.kill()
+ self.stop()
bb.note("Output from runqemu:\n%s" % output.read())
return False
return self.is_alive()
- def kill(self):
+ def stop(self):
if self.runqemu:
bb.note("Sending SIGTERM to runqemu")
@@ -170,9 +180,9 @@ class QemuRunner:
def restart(self, qemuparams = None):
bb.note("Restarting qemu process")
if self.runqemu.poll() is None:
- self.kill()
+ self.stop()
self.create_socket()
- if self.launch(qemuparams):
+ if self.start(qemuparams):
return True
return False