diff options
Diffstat (limited to 'import-layers/yocto-poky/meta/lib/oeqa/oetest.py')
-rw-r--r-- | import-layers/yocto-poky/meta/lib/oeqa/oetest.py | 164 |
1 files changed, 29 insertions, 135 deletions
diff --git a/import-layers/yocto-poky/meta/lib/oeqa/oetest.py b/import-layers/yocto-poky/meta/lib/oeqa/oetest.py index 95d3bf72fc..f7171260e7 100644 --- a/import-layers/yocto-poky/meta/lib/oeqa/oetest.py +++ b/import-layers/yocto-poky/meta/lib/oeqa/oetest.py @@ -27,7 +27,6 @@ try: except ImportError: pass from oeqa.utils.decorators import LogResults, gettag, getResults -from oeqa.utils import avoid_paths_in_environ logger = logging.getLogger("BitBake") @@ -107,7 +106,7 @@ class oeRuntimeTest(oeTest): pass def tearDown(self): - # Unistall packages in the DUT + # Uninstall packages in the DUT self.tc.install_uninstall_packages(self.id(), False) res = getResults() @@ -129,48 +128,6 @@ class oeRuntimeTest(oeTest): def tearDownLocal(self): pass - #TODO: use package_manager.py to install packages on any type of image - def install_packages(self, packagelist): - for package in packagelist: - (status, result) = self.target.run("smart install -y "+package) - if status != 0: - return status - -class OETestCalledProcessError(subprocess.CalledProcessError): - def __str__(self): - if hasattr(self, "stderr"): - return "Command '%s' returned non-zero exit status %d with output %s and stderr %s" % (self.cmd, self.returncode, self.output, self.stderr) - else: - return "Command '%s' returned non-zero exit status %d with output %s" % (self.cmd, self.returncode, self.output) - -subprocess.CalledProcessError = OETestCalledProcessError - -class oeSDKTest(oeTest): - def __init__(self, methodName='runTest'): - self.sdktestdir = oeSDKTest.tc.sdktestdir - super(oeSDKTest, self).__init__(methodName) - - @classmethod - def hasHostPackage(self, pkg): - if re.search(pkg, oeTest.tc.hostpkgmanifest): - return True - return False - - def _run(self, cmd): - return subprocess.check_output(". %s > /dev/null; %s;" % (self.tc.sdkenv, cmd), shell=True, stderr=subprocess.STDOUT).decode("utf-8") - -class oeSDKExtTest(oeSDKTest): - def _run(self, cmd): - # extensible sdk shows a warning if found bitbake in the path - # because can cause contamination, i.e. use devtool from - # poky/scripts instead of eSDK one. - env = os.environ.copy() - paths_to_avoid = ['bitbake/bin', 'poky/scripts'] - env['PATH'] = avoid_paths_in_environ(paths_to_avoid) - - return subprocess.check_output(". %s > /dev/null;"\ - " %s;" % (self.tc.sdkenv, cmd), stderr=subprocess.STDOUT, shell=True, env=env).decode("utf-8") - def getmodule(pos=2): # stack returns a list of tuples containg frame information # First element of the list the is current frame, caller is 1 @@ -221,15 +178,16 @@ class TestContext(object): path = [os.path.dirname(os.path.abspath(__file__))] extrapath = "" else: - path = d.getVar("BBPATH", True).split(':') + path = d.getVar("BBPATH").split(':') extrapath = "lib/oeqa" self.testslist = self._get_tests_list(path, extrapath) self.testsrequired = self._get_test_suites_required() self.filesdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "runtime/files") - self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split() - self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split() + self.corefilesdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "files") + self.imagefeatures = d.getVar("IMAGE_FEATURES").split() + self.distrofeatures = d.getVar("DISTRO_FEATURES").split() # get testcase list from specified file # if path is a relative path, then relative to build/conf/ @@ -406,9 +364,9 @@ class RuntimeTestContext(TestContext): self.target = target self.pkgmanifest = {} - manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), - d.getVar("IMAGE_LINK_NAME", True) + ".manifest") - nomanifest = d.getVar("IMAGE_NO_MANIFEST", True) + manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), + d.getVar("IMAGE_LINK_NAME") + ".manifest") + nomanifest = d.getVar("IMAGE_NO_MANIFEST") if nomanifest is None or nomanifest != "1": try: with open(manifest) as f: @@ -424,19 +382,19 @@ class RuntimeTestContext(TestContext): def _get_test_suites(self): testsuites = [] - manifests = (self.d.getVar("TEST_SUITES_MANIFEST", True) or '').split() + manifests = (self.d.getVar("TEST_SUITES_MANIFEST") or '').split() if manifests: for manifest in manifests: testsuites.extend(self._read_testlist(manifest, - self.d.getVar("TOPDIR", True)).split()) + self.d.getVar("TOPDIR")).split()) else: - testsuites = self.d.getVar("TEST_SUITES", True).split() + testsuites = self.d.getVar("TEST_SUITES").split() return testsuites def _get_test_suites_required(self): - return [t for t in self.d.getVar("TEST_SUITES", True).split() if t != "auto"] + return [t for t in self.d.getVar("TEST_SUITES").split() if t != "auto"] def loadTests(self): super(RuntimeTestContext, self).loadTests() @@ -449,10 +407,10 @@ class RuntimeTestContext(TestContext): """ modules = self.getTestModules() - bbpaths = self.d.getVar("BBPATH", True).split(":") + bbpaths = self.d.getVar("BBPATH").split(":") - shutil.rmtree(self.d.getVar("TEST_EXTRACTED_DIR", True)) - shutil.rmtree(self.d.getVar("TEST_PACKAGED_DIR", True)) + shutil.rmtree(self.d.getVar("TEST_EXTRACTED_DIR")) + shutil.rmtree(self.d.getVar("TEST_PACKAGED_DIR")) for module in modules: json_file = self._getJsonFile(module) if json_file: @@ -466,8 +424,8 @@ class RuntimeTestContext(TestContext): import oe.path - extracted_path = self.d.getVar("TEST_EXTRACTED_DIR", True) - packaged_path = self.d.getVar("TEST_PACKAGED_DIR", True) + extracted_path = self.d.getVar("TEST_EXTRACTED_DIR") + packaged_path = self.d.getVar("TEST_PACKAGED_DIR") for key,value in needed_packages.items(): packages = () @@ -548,7 +506,7 @@ class RuntimeTestContext(TestContext): from oeqa.utils.package_manager import get_package_manager - pkg_path = os.path.join(self.d.getVar("TEST_INSTALL_TMP_DIR", True), pkg) + pkg_path = os.path.join(self.d.getVar("TEST_INSTALL_TMP_DIR"), pkg) pm = get_package_manager(self.d, pkg_path) extract_dir = pm.extract(pkg) shutil.rmtree(pkg_path) @@ -562,8 +520,8 @@ class RuntimeTestContext(TestContext): from oeqa.utils.package_manager import get_package_manager - pkg_path = os.path.join(self.d.getVar("TEST_INSTALL_TMP_DIR", True), pkg) - dst_dir = self.d.getVar("TEST_PACKAGED_DIR", True) + pkg_path = os.path.join(self.d.getVar("TEST_INSTALL_TMP_DIR"), pkg) + dst_dir = self.d.getVar("TEST_PACKAGED_DIR") pm = get_package_manager(self.d, pkg_path) pkg_info = pm.package_info(pkg) file_path = pkg_info[pkg]["filepath"] @@ -572,7 +530,7 @@ class RuntimeTestContext(TestContext): def install_uninstall_packages(self, test_id, pkg_dir, install): """ - Check if the test requires a package and Install/Unistall it in the DUT + Check if the test requires a package and Install/Uninstall it in the DUT """ test = test_id.split(".")[4] @@ -585,7 +543,7 @@ class RuntimeTestContext(TestContext): def _install_uninstall_packages(self, needed_packages, pkg_dir, install=True): """ - Install/Unistall packages in the DUT without using a package manager + Install/Uninstall packages in the DUT without using a package manager """ if isinstance(needed_packages, dict): @@ -603,7 +561,7 @@ class RuntimeTestContext(TestContext): if install and extract: self.target.connection.copy_dir_to(src_dir, "/") - # Unistall package + # Uninstall package elif not install and rm: self.target.connection.delete_dir_structure(src_dir, "/") @@ -611,7 +569,7 @@ class ImageTestContext(RuntimeTestContext): def __init__(self, d, target, host_dumper): super(ImageTestContext, self).__init__(d, target) - self.tagexp = d.getVar("TEST_SUITES_TAGS", True) + self.tagexp = d.getVar("TEST_SUITES_TAGS") self.host_dumper = host_dumper @@ -626,10 +584,10 @@ class ImageTestContext(RuntimeTestContext): def install_uninstall_packages(self, test_id, install=True): """ - Check if the test requires a package and Install/Unistall it in the DUT + Check if the test requires a package and Install/Uninstall it in the DUT """ - pkg_dir = self.d.getVar("TEST_EXTRACTED_DIR", True) + pkg_dir = self.d.getVar("TEST_EXTRACTED_DIR") super(ImageTestContext, self).install_uninstall_packages(test_id, pkg_dir, install) class ExportTestContext(RuntimeTestContext): @@ -643,80 +601,16 @@ class ExportTestContext(RuntimeTestContext): super(ExportTestContext, self).__init__(d, target, exported) tag = parsedArgs.get("tag", None) - self.tagexp = tag if tag != None else d.getVar("TEST_SUITES_TAGS", True) + self.tagexp = tag if tag != None else d.getVar("TEST_SUITES_TAGS") self.sigterm = None def install_uninstall_packages(self, test_id, install=True): """ - Check if the test requires a package and Install/Unistall it in the DUT + Check if the test requires a package and Install/Uninstall it in the DUT """ export_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) - extracted_dir = self.d.getVar("TEST_EXPORT_EXTRACTED_DIR", True) + extracted_dir = self.d.getVar("TEST_EXPORT_EXTRACTED_DIR") pkg_dir = os.path.join(export_dir, extracted_dir) super(ExportTestContext, self).install_uninstall_packages(test_id, pkg_dir, install) - -class SDKTestContext(TestContext): - def __init__(self, d, sdktestdir, sdkenv, tcname, *args): - super(SDKTestContext, self).__init__(d) - - self.sdktestdir = sdktestdir - self.sdkenv = sdkenv - self.tcname = tcname - - if not hasattr(self, 'target_manifest'): - self.target_manifest = d.getVar("SDK_TARGET_MANIFEST", True) - try: - self.pkgmanifest = {} - with open(self.target_manifest) as f: - for line in f: - (pkg, arch, version) = line.strip().split() - self.pkgmanifest[pkg] = (version, arch) - except IOError as e: - bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e) - - if not hasattr(self, 'host_manifest'): - self.host_manifest = d.getVar("SDK_HOST_MANIFEST", True) - try: - with open(self.host_manifest) 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) - - 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(SDKTestContext): - def __init__(self, d, sdktestdir, sdkenv, tcname, *args): - self.target_manifest = d.getVar("SDK_EXT_TARGET_MANIFEST", True) - self.host_manifest = d.getVar("SDK_EXT_HOST_MANIFEST", True) - if args: - self.cm = args[0] # Compatibility mode for run SDK tests - else: - self.cm = False - - super(SDKExtTestContext, self).__init__(d, sdktestdir, sdkenv, tcname) - - self.sdkextfilesdir = os.path.join(os.path.dirname(os.path.abspath( - oeqa.sdkext.__file__)), "files") - - def _get_test_namespace(self): - if self.cm: - return "sdk" - else: - 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"] |