mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
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>
This commit is contained in:
parent
59791d1f49
commit
b588b80d66
|
@ -195,7 +195,8 @@ def testimage_main(d):
|
||||||
import oeqa.runtime
|
import oeqa.runtime
|
||||||
import time
|
import time
|
||||||
import signal
|
import signal
|
||||||
from oeqa.oetest import loadTests, runTests, get_test_suites, get_tests_list
|
from oeqa.oetest import loadTests, runTests, \
|
||||||
|
get_test_suites, get_tests_list, ImageTestContext
|
||||||
from oeqa.targetcontrol import get_target_controller
|
from oeqa.targetcontrol import get_target_controller
|
||||||
from oeqa.utils.dump import get_host_dumper
|
from oeqa.utils.dump import get_host_dumper
|
||||||
|
|
||||||
|
@ -212,48 +213,14 @@ def testimage_main(d):
|
||||||
testslist = get_tests_list(get_test_suites(d), d.getVar("BBPATH", True).split(':'))
|
testslist = get_tests_list(get_test_suites(d), d.getVar("BBPATH", True).split(':'))
|
||||||
testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"]
|
testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"]
|
||||||
|
|
||||||
tagexp = d.getVar("TEST_SUITES_TAGS", True)
|
|
||||||
|
|
||||||
# we need the host dumper in test context
|
# we need the host dumper in test context
|
||||||
host_dumper = get_host_dumper(d)
|
host_dumper = get_host_dumper(d)
|
||||||
|
|
||||||
# the robot dance
|
# the robot dance
|
||||||
target = get_target_controller(d)
|
target = get_target_controller(d)
|
||||||
|
|
||||||
class TestContext(object):
|
|
||||||
def __init__(self):
|
|
||||||
self.d = d
|
|
||||||
self.testslist = testslist
|
|
||||||
self.tagexp = tagexp
|
|
||||||
self.testsrequired = testsrequired
|
|
||||||
self.filesdir = os.path.join(os.path.dirname(os.path.abspath(oeqa.runtime.__file__)),"files")
|
|
||||||
self.target = target
|
|
||||||
self.host_dumper = host_dumper
|
|
||||||
self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split()
|
|
||||||
self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split()
|
|
||||||
manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + ".manifest")
|
|
||||||
nomanifest = d.getVar("IMAGE_NO_MANIFEST", True)
|
|
||||||
|
|
||||||
self.sigterm = False
|
|
||||||
self.origsigtermhandler = signal.getsignal(signal.SIGTERM)
|
|
||||||
signal.signal(signal.SIGTERM, self.sigterm_exception)
|
|
||||||
|
|
||||||
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 = ""
|
|
||||||
|
|
||||||
def sigterm_exception(self, signum, stackframe):
|
|
||||||
bb.warn("TestImage received SIGTERM, shutting down...")
|
|
||||||
self.sigterm = True
|
|
||||||
self.target.stop()
|
|
||||||
|
|
||||||
# test context
|
# test context
|
||||||
tc = TestContext()
|
tc = ImageTestContext(d, testslist, testsrequired, target, host_dumper)
|
||||||
|
|
||||||
# this is a dummy load of tests
|
# this is a dummy load of tests
|
||||||
# we are doing that to find compile errors in the tests themselves
|
# we are doing that to find compile errors in the tests themselves
|
||||||
|
@ -264,7 +231,6 @@ def testimage_main(d):
|
||||||
import traceback
|
import traceback
|
||||||
bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
|
bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
if export:
|
if export:
|
||||||
signal.signal(signal.SIGTERM, tc.origsigtermhandler)
|
signal.signal(signal.SIGTERM, tc.origsigtermhandler)
|
||||||
tc.origsigtermhandler = None
|
tc.origsigtermhandler = None
|
||||||
|
|
|
@ -13,7 +13,8 @@ def testsdk_main(d):
|
||||||
import oeqa.sdk
|
import oeqa.sdk
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
from oeqa.oetest import loadTests, runTests, get_test_suites, get_tests_list
|
from oeqa.oetest import loadTests, runTests, \
|
||||||
|
get_test_suites, get_tests_list, SDKTestContext
|
||||||
|
|
||||||
pn = d.getVar("PN", True)
|
pn = d.getVar("PN", True)
|
||||||
bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
|
bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
|
||||||
|
@ -28,29 +29,6 @@ def testsdk_main(d):
|
||||||
if not os.path.exists(tcname):
|
if not os.path.exists(tcname):
|
||||||
bb.fatal("The toolchain is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' .")
|
bb.fatal("The toolchain is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' .")
|
||||||
|
|
||||||
class TestContext(object):
|
|
||||||
def __init__(self):
|
|
||||||
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.sdktestdir = sdktestdir
|
|
||||||
self.sdkenv = sdkenv
|
|
||||||
self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split()
|
|
||||||
self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split()
|
|
||||||
manifest = d.getVar("SDK_TARGET_MANIFEST", True)
|
|
||||||
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 sdk image?\n%s" % e)
|
|
||||||
hostmanifest = d.getVar("SDK_HOST_MANIFEST", True)
|
|
||||||
try:
|
|
||||||
with open(hostmanifest) 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)
|
|
||||||
|
|
||||||
sdktestdir = d.expand("${WORKDIR}/testimage-sdk/")
|
sdktestdir = d.expand("${WORKDIR}/testimage-sdk/")
|
||||||
bb.utils.remove(sdktestdir, True)
|
bb.utils.remove(sdktestdir, True)
|
||||||
bb.utils.mkdirhier(sdktestdir)
|
bb.utils.mkdirhier(sdktestdir)
|
||||||
|
@ -63,8 +41,7 @@ def testsdk_main(d):
|
||||||
targets = glob.glob(d.expand(sdktestdir + "/tc/environment-setup-*"))
|
targets = glob.glob(d.expand(sdktestdir + "/tc/environment-setup-*"))
|
||||||
for sdkenv in targets:
|
for sdkenv in targets:
|
||||||
bb.plain("Testing %s" % sdkenv)
|
bb.plain("Testing %s" % sdkenv)
|
||||||
# test context
|
tc = SDKTestContext(d, testslist, testsrequired, sdktestdir, sdkenv)
|
||||||
tc = TestContext()
|
|
||||||
|
|
||||||
# this is a dummy load of tests
|
# this is a dummy load of tests
|
||||||
# we are doing that to find compile errors in the tests themselves
|
# we are doing that to find compile errors in the tests themselves
|
||||||
|
|
|
@ -11,11 +11,14 @@ import os, re, mmap
|
||||||
import unittest
|
import unittest
|
||||||
import inspect
|
import inspect
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import signal
|
||||||
try:
|
try:
|
||||||
import bb
|
import bb
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import oeqa.runtime
|
||||||
from oeqa.utils.decorators import LogResults, gettag, getResults
|
from oeqa.utils.decorators import LogResults, gettag, getResults
|
||||||
|
|
||||||
logger = logging.getLogger("BitBake")
|
logger = logging.getLogger("BitBake")
|
||||||
|
@ -326,3 +329,63 @@ def get_tests_list(testsuites, bbpath, type="runtime"):
|
||||||
add_auto_list(testpath)
|
add_auto_list(testpath)
|
||||||
|
|
||||||
return testslist
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user