Skip to contentSkip to conversation

testsdk: add ability to search for multilib packages

PATCH In review Joe Slater 2 participants 2 messages Dec 19, 2017 – Jan 13, 2018

lore
Share & tools
lore

Joe Slater

author
#0 lore raw

PATCH 1/1 testsdk: add ability to search for multilib packages

We search for packages related to the sdk environment being used for a test.

---
 meta/lib/oeqa/sdk/cases/buildgalculator.py |  7 ++++---
 meta/lib/oeqa/sdk/context.py               | 15 +++++++++++++--
 2 files changed, 17 insertions(+), 5 deletions(-)
meta/lib/oeqa/sdk/cases/buildgalculator.py +4 -3
index 780afcc..8518b15 100644
@@ -8,9 +8,10 @@ class GalculatorTest(OESDKTestCase):
 
     @classmethod
     def setUpClass(self):
-        if not (self.tc.hasTargetPackage("gtk\+3") or\
-                self.tc.hasTargetPackage("libgtk-3.0")):
-            raise unittest.SkipTest("GalculatorTest class: SDK don't support gtk+3")
+        # search for the multilib package per sdk_env
+        if not (self.tc.hasPrefixedTargetPackage("gtk\+3") or
+                self.tc.hasPrefixedTargetPackage("libgtk-3.0")):
+            raise unittest.SkipTest("GalculatorTest class: SDK doesn't support gtk+3")
 
     def test_galculator(self):
         dl_dir = self.td.get('DL_DIR', None)
meta/lib/oeqa/sdk/context.py +13 -2
index b3d7c75..291be1e 100644
@@ -22,8 +22,9 @@ class OESDKTestContext(OETestContextThreaded):
         self.host_pkg_manifest = host_pkg_manifest
 
     def _hasPackage(self, manifest, pkg):
-        for host_pkg in manifest.keys():
-            if re.search(pkg, host_pkg):
+        pat = re.compile(pkg)
+        for s in manifest.keys():
+            if pat.search(s):
                 return True
         return False
 
@@ -33,6 +34,16 @@ class OESDKTestContext(OETestContextThreaded):
     def hasTargetPackage(self, pkg):
         return self._hasPackage(self.target_pkg_manifest, pkg)
 
+    def hasPrefixedTargetPackage(self, pkg):
+        # extract multilib from environment script name
+        try:
+            p = re.match(".*(lib.?[36][24]-)linux-?", self.sdk_env).group(1) + pkg
+        except:
+            p = pkg
+
+        # bb.warn("Searching for multilib pkg %s" % (p))
+        return self.hasTargetPackage(p)
+
 class OESDKTestContextExecutor(OETestContextExecutor):
     _context_class = OESDKTestContext
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Joe Slater

We search for packages related to the sdk environment being used for a test.

[...]

Quoted 10 lines
(quoted diff) +0 -0
@@ -33,6 +34,16 @@ class OESDKTestContext(OETestContextThreaded):

     def hasTargetPackage(self, pkg):
         return self._hasPackage(self.target_pkg_manifest, pkg)
+    def hasPrefixedTargetPackage(self, pkg):
+        # extract multilib from environment script name +        try:
+            p = re.match(".*(lib.?[36][24]-)linux-?", self.sdk_env).group(1) + pkg
+        except:

I'm not sure this is correct, many of the prefixes are just "lib32-" and there is no "linux" in there?

We could really use unit tests on these functions as we're heading into unmaintainable spaghetti territory :(.

It may also be an option to iterate the configured multilibs and search for each one, that way we avoid the regexp overhead?

Cheers,

Richard