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/lib/oeqa/oetest.py | |
| 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/lib/oeqa/oetest.py')
| -rw-r--r-- | meta/lib/oeqa/oetest.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py index 6470129180..9951a6f40e 100644 --- a/meta/lib/oeqa/oetest.py +++ b/meta/lib/oeqa/oetest.py | |||
| @@ -11,11 +11,14 @@ import os, re, mmap | |||
| 11 | import unittest | 11 | import unittest |
| 12 | import inspect | 12 | import inspect |
| 13 | import subprocess | 13 | import subprocess |
| 14 | import signal | ||
| 14 | try: | 15 | try: |
| 15 | import bb | 16 | import bb |
| 16 | except ImportError: | 17 | except ImportError: |
| 17 | pass | 18 | pass |
| 18 | import logging | 19 | import logging |
| 20 | |||
| 21 | import oeqa.runtime | ||
| 19 | from oeqa.utils.decorators import LogResults, gettag, getResults | 22 | from oeqa.utils.decorators import LogResults, gettag, getResults |
| 20 | 23 | ||
| 21 | logger = logging.getLogger("BitBake") | 24 | logger = logging.getLogger("BitBake") |
| @@ -326,3 +329,63 @@ def get_tests_list(testsuites, bbpath, type="runtime"): | |||
| 326 | add_auto_list(testpath) | 329 | add_auto_list(testpath) |
| 327 | 330 | ||
| 328 | return testslist | 331 | return testslist |
| 332 | |||
| 333 | class TestContext(object): | ||
| 334 | def __init__(self, d, testslist, testsrequired): | ||
| 335 | self.d = d | ||
| 336 | self.testslist = testslist | ||
| 337 | self.testsrequired = testsrequired | ||
| 338 | |||
| 339 | self.filesdir = os.path.join(os.path.dirname(os.path.abspath( | ||
| 340 | oeqa.runtime.__file__)), "files") | ||
| 341 | self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split() | ||
| 342 | self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split() | ||
| 343 | |||
| 344 | class ImageTestContext(TestContext): | ||
| 345 | def __init__(self, d, testslist, testsrequired, target, host_dumper): | ||
| 346 | super(ImageTestContext, self).__init__(d, testslist, testsrequired) | ||
| 347 | |||
| 348 | self.tagexp = d.getVar("TEST_SUITES_TAGS", True) | ||
| 349 | |||
| 350 | self.target = target | ||
| 351 | self.host_dumper = host_dumper | ||
| 352 | |||
| 353 | manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), | ||
| 354 | d.getVar("IMAGE_LINK_NAME", True) + ".manifest") | ||
| 355 | nomanifest = d.getVar("IMAGE_NO_MANIFEST", True) | ||
| 356 | if nomanifest is None or nomanifest != "1": | ||
| 357 | try: | ||
| 358 | with open(manifest) as f: | ||
| 359 | self.pkgmanifest = f.read() | ||
| 360 | except IOError as e: | ||
| 361 | bb.fatal("No package manifest file found. Did you build the image?\n%s" % e) | ||
| 362 | else: | ||
| 363 | self.pkgmanifest = "" | ||
| 364 | |||
| 365 | self.sigterm = False | ||
| 366 | self.origsigtermhandler = signal.getsignal(signal.SIGTERM) | ||
| 367 | signal.signal(signal.SIGTERM, self._sigterm_exception) | ||
| 368 | |||
| 369 | def _sigterm_exception(self, signum, stackframe): | ||
| 370 | bb.warn("TestImage received SIGTERM, shutting down...") | ||
| 371 | self.sigterm = True | ||
| 372 | self.target.stop() | ||
| 373 | |||
| 374 | class SDKTestContext(TestContext): | ||
| 375 | def __init__(self, d, testslist, testsrequired, sdktestdir, sdkenv): | ||
| 376 | super(SDKTestContext, self).__init__(d, testslist, testsrequired) | ||
| 377 | |||
| 378 | self.sdktestdir = sdktestdir | ||
| 379 | self.sdkenv = sdkenv | ||
| 380 | |||
| 381 | try: | ||
| 382 | with open(d.getVar("SDK_TARGET_MANIFEST", True)) as f: | ||
| 383 | self.pkgmanifest = f.read() | ||
| 384 | except IOError as e: | ||
| 385 | bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e) | ||
| 386 | |||
| 387 | try: | ||
| 388 | with open(d.getVar("SDK_HOST_MANIFEST", True)) as f: | ||
| 389 | self.hostpkgmanifest = f.read() | ||
| 390 | except IOError as e: | ||
| 391 | bb.fatal("No host package manifest file found. Did you build the sdk image?\n%s" % e) | ||
