diff options
author | Aníbal Limón <limon.anibal@gmail.com> | 2016-01-30 11:05:15 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-10 16:06:22 +0000 |
commit | b588b80d667052f2864d529793bf7db155b29f90 (patch) | |
tree | 2e5e5cb0b2f2d98a9afc66fae53868684b3f2ef6 /meta/classes/testimage.bbclass | |
parent | 59791d1f49591354c31c652af6c7c482461a878c (diff) | |
download | poky-b588b80d667052f2864d529793bf7db155b29f90.tar.gz |
testimage/testsdk: Modularize TestContext.
Move anonymous duplicated class TestContext from testimage/testsdk to
oeqa/oetest now we have two new classes ImageTestContext and
SDKTestContext with common code in TestContext class.
(From OE-Core rev: 593f2fdf6ee94c5f91761a669048da3598cbe3fa)
Signed-off-by: Aníbal Limón <limon.anibal@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/testimage.bbclass')
-rw-r--r-- | meta/classes/testimage.bbclass | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 6eea3f8a27..bdd6c9de6f 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass | |||
@@ -195,7 +195,8 @@ def testimage_main(d): | |||
195 | import oeqa.runtime | 195 | import oeqa.runtime |
196 | import time | 196 | import time |
197 | import signal | 197 | import signal |
198 | from oeqa.oetest import loadTests, runTests, get_test_suites, get_tests_list | 198 | from oeqa.oetest import loadTests, runTests, \ |
199 | get_test_suites, get_tests_list, ImageTestContext | ||
199 | from oeqa.targetcontrol import get_target_controller | 200 | from oeqa.targetcontrol import get_target_controller |
200 | from oeqa.utils.dump import get_host_dumper | 201 | from oeqa.utils.dump import get_host_dumper |
201 | 202 | ||
@@ -212,48 +213,14 @@ def testimage_main(d): | |||
212 | testslist = get_tests_list(get_test_suites(d), d.getVar("BBPATH", True).split(':')) | 213 | testslist = get_tests_list(get_test_suites(d), d.getVar("BBPATH", True).split(':')) |
213 | testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"] | 214 | testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"] |
214 | 215 | ||
215 | tagexp = d.getVar("TEST_SUITES_TAGS", True) | ||
216 | |||
217 | # we need the host dumper in test context | 216 | # we need the host dumper in test context |
218 | host_dumper = get_host_dumper(d) | 217 | host_dumper = get_host_dumper(d) |
219 | 218 | ||
220 | # the robot dance | 219 | # the robot dance |
221 | target = get_target_controller(d) | 220 | target = get_target_controller(d) |
222 | 221 | ||
223 | class TestContext(object): | ||
224 | def __init__(self): | ||
225 | self.d = d | ||
226 | self.testslist = testslist | ||
227 | self.tagexp = tagexp | ||
228 | self.testsrequired = testsrequired | ||
229 | self.filesdir = os.path.join(os.path.dirname(os.path.abspath(oeqa.runtime.__file__)),"files") | ||
230 | self.target = target | ||
231 | self.host_dumper = host_dumper | ||
232 | self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split() | ||
233 | self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split() | ||
234 | manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + ".manifest") | ||
235 | nomanifest = d.getVar("IMAGE_NO_MANIFEST", True) | ||
236 | |||
237 | self.sigterm = False | ||
238 | self.origsigtermhandler = signal.getsignal(signal.SIGTERM) | ||
239 | signal.signal(signal.SIGTERM, self.sigterm_exception) | ||
240 | |||
241 | if nomanifest is None or nomanifest != "1": | ||
242 | try: | ||
243 | with open(manifest) as f: | ||
244 | self.pkgmanifest = f.read() | ||
245 | except IOError as e: | ||
246 | bb.fatal("No package manifest file found. Did you build the image?\n%s" % e) | ||
247 | else: | ||
248 | self.pkgmanifest = "" | ||
249 | |||
250 | def sigterm_exception(self, signum, stackframe): | ||
251 | bb.warn("TestImage received SIGTERM, shutting down...") | ||
252 | self.sigterm = True | ||
253 | self.target.stop() | ||
254 | |||
255 | # test context | 222 | # test context |
256 | tc = TestContext() | 223 | tc = ImageTestContext(d, testslist, testsrequired, target, host_dumper) |
257 | 224 | ||
258 | # this is a dummy load of tests | 225 | # this is a dummy load of tests |
259 | # we are doing that to find compile errors in the tests themselves | 226 | # we are doing that to find compile errors in the tests themselves |
@@ -264,7 +231,6 @@ def testimage_main(d): | |||
264 | import traceback | 231 | import traceback |
265 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) | 232 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) |
266 | 233 | ||
267 | |||
268 | if export: | 234 | if export: |
269 | signal.signal(signal.SIGTERM, tc.origsigtermhandler) | 235 | signal.signal(signal.SIGTERM, tc.origsigtermhandler) |
270 | tc.origsigtermhandler = None | 236 | tc.origsigtermhandler = None |