aboutsummaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2016-06-15 12:01:23 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-23 14:21:25 +0100
commitb9409863af71899e02275439949e3f4cdfaf2d0f (patch)
tree77b9f1bcd1dc88bc0a172d3e9c130e5ee4f148c3 /meta
parentbb5a43f049c1a7cffb5516b1c3d0264dea68ea3f (diff)
downloadopenembedded-core-contrib-b9409863af71899e02275439949e3f4cdfaf2d0f.tar.gz
oeqa: fix hasPackage, add hasPackageMatch
hasPackage() was looking for the string provided as an RE substring in the manifest, which resulted in a large number of false positives (i.e. libgtkfoo would match "gtk+"). Rewrite the manifest loader to parse the files into a proper data structure, change hasPackage to do full string matches, and add hasPackageMatch which does RE substring matches. Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/oetest.py28
-rw-r--r--meta/lib/oeqa/runtime/_ptest.py4
-rw-r--r--meta/lib/oeqa/runtime/python.py2
-rw-r--r--meta/lib/oeqa/runtime/smart.py2
-rw-r--r--meta/lib/oeqa/sdk/buildsudoku.py2
5 files changed, 26 insertions, 12 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index feb0f71eb44..4a740fb53f4 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -61,14 +61,24 @@ class oeTest(unittest.TestCase):
@classmethod
def hasPackage(self, pkg):
- for item in oeTest.tc.pkgmanifest.split('\n'):
- if re.match(pkg, item):
+ """
+ True if the full package name exists in the manifest, False otherwise.
+ """
+ return pkg in oeTest.tc.pkgmanifest
+
+ @classmethod
+ def hasPackageMatch(self, match):
+ """
+ True if match exists in the manifest as a regular expression substring,
+ False otherwise.
+ """
+ for s in oeTest.tc.pkgmanifest:
+ if re.match(match, s):
return True
return False
@classmethod
def hasFeature(self,feature):
-
if feature in oeTest.tc.imagefeatures or \
feature in oeTest.tc.distrofeatures:
return True
@@ -391,17 +401,18 @@ 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)
if nomanifest is None or nomanifest != "1":
try:
with open(manifest) as f:
- self.pkgmanifest = f.read()
+ 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 image?\n%s" % e)
- else:
- self.pkgmanifest = ""
def _get_test_namespace(self):
return "runtime"
@@ -626,8 +637,11 @@ class SDKTestContext(TestContext):
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:
- self.pkgmanifest = f.read()
+ 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)
diff --git a/meta/lib/oeqa/runtime/_ptest.py b/meta/lib/oeqa/runtime/_ptest.py
index 0621028b86c..71324d3da2d 100644
--- a/meta/lib/oeqa/runtime/_ptest.py
+++ b/meta/lib/oeqa/runtime/_ptest.py
@@ -11,7 +11,7 @@ import subprocess
def setUpModule():
if not oeRuntimeTest.hasFeature("package-management"):
skipModule("Image doesn't have package management feature")
- if not oeRuntimeTest.hasPackage("smart"):
+ if not oeRuntimeTest.hasPackage("smartpm"):
skipModule("Image doesn't have smart installed")
if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
skipModule("Rpm is not the primary package manager")
@@ -105,7 +105,7 @@ class PtestRunnerTest(oeRuntimeTest):
def test_ptestrunner(self):
self.add_smart_channel()
(runnerstatus, result) = self.target.run('which ptest-runner', 0)
- cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackage("-ptest") and (runnerstatus != 0)
+ cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackageMatch("-ptest") and (runnerstatus != 0)
if cond:
self.install_packages(self.install_complementary("*-ptest"))
self.install_packages(['ptest-runner'])
diff --git a/meta/lib/oeqa/runtime/python.py b/meta/lib/oeqa/runtime/python.py
index 26edb7a9b85..29a231c7c3f 100644
--- a/meta/lib/oeqa/runtime/python.py
+++ b/meta/lib/oeqa/runtime/python.py
@@ -4,7 +4,7 @@ from oeqa.oetest import oeRuntimeTest, skipModule
from oeqa.utils.decorators import *
def setUpModule():
- if not oeRuntimeTest.hasPackage("python"):
+ if not oeRuntimeTest.hasPackage("python-core"):
skipModule("No python package in the image")
diff --git a/meta/lib/oeqa/runtime/smart.py b/meta/lib/oeqa/runtime/smart.py
index 126d614638f..c7a57539917 100644
--- a/meta/lib/oeqa/runtime/smart.py
+++ b/meta/lib/oeqa/runtime/smart.py
@@ -7,7 +7,7 @@ from oeqa.utils.httpserver import HTTPService
def setUpModule():
if not oeRuntimeTest.hasFeature("package-management"):
skipModule("Image doesn't have package management feature")
- if not oeRuntimeTest.hasPackage("smart"):
+ if not oeRuntimeTest.hasPackage("smartpm"):
skipModule("Image doesn't have smart installed")
if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
skipModule("Rpm is not the primary package manager")
diff --git a/meta/lib/oeqa/sdk/buildsudoku.py b/meta/lib/oeqa/sdk/buildsudoku.py
index dea77c65992..5abbbb867f1 100644
--- a/meta/lib/oeqa/sdk/buildsudoku.py
+++ b/meta/lib/oeqa/sdk/buildsudoku.py
@@ -3,7 +3,7 @@ from oeqa.utils.decorators import *
from oeqa.utils.targetbuild import SDKBuildProject
def setUpModule():
- if not oeSDKTest.hasPackage("gtk\+"):
+ if not oeSDKTest.hasPackage("gtk+"):
skipModule("Image doesn't have gtk+ in manifest")
class SudokuTest(oeSDKTest):