summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-27 14:04:02 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-27 23:29:14 +0100
commit76d8c4e97c9dbf9e50d8e73805f77b8404a53caf (patch)
treee6eda6a3d87c413b8ce41cfe49ec39a39e58113a /meta/lib/oeqa/utils
parent01ccad15dab5743ab1cb0f566e48167672389fdd (diff)
downloadpoky-76d8c4e97c9dbf9e50d8e73805f77b8404a53caf.tar.gz
oeqa/selftest/imagefeatures: Use QemuTarget code
Create a runqemu function which uses the QemuTarget() code from oeqa.targetcontrol to setup the QEMU instance, with all of the added robustness that that gives us. To do this, a datastore is needed for the recipe in question (core-image-minimal) so we do the work needed to set this up. We then use this runqemu function within the imagefeatures tests instead of a hand-rolled implementation. We can then use SSHControl to run the SSH tests rather than rolling our own code to do that as an added bonus. Fixed and extended by Paul Eggleton <paul.eggleton@linux.intel.com>. Part of the fix for [YOCTO #7994]. (From OE-Core rev: 7d18d1169204ee80f1c00b35998f10fffaefa107) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/commands.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 1be7bedd40..50a08dc1fa 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -17,6 +17,7 @@ import logging
17from oeqa.utils import CommandError 17from oeqa.utils import CommandError
18from oeqa.utils import ftools 18from oeqa.utils import ftools
19import re 19import re
20import contextlib
20 21
21class Command(object): 22class Command(object):
22 def __init__(self, command, bg=False, timeout=None, data=None, **options): 23 def __init__(self, command, bg=False, timeout=None, data=None, **options):
@@ -173,3 +174,51 @@ def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec=
173 f.write('BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' % templayername) 174 f.write('BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' % templayername)
174 f.write('BBFILE_PRIORITY_%s = "%d"\n' % (templayername, priority)) 175 f.write('BBFILE_PRIORITY_%s = "%d"\n' % (templayername, priority))
175 f.write('BBFILE_PATTERN_IGNORE_EMPTY_%s = "1"\n' % templayername) 176 f.write('BBFILE_PATTERN_IGNORE_EMPTY_%s = "1"\n' % templayername)
177
178
179@contextlib.contextmanager
180def runqemu(pn, test):
181
182 import bb.tinfoil
183 import bb.build
184
185 tinfoil = bb.tinfoil.Tinfoil()
186 tinfoil.prepare(False)
187 try:
188 tinfoil.logger.setLevel(logging.WARNING)
189 import oeqa.targetcontrol
190 tinfoil.config_data.setVar("TEST_LOG_DIR", "${WORKDIR}/testimage")
191 tinfoil.config_data.setVar("TEST_QEMUBOOT_TIMEOUT", "90")
192 import oe.recipeutils
193 recipefile = oe.recipeutils.pn_to_recipe(tinfoil.cooker, pn)
194 recipedata = oe.recipeutils.parse_recipe(recipefile, [], tinfoil.config_data)
195
196 # The QemuRunner log is saved out, but we need to ensure it is at the right
197 # log level (and then ensure that since it's a child of the BitBake logger,
198 # we disable propagation so we don't then see the log events on the console)
199 logger = logging.getLogger('BitBake.QemuRunner')
200 logger.setLevel(logging.DEBUG)
201 logger.propagate = False
202 logdir = recipedata.getVar("TEST_LOG_DIR", True)
203
204 qemu = oeqa.targetcontrol.QemuTarget(recipedata)
205 finally:
206 # We need to shut down tinfoil early here in case we actually want
207 # to run tinfoil-using utilities with the running QEMU instance.
208 # Luckily QemuTarget doesn't need it after the constructor.
209 tinfoil.shutdown()
210
211 try:
212 qemu.deploy()
213 try:
214 qemu.start()
215 except bb.build.FuncFailed:
216 raise Exception('Failed to start QEMU - see the logs in %s' % logdir)
217
218 yield qemu
219
220 finally:
221 try:
222 qemu.stop()
223 except:
224 pass