diff options
| author | Ross Burton <ross.burton@intel.com> | 2016-06-15 12:01:23 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-05-18 13:14:21 +0100 |
| commit | c71ea3831a9d40e37f47015cf0d14ab7fd61077d (patch) | |
| tree | 06efccdab638539732d0316993e2ff6bd86cdca8 /meta/lib | |
| parent | 3428c1db71d35fc811b9fb1fc2f0ba1edd237f8c (diff) | |
| download | poky-c71ea3831a9d40e37f47015cf0d14ab7fd61077d.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)
(From OE-Core rev: 990db70dac60541ef14977177fff4361e31c51eb)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
| -rw-r--r-- | meta/lib/oeqa/oetest.py | 28 | ||||
| -rw-r--r-- | meta/lib/oeqa/runtime/_ptest.py | 4 | ||||
| -rw-r--r-- | meta/lib/oeqa/runtime/python.py | 2 | ||||
| -rw-r--r-- | meta/lib/oeqa/runtime/smart.py | 2 | ||||
| -rw-r--r-- | meta/lib/oeqa/sdk/buildsudoku.py | 2 |
5 files changed, 26 insertions, 12 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py index 3ed5bb8c2b..9ef4d1f53b 100644 --- a/meta/lib/oeqa/oetest.py +++ b/meta/lib/oeqa/oetest.py | |||
| @@ -58,14 +58,24 @@ class oeTest(unittest.TestCase): | |||
| 58 | 58 | ||
| 59 | @classmethod | 59 | @classmethod |
| 60 | def hasPackage(self, pkg): | 60 | def hasPackage(self, pkg): |
| 61 | for item in oeTest.tc.pkgmanifest.split('\n'): | 61 | """ |
| 62 | if re.match(pkg, item): | 62 | True if the full package name exists in the manifest, False otherwise. |
| 63 | """ | ||
| 64 | return pkg in oeTest.tc.pkgmanifest | ||
| 65 | |||
| 66 | @classmethod | ||
| 67 | def hasPackageMatch(self, match): | ||
| 68 | """ | ||
| 69 | True if match exists in the manifest as a regular expression substring, | ||
| 70 | False otherwise. | ||
| 71 | """ | ||
| 72 | for s in oeTest.tc.pkgmanifest: | ||
| 73 | if re.match(match, s): | ||
| 63 | return True | 74 | return True |
| 64 | return False | 75 | return False |
| 65 | 76 | ||
| 66 | @classmethod | 77 | @classmethod |
| 67 | def hasFeature(self,feature): | 78 | def hasFeature(self,feature): |
| 68 | |||
| 69 | if feature in oeTest.tc.imagefeatures or \ | 79 | if feature in oeTest.tc.imagefeatures or \ |
| 70 | feature in oeTest.tc.distrofeatures: | 80 | feature in oeTest.tc.distrofeatures: |
| 71 | return True | 81 | return True |
| @@ -340,17 +350,18 @@ class ImageTestContext(TestContext): | |||
| 340 | self.target = target | 350 | self.target = target |
| 341 | self.host_dumper = host_dumper | 351 | self.host_dumper = host_dumper |
| 342 | 352 | ||
| 353 | self.pkgmanifest = {} | ||
| 343 | manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), | 354 | manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), |
| 344 | d.getVar("IMAGE_LINK_NAME", True) + ".manifest") | 355 | d.getVar("IMAGE_LINK_NAME", True) + ".manifest") |
| 345 | nomanifest = d.getVar("IMAGE_NO_MANIFEST", True) | 356 | nomanifest = d.getVar("IMAGE_NO_MANIFEST", True) |
| 346 | if nomanifest is None or nomanifest != "1": | 357 | if nomanifest is None or nomanifest != "1": |
| 347 | try: | 358 | try: |
| 348 | with open(manifest) as f: | 359 | with open(manifest) as f: |
| 349 | self.pkgmanifest = f.read() | 360 | for line in f: |
| 361 | (pkg, arch, version) = line.strip().split() | ||
| 362 | self.pkgmanifest[pkg] = (version, arch) | ||
| 350 | except IOError as e: | 363 | except IOError as e: |
| 351 | bb.fatal("No package manifest file found. Did you build the image?\n%s" % e) | 364 | bb.fatal("No package manifest file found. Did you build the image?\n%s" % e) |
| 352 | else: | ||
| 353 | self.pkgmanifest = "" | ||
| 354 | 365 | ||
| 355 | self.sigterm = False | 366 | self.sigterm = False |
| 356 | self.origsigtermhandler = signal.getsignal(signal.SIGTERM) | 367 | self.origsigtermhandler = signal.getsignal(signal.SIGTERM) |
| @@ -396,8 +407,11 @@ class SDKTestContext(TestContext): | |||
| 396 | if not hasattr(self, 'target_manifest'): | 407 | if not hasattr(self, 'target_manifest'): |
| 397 | self.target_manifest = d.getVar("SDK_TARGET_MANIFEST", True) | 408 | self.target_manifest = d.getVar("SDK_TARGET_MANIFEST", True) |
| 398 | try: | 409 | try: |
| 410 | self.pkgmanifest = {} | ||
| 399 | with open(self.target_manifest) as f: | 411 | with open(self.target_manifest) as f: |
| 400 | self.pkgmanifest = f.read() | 412 | for line in f: |
| 413 | (pkg, arch, version) = line.strip().split() | ||
| 414 | self.pkgmanifest[pkg] = (version, arch) | ||
| 401 | except IOError as e: | 415 | except IOError as e: |
| 402 | bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e) | 416 | bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e) |
| 403 | 417 | ||
diff --git a/meta/lib/oeqa/runtime/_ptest.py b/meta/lib/oeqa/runtime/_ptest.py index 0621028b86..71324d3da2 100644 --- a/meta/lib/oeqa/runtime/_ptest.py +++ b/meta/lib/oeqa/runtime/_ptest.py | |||
| @@ -11,7 +11,7 @@ import subprocess | |||
| 11 | def setUpModule(): | 11 | def setUpModule(): |
| 12 | if not oeRuntimeTest.hasFeature("package-management"): | 12 | if not oeRuntimeTest.hasFeature("package-management"): |
| 13 | skipModule("Image doesn't have package management feature") | 13 | skipModule("Image doesn't have package management feature") |
| 14 | if not oeRuntimeTest.hasPackage("smart"): | 14 | if not oeRuntimeTest.hasPackage("smartpm"): |
| 15 | skipModule("Image doesn't have smart installed") | 15 | skipModule("Image doesn't have smart installed") |
| 16 | if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]: | 16 | if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]: |
| 17 | skipModule("Rpm is not the primary package manager") | 17 | skipModule("Rpm is not the primary package manager") |
| @@ -105,7 +105,7 @@ class PtestRunnerTest(oeRuntimeTest): | |||
| 105 | def test_ptestrunner(self): | 105 | def test_ptestrunner(self): |
| 106 | self.add_smart_channel() | 106 | self.add_smart_channel() |
| 107 | (runnerstatus, result) = self.target.run('which ptest-runner', 0) | 107 | (runnerstatus, result) = self.target.run('which ptest-runner', 0) |
| 108 | cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackage("-ptest") and (runnerstatus != 0) | 108 | cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackageMatch("-ptest") and (runnerstatus != 0) |
| 109 | if cond: | 109 | if cond: |
| 110 | self.install_packages(self.install_complementary("*-ptest")) | 110 | self.install_packages(self.install_complementary("*-ptest")) |
| 111 | self.install_packages(['ptest-runner']) | 111 | self.install_packages(['ptest-runner']) |
diff --git a/meta/lib/oeqa/runtime/python.py b/meta/lib/oeqa/runtime/python.py index 26edb7a9b8..29a231c7c3 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 | |||
| 4 | from oeqa.utils.decorators import * | 4 | from oeqa.utils.decorators import * |
| 5 | 5 | ||
| 6 | def setUpModule(): | 6 | def setUpModule(): |
| 7 | if not oeRuntimeTest.hasPackage("python"): | 7 | if not oeRuntimeTest.hasPackage("python-core"): |
| 8 | skipModule("No python package in the image") | 8 | skipModule("No python package in the image") |
| 9 | 9 | ||
| 10 | 10 | ||
diff --git a/meta/lib/oeqa/runtime/smart.py b/meta/lib/oeqa/runtime/smart.py index 126d614638..c7a5753991 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 | |||
| 7 | def setUpModule(): | 7 | def setUpModule(): |
| 8 | if not oeRuntimeTest.hasFeature("package-management"): | 8 | if not oeRuntimeTest.hasFeature("package-management"): |
| 9 | skipModule("Image doesn't have package management feature") | 9 | skipModule("Image doesn't have package management feature") |
| 10 | if not oeRuntimeTest.hasPackage("smart"): | 10 | if not oeRuntimeTest.hasPackage("smartpm"): |
| 11 | skipModule("Image doesn't have smart installed") | 11 | skipModule("Image doesn't have smart installed") |
| 12 | if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]: | 12 | if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]: |
| 13 | skipModule("Rpm is not the primary package manager") | 13 | 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 dea77c6599..5abbbb867f 100644 --- a/meta/lib/oeqa/sdk/buildsudoku.py +++ b/meta/lib/oeqa/sdk/buildsudoku.py | |||
| @@ -3,7 +3,7 @@ from oeqa.utils.decorators import * | |||
| 3 | from oeqa.utils.targetbuild import SDKBuildProject | 3 | from oeqa.utils.targetbuild import SDKBuildProject |
| 4 | 4 | ||
| 5 | def setUpModule(): | 5 | def setUpModule(): |
| 6 | if not oeSDKTest.hasPackage("gtk\+"): | 6 | if not oeSDKTest.hasPackage("gtk+"): |
| 7 | skipModule("Image doesn't have gtk+ in manifest") | 7 | skipModule("Image doesn't have gtk+ in manifest") |
| 8 | 8 | ||
| 9 | class SudokuTest(oeSDKTest): | 9 | class SudokuTest(oeSDKTest): |
