mirror of
https://git.yoctoproject.org/poky
synced 2026-09-24 22:36:21 +02:00
testimage/testsdk: Move get test suites routine inside TestContext.
In order to provide better abstraction move functions to get the test suite inside the TestContext. (From OE-Core rev: 552285688441330440bd1bc138aeaea87549024a) 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:
committed by
Richard Purdie
parent
b588b80d66
commit
8009418d55
@@ -195,8 +195,7 @@ def testimage_main(d):
|
|||||||
import oeqa.runtime
|
import oeqa.runtime
|
||||||
import time
|
import time
|
||||||
import signal
|
import signal
|
||||||
from oeqa.oetest import loadTests, runTests, \
|
from oeqa.oetest import loadTests, runTests, ImageTestContext
|
||||||
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
|
||||||
|
|
||||||
@@ -207,12 +206,6 @@ def testimage_main(d):
|
|||||||
bb.utils.remove(d.getVar("TEST_EXPORT_DIR", True), recurse=True)
|
bb.utils.remove(d.getVar("TEST_EXPORT_DIR", True), recurse=True)
|
||||||
bb.utils.mkdirhier(d.getVar("TEST_EXPORT_DIR", True))
|
bb.utils.mkdirhier(d.getVar("TEST_EXPORT_DIR", True))
|
||||||
|
|
||||||
# tests in TEST_SUITES become required tests
|
|
||||||
# they won't be skipped even if they aren't suitable for a image (like xorg for minimal)
|
|
||||||
# testslist is what we'll actually pass to the unittest loader
|
|
||||||
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"]
|
|
||||||
|
|
||||||
# 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)
|
||||||
|
|
||||||
@@ -220,7 +213,7 @@ def testimage_main(d):
|
|||||||
target = get_target_controller(d)
|
target = get_target_controller(d)
|
||||||
|
|
||||||
# test context
|
# test context
|
||||||
tc = ImageTestContext(d, testslist, testsrequired, target, host_dumper)
|
tc = ImageTestContext(d, 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
|
||||||
|
|||||||
@@ -13,18 +13,11 @@ def testsdk_main(d):
|
|||||||
import oeqa.sdk
|
import oeqa.sdk
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
from oeqa.oetest import loadTests, runTests, \
|
from oeqa.oetest import loadTests, runTests, SDKTestContext
|
||||||
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))
|
||||||
|
|
||||||
# tests in TEST_SUITES become required tests
|
|
||||||
# they won't be skipped even if they aren't suitable.
|
|
||||||
# testslist is what we'll actually pass to the unittest loader
|
|
||||||
testslist = get_tests_list(get_test_suites(d, "sdk"), d.getVar("BBPATH", True).split(':'), "sdk")
|
|
||||||
testsrequired = [t for t in (d.getVar("TEST_SUITES_SDK", True) or "auto").split() if t != "auto"]
|
|
||||||
|
|
||||||
tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
|
tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
|
||||||
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' .")
|
||||||
@@ -41,7 +34,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)
|
||||||
tc = SDKTestContext(d, testslist, testsrequired, sdktestdir, sdkenv)
|
tc = SDKTestContext(d, sdktestdir, sdkenv)
|
||||||
|
|
||||||
# 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
|
||||||
@@ -94,14 +87,6 @@ def testsdkext_main(d):
|
|||||||
pn = d.getVar("PN", True)
|
pn = d.getVar("PN", True)
|
||||||
bb.utils.mkdirhier(d.getVar("TEST_LOG_SDKEXT_DIR", True))
|
bb.utils.mkdirhier(d.getVar("TEST_LOG_SDKEXT_DIR", True))
|
||||||
|
|
||||||
# tests in TEST_SUITES become required tests
|
|
||||||
# they won't be skipped even if they aren't suitable.
|
|
||||||
# testslist is what we'll actually pass to the unittest loader
|
|
||||||
testslist = get_tests_list(get_test_suites(d, "sdkext"),
|
|
||||||
d.getVar("BBPATH", True).split(':'), "sdkext")
|
|
||||||
testsrequired = [t for t in (d.getVar("TEST_SUITES_SDKEXT", True) or \
|
|
||||||
"auto").split() if t != "auto"]
|
|
||||||
|
|
||||||
tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh")
|
tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh")
|
||||||
if not os.path.exists(tcname):
|
if not os.path.exists(tcname):
|
||||||
bb.fatal("The toolchain ext is not built. Build it before running the" \
|
bb.fatal("The toolchain ext is not built. Build it before running the" \
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ def getVar(obj):
|
|||||||
def checkTags(tc, tagexp):
|
def checkTags(tc, tagexp):
|
||||||
return eval(tagexp, None, getVar(tc))
|
return eval(tagexp, None, getVar(tc))
|
||||||
|
|
||||||
|
|
||||||
def filterByTagExp(testsuite, tagexp):
|
def filterByTagExp(testsuite, tagexp):
|
||||||
if not tagexp:
|
if not tagexp:
|
||||||
return testsuite
|
return testsuite
|
||||||
@@ -254,9 +253,22 @@ def skipModuleUnless(cond, reason):
|
|||||||
if not cond:
|
if not cond:
|
||||||
skipModule(reason, 3)
|
skipModule(reason, 3)
|
||||||
|
|
||||||
|
class TestContext(object):
|
||||||
|
def __init__(self, d):
|
||||||
|
self.d = d
|
||||||
|
|
||||||
|
self.testsuites = self._get_test_suites()
|
||||||
|
self.testslist = self._get_tests_list(d.getVar("BBPATH", True).split(':'))
|
||||||
|
self.testsrequired = self._get_test_suites_required()
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
# get testcase list from specified file
|
# get testcase list from specified file
|
||||||
# if path is a relative path, then relative to build/conf/
|
# if path is a relative path, then relative to build/conf/
|
||||||
def read_testlist(fpath, builddir):
|
def _read_testlist(self, fpath, builddir):
|
||||||
if not os.path.isabs(fpath):
|
if not os.path.isabs(fpath):
|
||||||
fpath = os.path.join(builddir, "conf", fpath)
|
fpath = os.path.join(builddir, "conf", fpath)
|
||||||
if not os.path.exists(fpath):
|
if not os.path.exists(fpath):
|
||||||
@@ -268,33 +280,15 @@ def read_testlist(fpath, builddir):
|
|||||||
tcs.append(line)
|
tcs.append(line)
|
||||||
return " ".join(tcs)
|
return " ".join(tcs)
|
||||||
|
|
||||||
# get test suites, returns test suites based on d variables
|
|
||||||
def get_test_suites(d, type='runtime'):
|
|
||||||
testsuites = []
|
|
||||||
|
|
||||||
if type == "sdk":
|
|
||||||
testsuites = (d.getVar("TEST_SUITES_SDK", True) or "auto").split()
|
|
||||||
elif type == "sdkext":
|
|
||||||
testsuites = (d.getVar("TEST_SUITES_SDKEXT", True) or "auto").split()
|
|
||||||
else:
|
|
||||||
manifests = (d.getVar("TEST_SUITES_MANIFEST", True) or '').split()
|
|
||||||
if manifests:
|
|
||||||
for manifest in manifests:
|
|
||||||
testsuites.extend(read_testlist(manifest,
|
|
||||||
d.getVar("TOPDIR", True)).split())
|
|
||||||
|
|
||||||
else:
|
|
||||||
testsuites = d.getVar("TEST_SUITES", True).split()
|
|
||||||
|
|
||||||
return testsuites
|
|
||||||
|
|
||||||
# return test list by type also filter if TEST_SUITES is specified
|
# return test list by type also filter if TEST_SUITES is specified
|
||||||
def get_tests_list(testsuites, bbpath, type="runtime"):
|
def _get_tests_list(self, bbpath):
|
||||||
testslist = []
|
testslist = []
|
||||||
|
|
||||||
|
type = self._get_test_namespace()
|
||||||
|
|
||||||
# This relies on lib/ under each directory in BBPATH being added to sys.path
|
# This relies on lib/ under each directory in BBPATH being added to sys.path
|
||||||
# (as done by default in base.bbclass)
|
# (as done by default in base.bbclass)
|
||||||
for testname in testsuites:
|
for testname in self.testsuites:
|
||||||
if testname != "auto":
|
if testname != "auto":
|
||||||
if testname.startswith("oeqa."):
|
if testname.startswith("oeqa."):
|
||||||
testslist.append(testname)
|
testslist.append(testname)
|
||||||
@@ -312,7 +306,7 @@ def get_tests_list(testsuites, bbpath, type="runtime"):
|
|||||||
if not found:
|
if not found:
|
||||||
bb.fatal('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname)
|
bb.fatal('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname)
|
||||||
|
|
||||||
if "auto" in testsuites:
|
if "auto" in self.testsuites:
|
||||||
def add_auto_list(path):
|
def add_auto_list(path):
|
||||||
if not os.path.exists(os.path.join(path, '__init__.py')):
|
if not os.path.exists(os.path.join(path, '__init__.py')):
|
||||||
bb.fatal('Tests directory %s exists but is missing __init__.py' % path)
|
bb.fatal('Tests directory %s exists but is missing __init__.py' % path)
|
||||||
@@ -330,20 +324,9 @@ def get_tests_list(testsuites, bbpath, type="runtime"):
|
|||||||
|
|
||||||
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):
|
class ImageTestContext(TestContext):
|
||||||
def __init__(self, d, testslist, testsrequired, target, host_dumper):
|
def __init__(self, d, target, host_dumper):
|
||||||
super(ImageTestContext, self).__init__(d, testslist, testsrequired)
|
super(ImageTestContext, self).__init__(d)
|
||||||
|
|
||||||
self.tagexp = d.getVar("TEST_SUITES_TAGS", True)
|
self.tagexp = d.getVar("TEST_SUITES_TAGS", True)
|
||||||
|
|
||||||
@@ -371,9 +354,29 @@ class ImageTestContext(TestContext):
|
|||||||
self.sigterm = True
|
self.sigterm = True
|
||||||
self.target.stop()
|
self.target.stop()
|
||||||
|
|
||||||
|
def _get_test_namespace(self):
|
||||||
|
return "runtime"
|
||||||
|
|
||||||
|
def _get_test_suites(self):
|
||||||
|
testsuites = []
|
||||||
|
|
||||||
|
manifests = (self.d.getVar("TEST_SUITES_MANIFEST", True) or '').split()
|
||||||
|
if manifests:
|
||||||
|
for manifest in manifests:
|
||||||
|
testsuites.extend(self._read_testlist(manifest,
|
||||||
|
self.d.getVar("TOPDIR", True)).split())
|
||||||
|
|
||||||
|
else:
|
||||||
|
testsuites = self.d.getVar("TEST_SUITES", True).split()
|
||||||
|
|
||||||
|
return testsuites
|
||||||
|
|
||||||
|
def _get_test_suites_required(self):
|
||||||
|
return [t for t in self.d.getVar("TEST_SUITES", True).split() if t != "auto"]
|
||||||
|
|
||||||
class SDKTestContext(TestContext):
|
class SDKTestContext(TestContext):
|
||||||
def __init__(self, d, testslist, testsrequired, sdktestdir, sdkenv):
|
def __init__(self, d, sdktestdir, sdkenv):
|
||||||
super(SDKTestContext, self).__init__(d, testslist, testsrequired)
|
super(SDKTestContext, self).__init__(d)
|
||||||
|
|
||||||
self.sdktestdir = sdktestdir
|
self.sdktestdir = sdktestdir
|
||||||
self.sdkenv = sdkenv
|
self.sdkenv = sdkenv
|
||||||
@@ -389,3 +392,24 @@ class SDKTestContext(TestContext):
|
|||||||
self.hostpkgmanifest = f.read()
|
self.hostpkgmanifest = f.read()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
bb.fatal("No host package manifest file found. Did you build the sdk image?\n%s" % e)
|
bb.fatal("No host package manifest file found. Did you build the sdk image?\n%s" % e)
|
||||||
|
|
||||||
|
def _get_test_namespace(self):
|
||||||
|
return "sdk"
|
||||||
|
|
||||||
|
def _get_test_suites(self):
|
||||||
|
return (self.d.getVar("TEST_SUITES_SDK", True) or "auto").split()
|
||||||
|
|
||||||
|
def _get_test_suites_required(self):
|
||||||
|
return [t for t in (self.d.getVar("TEST_SUITES_SDK", True) or \
|
||||||
|
"auto").split() if t != "auto"]
|
||||||
|
|
||||||
|
class SDKExtTestContext(TestContext):
|
||||||
|
def _get_test_namespace(self):
|
||||||
|
return "sdkext"
|
||||||
|
|
||||||
|
def _get_test_suites(self):
|
||||||
|
return (self.d.getVar("TEST_SUITES_SDK_EXT", True) or "auto").split()
|
||||||
|
|
||||||
|
def _get_test_suites_required(self):
|
||||||
|
return [t for t in (self.d.getVar("TEST_SUITES_SDK_EXT", True) or \
|
||||||
|
"auto").split() if t != "auto"]
|
||||||
|
|||||||
Reference in New Issue
Block a user