diff mbox series

oeqa/sdk/context: Improve multilib handling

Message ID 20250201132038.3174641-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 7699867c3ce979ab615eb677a417bb5b82faecb7
Headers show
Series oeqa/sdk/context: Improve multilib handling | expand

Commit Message

Richard Purdie Feb. 1, 2025, 1:20 p.m. UTC
Rather than hiding the multilib logic in the package tests, move the
multilib setting to the init function of the class so the logic is
clearer.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/oeqa/sdk/context.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/sdk/context.py b/meta/lib/oeqa/sdk/context.py
index 77e6a98f391..d968cfa2be9 100644
--- a/meta/lib/oeqa/sdk/context.py
+++ b/meta/lib/oeqa/sdk/context.py
@@ -23,6 +23,13 @@  class OESDKTestContext(OETestContext):
         self.target_pkg_manifest = target_pkg_manifest
         self.host_pkg_manifest = host_pkg_manifest
 
+        # match multilib according to sdk_env
+        self.multilib = ""
+        multilibs = self.td.get('MULTILIB_VARIANTS', '').split()
+        for ml in multilibs:
+            if ml in os.path.basename(self.sdk_env):
+                self.multilib = ml
+
     def _hasPackage(self, manifest, pkg, regex=False):
         if regex:
             # do regex match
@@ -41,13 +48,7 @@  class OESDKTestContext(OETestContext):
 
     def hasTargetPackage(self, pkg, multilib=False, regex=False):
         if multilib:
-            stripped_sdk_env = os.path.basename(self.sdk_env)
-            if stripped_sdk_env.startswith('environment-setup-'):
-                # match multilib according to sdk_env
-                mls = self.td.get('MULTILIB_VARIANTS', '').split()
-                for ml in mls:
-                    if ('ml'+ml) in stripped_sdk_env:
-                        pkg = ml + '-' + pkg
+            pkg = self.multilib + '-' + pkg
         return self._hasPackage(self.target_pkg_manifest, pkg, regex=regex)
 
 class OESDKTestContextExecutor(OETestContextExecutor):