summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorAníbal Limón <limon.anibal@gmail.com>2016-01-30 11:05:15 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 16:06:22 +0000
commitb588b80d667052f2864d529793bf7db155b29f90 (patch)
tree2e5e5cb0b2f2d98a9afc66fae53868684b3f2ef6 /meta/lib/oeqa
parent59791d1f49591354c31c652af6c7c482461a878c (diff)
downloadpoky-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')
-rw-r--r--meta/lib/oeqa/oetest.py63
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
11import unittest 11import unittest
12import inspect 12import inspect
13import subprocess 13import subprocess
14import signal
14try: 15try:
15 import bb 16 import bb
16except ImportError: 17except ImportError:
17 pass 18 pass
18import logging 19import logging
20
21import oeqa.runtime
19from oeqa.utils.decorators import LogResults, gettag, getResults 22from oeqa.utils.decorators import LogResults, gettag, getResults
20 23
21logger = logging.getLogger("BitBake") 24logger = 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
333class 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
344class 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
374class 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)