diff options
| author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2016-11-02 12:02:01 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-23 12:05:20 +0000 |
| commit | 9ee0816ca9f71b503fcaa0046e2fec14ba2db4e6 (patch) | |
| tree | ebba16358333e739f30f4f2ae1ff199866047499 /meta/lib | |
| parent | 4cd982566b10375925e616b176e988219d65b170 (diff) | |
| download | poky-9ee0816ca9f71b503fcaa0046e2fec14ba2db4e6.tar.gz | |
oeqa/runtime: Add OEHasPackage decorator
This new decorator will be used to skip the test
if the image under test doesn't have the required
packages installed.
[YOCTO #10234]
(From OE-Core rev: 021449938ff0b4d182d7f02930a80693f109c8ba)
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
| -rw-r--r-- | meta/lib/oeqa/runtime/decorator/package.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/decorator/package.py b/meta/lib/oeqa/runtime/decorator/package.py new file mode 100644 index 0000000000..aa6ecb68fa --- /dev/null +++ b/meta/lib/oeqa/runtime/decorator/package.py | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | # Copyright (C) 2016 Intel Corporation | ||
| 2 | # Released under the MIT license (see COPYING.MIT) | ||
| 3 | |||
| 4 | from oeqa.core.decorator import OETestDecorator, registerDecorator | ||
| 5 | from oeqa.core.utils.misc import strToSet | ||
| 6 | |||
| 7 | @registerDecorator | ||
| 8 | class OEHasPackage(OETestDecorator): | ||
| 9 | """ | ||
| 10 | Checks if image has packages (un)installed. | ||
| 11 | |||
| 12 | The argument must be a string, set, or list of packages that must be | ||
| 13 | installed or not present in the image. | ||
| 14 | |||
| 15 | The way to tell a package must not be in an image is using an | ||
| 16 | exclamation point ('!') before the name of the package. | ||
| 17 | |||
| 18 | If test depends on pkg1 or pkg2 you need to use: | ||
| 19 | @OEHasPackage({'pkg1', 'pkg2'}) | ||
| 20 | |||
| 21 | If test depends on pkg1 and pkg2 you need to use: | ||
| 22 | @OEHasPackage('pkg1') | ||
| 23 | @OEHasPackage('pkg2') | ||
| 24 | |||
| 25 | If test depends on pkg1 but pkg2 must not be present use: | ||
| 26 | @OEHasPackage({'pkg1', '!pkg2'}) | ||
| 27 | """ | ||
| 28 | |||
| 29 | attrs = ('need_pkgs',) | ||
| 30 | |||
| 31 | def setUpDecorator(self): | ||
| 32 | need_pkgs = set() | ||
| 33 | unneed_pkgs = set() | ||
| 34 | pkgs = strToSet(self.need_pkgs) | ||
| 35 | for pkg in pkgs: | ||
| 36 | if pkg.startswith('!'): | ||
| 37 | unneed_pkgs.add(pkg[1:]) | ||
| 38 | else: | ||
| 39 | need_pkgs.add(pkg) | ||
| 40 | |||
| 41 | if unneed_pkgs: | ||
| 42 | msg = 'Checking if %s is not installed' % ', '.join(unneed_pkgs) | ||
| 43 | self.logger.debug(msg) | ||
| 44 | if not self.case.tc.image_packages.isdisjoint(unneed_pkgs): | ||
| 45 | msg = "Test can't run with %s installed" % ', or'.join(unneed_pkgs) | ||
| 46 | self.case.skipTest(msg) | ||
| 47 | |||
| 48 | if need_pkgs: | ||
| 49 | msg = 'Checking if at least one of %s is installed' % ', '.join(need_pkgs) | ||
| 50 | self.logger.debug(msg) | ||
| 51 | if self.case.tc.image_packages.isdisjoint(need_pkgs): | ||
| 52 | msg = "Test requires %s to be installed" % ', or'.join(need_pkgs) | ||
| 53 | self.case.skipTest(msg) | ||
