aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2016-05-24 12:44:14 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-30 09:30:32 +0100
commit90d585f59f217f23694a9b02a73b79d18dfdb579 (patch)
treec24a80c48f6a230172fe095177ad4f5d1acb6cbd
parent1f24ef9a339a2ad34e010f39aa93abdc8d085c85 (diff)
downloadopenembedded-core-contrib-90d585f59f217f23694a9b02a73b79d18dfdb579.tar.gz
oetest.py: Add extract_packages() to RuntimeTestContext class
This new method extracts the content of package (RPM, DEB, or IPK) to a directory inside of WORKDIR. The extraction is needed for later install in the DUTs without using a package manager. [YOCTO #8694] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r--meta/lib/oeqa/oetest.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 7abd850f63..8dd494a064 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -12,6 +12,7 @@ import unittest
import inspect
import subprocess
import signal
+import shutil
try:
import bb
except ImportError:
@@ -264,6 +265,22 @@ class TestContext(object):
return testslist
+ def getTestModules(self):
+ """
+ Returns all the test modules in the testlist.
+ """
+
+ import pkgutil
+
+ modules = []
+ for test in self.testslist:
+ if re.search("\w+\.\w+\.test_\S+", test):
+ test = '.'.join(t.split('.')[:3])
+ module = pkgutil.get_loader(test)
+ modules.append(module)
+
+ return modules
+
def getTests(self, test):
'''Return all individual tests executed when running the suite.'''
# Unfortunately unittest does not have an API for this, so we have
@@ -385,6 +402,44 @@ class RuntimeTestContext(TestContext):
if oeTest.hasPackage("procps"):
oeRuntimeTest.pscmd = "ps -ef"
+ def extract_packages(self):
+ """
+ Find and extract packages that will be needed during runtime.
+ """
+
+ needed_packages = {}
+ extracted_path = self.d.getVar("TEST_EXTRACTED_DIR", True)
+ modules = self.getTestModules()
+ bbpaths = self.d.getVar("BBPATH", True).split(":")
+
+ for module in modules:
+ json_file = self._getJsonFile(module)
+ if json_file:
+ needed_packages = self._getNeededPackages(json_file)
+
+ for key,value in needed_packages.items():
+ packages = ()
+ if isinstance(value, dict):
+ packages = (value, )
+ elif isinstance(value, list):
+ packages = value
+ else:
+ bb.fatal("Failed to process needed packages for %s; "
+ "Value must be a dict or list" % key)
+
+ for package in packages:
+ pkg = package["pkg"]
+ rm = package.get("rm", False)
+ extract = package.get("extract", True)
+ if extract:
+ dst_dir = os.path.join(extracted_path, pkg)
+
+ # Extract package and copy it to TEST_EXTRACTED_DIR
+ if extract and not os.path.exists(dst_dir):
+ pkg_dir = self._extract_in_tmpdir(pkg)
+ shutil.copytree(pkg_dir, dst_dir)
+ shutil.rmtree(pkg_dir)
+
def _getJsonFile(self, module):
"""
Returns the path of the JSON file for a module, empty if doesn't exitst.
@@ -422,6 +477,21 @@ class RuntimeTestContext(TestContext):
return needed_packages
+ def _extract_in_tmpdir(self, pkg):
+ """"
+ Returns path to a temp directory where the package was
+ extracted without dependencies.
+ """
+
+ from oeqa.utils.package_manager import get_package_manager
+
+ pkg_path = os.path.join(self.d.getVar("TEST_INSTALL_TMP_DIR", True), pkg)
+ pm = get_package_manager(self.d, pkg_path)
+ extract_dir = pm.extract(pkg)
+ shutil.rmtree(pkg_path)
+
+ return extract_dir
+
class ImageTestContext(RuntimeTestContext):
def __init__(self, d, target, host_dumper):
super(ImageTestContext, self).__init__(d, target)