aboutsummaryrefslogtreecommitdiffstats
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 15:51:03 +0000
commit593f2fdf6ee94c5f91761a669048da3598cbe3fa (patch)
tree6670e89ac289e7cdb846cb2c62d9556959ab89bc /meta/lib/oeqa
parent6d65712660a314916ebee5abc9990404216dbe00 (diff)
downloadopenembedded-core-593f2fdf6ee94c5f91761a669048da3598cbe3fa.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. Signed-off-by: Aníbal Limón <limon.anibal@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
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
import unittest
import inspect
import subprocess
+import signal
try:
import bb
except ImportError:
pass
import logging
+
+import oeqa.runtime
from oeqa.utils.decorators import LogResults, gettag, getResults
logger = logging.getLogger("BitBake")
@@ -326,3 +329,63 @@ def get_tests_list(testsuites, bbpath, type="runtime"):
add_auto_list(testpath)
return testslist
+
+class TestContext(object):
+ def __init__(self, d, testslist, testsrequired):
+ self.d = d
+ self.testslist = testslist
+ self.testsrequired = testsrequired
+
+ self.filesdir = os.path.join(os.path.dirname(os.path.abspath(
+ oeqa.runtime.__file__)), "files")
+ self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split()
+ self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split()
+
+class ImageTestContext(TestContext):
+ def __init__(self, d, testslist, testsrequired, target, host_dumper):
+ super(ImageTestContext, self).__init__(d, testslist, testsrequired)
+
+ self.tagexp = d.getVar("TEST_SUITES_TAGS", True)
+
+ self.target = target
+ self.host_dumper = host_dumper
+
+ manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),
+ d.getVar("IMAGE_LINK_NAME", True) + ".manifest")
+ nomanifest = d.getVar("IMAGE_NO_MANIFEST", True)
+ if nomanifest is None or nomanifest != "1":
+ try:
+ with open(manifest) as f:
+ self.pkgmanifest = f.read()
+ except IOError as e:
+ bb.fatal("No package manifest file found. Did you build the image?\n%s" % e)
+ else:
+ self.pkgmanifest = ""
+
+ self.sigterm = False
+ self.origsigtermhandler = signal.getsignal(signal.SIGTERM)
+ signal.signal(signal.SIGTERM, self._sigterm_exception)
+
+ def _sigterm_exception(self, signum, stackframe):
+ bb.warn("TestImage received SIGTERM, shutting down...")
+ self.sigterm = True
+ self.target.stop()
+
+class SDKTestContext(TestContext):
+ def __init__(self, d, testslist, testsrequired, sdktestdir, sdkenv):
+ super(SDKTestContext, self).__init__(d, testslist, testsrequired)
+
+ self.sdktestdir = sdktestdir
+ self.sdkenv = sdkenv
+
+ try:
+ with open(d.getVar("SDK_TARGET_MANIFEST", True)) as f:
+ self.pkgmanifest = f.read()
+ except IOError as e:
+ bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e)
+
+ try:
+ with open(d.getVar("SDK_HOST_MANIFEST", True)) as f:
+ self.hostpkgmanifest = f.read()
+ except IOError as e:
+ bb.fatal("No host package manifest file found. Did you build the sdk image?\n%s" % e)