summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/oetest.py
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:26:14 +0100
commit675843d540f30058269789b2c6808a206ab04a04 (patch)
tree85383a91e26ddebb9dc3bcd8b4c63d47dc3bf5c5 /meta/lib/oeqa/oetest.py
parentc65cf8ede2116ef1fa3ddeb617e7c39caacff941 (diff)
downloadpoky-675843d540f30058269789b2c6808a206ab04a04.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. (From OE-Core rev: b9409863af71899e02275439949e3f4cdfaf2d0f) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/oetest.py')
-rw-r--r--meta/lib/oeqa/oetest.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index feb0f71eb4..4a740fb53f 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -61,14 +61,24 @@ class oeTest(unittest.TestCase):
61 61
62 @classmethod 62 @classmethod
63 def hasPackage(self, pkg): 63 def hasPackage(self, pkg):
64 for item in oeTest.tc.pkgmanifest.split('\n'): 64 """
65 if re.match(pkg, item): 65 True if the full package name exists in the manifest, False otherwise.
66 """
67 return pkg in oeTest.tc.pkgmanifest
68
69 @classmethod
70 def hasPackageMatch(self, match):
71 """
72 True if match exists in the manifest as a regular expression substring,
73 False otherwise.
74 """
75 for s in oeTest.tc.pkgmanifest:
76 if re.match(match, s):
66 return True 77 return True
67 return False 78 return False
68 79
69 @classmethod 80 @classmethod
70 def hasFeature(self,feature): 81 def hasFeature(self,feature):
71
72 if feature in oeTest.tc.imagefeatures or \ 82 if feature in oeTest.tc.imagefeatures or \
73 feature in oeTest.tc.distrofeatures: 83 feature in oeTest.tc.distrofeatures:
74 return True 84 return True
@@ -391,17 +401,18 @@ class RuntimeTestContext(TestContext):
391 401
392 self.target = target 402 self.target = target
393 403
404 self.pkgmanifest = {}
394 manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), 405 manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),
395 d.getVar("IMAGE_LINK_NAME", True) + ".manifest") 406 d.getVar("IMAGE_LINK_NAME", True) + ".manifest")
396 nomanifest = d.getVar("IMAGE_NO_MANIFEST", True) 407 nomanifest = d.getVar("IMAGE_NO_MANIFEST", True)
397 if nomanifest is None or nomanifest != "1": 408 if nomanifest is None or nomanifest != "1":
398 try: 409 try:
399 with open(manifest) as f: 410 with open(manifest) as f:
400 self.pkgmanifest = f.read() 411 for line in f:
412 (pkg, arch, version) = line.strip().split()
413 self.pkgmanifest[pkg] = (version, arch)
401 except IOError as e: 414 except IOError as e:
402 bb.fatal("No package manifest file found. Did you build the image?\n%s" % e) 415 bb.fatal("No package manifest file found. Did you build the image?\n%s" % e)
403 else:
404 self.pkgmanifest = ""
405 416
406 def _get_test_namespace(self): 417 def _get_test_namespace(self):
407 return "runtime" 418 return "runtime"
@@ -626,8 +637,11 @@ class SDKTestContext(TestContext):
626 if not hasattr(self, 'target_manifest'): 637 if not hasattr(self, 'target_manifest'):
627 self.target_manifest = d.getVar("SDK_TARGET_MANIFEST", True) 638 self.target_manifest = d.getVar("SDK_TARGET_MANIFEST", True)
628 try: 639 try:
640 self.pkgmanifest = {}
629 with open(self.target_manifest) as f: 641 with open(self.target_manifest) as f:
630 self.pkgmanifest = f.read() 642 for line in f:
643 (pkg, arch, version) = line.strip().split()
644 self.pkgmanifest[pkg] = (version, arch)
631 except IOError as e: 645 except IOError as e:
632 bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e) 646 bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e)
633 647