]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/sdk: fixes related to hasPackage semantics
authorChen Qi <Qi.Chen@windriver.com>
Wed, 29 Aug 2018 02:56:31 +0000 (10:56 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 30 Aug 2018 15:16:06 +0000 (16:16 +0100)
The current _hasPackage does a regex match when checking for the
existence of packages. This will sometimes result in unexpected
result. For example, the condition hasTargetPackage('gcc') is likely
to be always true as it matches libgcc1.

For most of the time, we should do exact match instead of regex match.
So change _hasPackage function to do that. For the current sdk test
cases, the only place that needs regex match is '^gcc-'. This is because
there's no easy way to get multilib tune arch (e.g. i686) from testdata.json
file.

Besides, packagegroup-cross-canadian-xxx and gcc-xxx should be check in
host manifest instead of the target one. So fix to use hasHostPackage.

Also, as we are doing exact match, there's no need to use r'gtk\+3',
just 'gtk+3' is enough.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/sdk/cases/buildgalculator.py
meta/lib/oeqa/sdk/cases/buildlzip.py
meta/lib/oeqa/sdk/cases/gcc.py
meta/lib/oeqa/sdk/context.py

index 3714825b06c0717128c277297efe7a0d8be1de02..050d1b3b520ca680cf5f80cffa8e24adecfd90ca 100644 (file)
@@ -8,8 +8,8 @@ class GalculatorTest(OESDKTestCase):
 
     @classmethod
     def setUpClass(self):
-        if not (self.tc.hasTargetPackage(r"gtk\+3", multilib=True) or\
-                self.tc.hasTargetPackage(r"libgtk-3.0", multilib=True)):
+        if not (self.tc.hasTargetPackage("gtk+3", multilib=True) or \
+                self.tc.hasTargetPackage("libgtk-3.0", multilib=True)):
             raise unittest.SkipTest("GalculatorTest class: SDK don't support gtk+3")
         if not (self.tc.hasHostPackage("nativesdk-gettext-dev")):
             raise unittest.SkipTest("GalculatorTest class: SDK doesn't contain gettext")
index 3a89ce86276b8d4b54fab0aab8ba399e01a35ee7..b28cc3a595ed6b978aeedbe74e7d8ae283d08daa 100644 (file)
@@ -17,8 +17,8 @@ class BuildLzipTest(OESDKTestCase):
 
         machine = self.td.get("MACHINE")
 
-        if not (self.tc.hasTargetPackage("packagegroup-cross-canadian-%s" % machine) or
-                self.tc.hasTargetPackage("gcc")):
+        if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
+                self.tc.hasHostPackage("^gcc-", regex=True)):
             raise unittest.SkipTest("SDK doesn't contain a cross-canadian toolchain")
 
     def test_lzip(self):
index d11f4b63fbf5bd854138ff819170bf1b5bcc07d8..b32b01fc24126b330a120a646b4b05500597a4e3 100644 (file)
@@ -18,8 +18,8 @@ class GccCompileTest(OESDKTestCase):
 
     def setUp(self):
         machine = self.td.get("MACHINE")
-        if not (self.tc.hasTargetPackage("packagegroup-cross-canadian-%s" % machine) or
-                self.tc.hasTargetPackage("gcc")):
+        if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
+                self.tc.hasHostPackage("^gcc-", regex=True)):
             raise unittest.SkipTest("GccCompileTest class: SDK doesn't contain a cross-canadian toolchain")
 
     def test_gcc_compile(self):
index ec8972d05a2aff8451db252901b8ff81583fef7c..adc4166fd2d93d5c8bff2e847f0b73d7ac62b967 100644 (file)
@@ -20,23 +20,30 @@ class OESDKTestContext(OETestContext):
         self.target_pkg_manifest = target_pkg_manifest
         self.host_pkg_manifest = host_pkg_manifest
 
-    def _hasPackage(self, manifest, pkg):
-        for host_pkg in manifest.keys():
-            if re.search(pkg, host_pkg):
+    def _hasPackage(self, manifest, pkg, regex=False):
+        if regex:
+            # do regex match
+            pat = re.compile(pkg)
+            for p in manifest.keys():
+                if pat.search(p):
+                    return True
+        else:
+            # do exact match
+            if pkg in manifest.keys():
                 return True
         return False
 
-    def hasHostPackage(self, pkg):
-        return self._hasPackage(self.host_pkg_manifest, pkg)
+    def hasHostPackage(self, pkg, regex=False):
+        return self._hasPackage(self.host_pkg_manifest, pkg, regex=regex)
 
-    def hasTargetPackage(self, pkg, multilib=False):
+    def hasTargetPackage(self, pkg, multilib=False, regex=False):
         if multilib:
             # match multilib according to sdk_env
             mls = self.td.get('MULTILIB_VARIANTS', '').split()
             for ml in mls:
                 if ('ml'+ml) in self.sdk_env:
                     pkg = ml + '-' + pkg
-        return self._hasPackage(self.target_pkg_manifest, pkg)
+        return self._hasPackage(self.target_pkg_manifest, pkg, regex=regex)
 
 class OESDKTestContextExecutor(OETestContextExecutor):
     _context_class = OESDKTestContext