diff options
author | Stefan Stanacar <stefanx.stanacar@intel.com> | 2013-08-22 14:47:21 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-08-26 11:47:21 +0100 |
commit | 51588936d4a8cde3c9bb05800240c0a0f5dedf8d (patch) | |
tree | f83affb23fa364c3baa7bfaa2d87755b49f7341e /meta/lib | |
parent | ecb21fd7f88e4f2f37389d8efbde76effa00d7db (diff) | |
download | poky-51588936d4a8cde3c9bb05800240c0a0f5dedf8d.tar.gz |
lib/oeqa: make it possible to restart the target
Tweak QemuRunner so we can actually restart the
qemu target in a test (if we want more memory for example).
Also add a restart method to the base test class so that tests
can use it.
(From OE-Core rev: 9de7fe11967576f4a8b24e653c6b9a02e5f6d85b)
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/oetest.py | 7 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 28 |
2 files changed, 28 insertions, 7 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py index 7f6baa4038..4a406e75ca 100644 --- a/meta/lib/oeqa/oetest.py +++ b/meta/lib/oeqa/oetest.py | |||
@@ -81,6 +81,13 @@ class oeRuntimeTest(unittest.TestCase): | |||
81 | else: | 81 | else: |
82 | return False | 82 | return False |
83 | 83 | ||
84 | @classmethod | ||
85 | def restartTarget(self,params=None): | ||
86 | |||
87 | if oeRuntimeTest.tc.qemu.restart(params): | ||
88 | oeRuntimeTest.tc.target.host = oeRuntimeTest.tc.qemu.ip | ||
89 | else: | ||
90 | raise Exception("Restarting target failed") | ||
84 | 91 | ||
85 | 92 | ||
86 | def getmodule(pos=2): | 93 | def getmodule(pos=2): |
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 9ae618f4c9..6ee5b8577e 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -32,6 +32,10 @@ class QemuRunner: | |||
32 | self.boottime = boottime | 32 | self.boottime = boottime |
33 | self.runqemutime = runqemutime | 33 | self.runqemutime = runqemutime |
34 | 34 | ||
35 | self.create_socket() | ||
36 | |||
37 | def create_socket(self): | ||
38 | |||
35 | self.bootlog = '' | 39 | self.bootlog = '' |
36 | self.qemusock = None | 40 | self.qemusock = None |
37 | 41 | ||
@@ -137,21 +141,31 @@ class QemuRunner: | |||
137 | return self.is_alive() | 141 | return self.is_alive() |
138 | 142 | ||
139 | def kill(self): | 143 | def kill(self): |
144 | |||
145 | if self.runqemu: | ||
146 | bb.note("Sending SIGTERM to runqemu") | ||
147 | os.kill(-self.runqemu.pid,signal.SIGTERM) | ||
148 | endtime = time.time() + self.runqemutime | ||
149 | while self.runqemu.poll() is None and time.time() < endtime: | ||
150 | time.sleep(1) | ||
151 | if self.runqemu.poll() is None: | ||
152 | bb.note("Sending SIGKILL to runqemu") | ||
153 | os.kill(-self.runqemu.pid,signal.SIGKILL) | ||
154 | self.runqemu = None | ||
140 | if self.server_socket: | 155 | if self.server_socket: |
141 | self.server_socket.close() | 156 | self.server_socket.close() |
142 | self.server_socket = None | 157 | self.server_socket = None |
143 | if self.runqemu.pid: | ||
144 | os.kill(-self.runqemu.pid,signal.SIGTERM) | ||
145 | os.kill(-self.runqemu.pid,signal.SIGKILL) | ||
146 | self.runqemu.pid = None | ||
147 | self.qemupid = None | 158 | self.qemupid = None |
148 | self.ip = None | 159 | self.ip = None |
149 | 160 | ||
150 | def restart(self, qemuparams = None): | 161 | def restart(self, qemuparams = None): |
151 | if self.is_alive(): | 162 | bb.note("Restarting qemu process") |
163 | if self.runqemu.poll() is None: | ||
152 | self.kill() | 164 | self.kill() |
153 | bb.note("Qemu Restart required...") | 165 | self.create_socket() |
154 | return self.launch(qemuparams) | 166 | if self.launch(qemuparams): |
167 | return True | ||
168 | return False | ||
155 | 169 | ||
156 | def is_alive(self): | 170 | def is_alive(self): |
157 | qemu_child = self.find_child(str(self.runqemu.pid)) | 171 | qemu_child = self.find_child(str(self.runqemu.pid)) |