summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorKonrad Weihmann <kweihmann@outlook.com>2020-06-15 22:26:56 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-17 11:10:28 +0100
commit7f7f785ed354c3b4e68109dea968756d6bff649c (patch)
tree01df03dfa27c482973d28b3b74d0ac26e929ff7e /meta/lib/oeqa
parent889eb94e98cb3b86d607441e6f2ebdda8ccd9368 (diff)
downloadpoky-7f7f785ed354c3b4e68109dea968756d6bff649c.tar.gz
oeqa/runtime: Add OERequirePackage decorator
Add new decorator which behaves like OEHasPackage, but fails the testcase if a dependency isn't met. This helps to identify missing packages in the image under test when using static test suite lists, otherwise a missing package won't fail the overall test suite and errors might slip through unnoticed (From OE-Core rev: c5be39df1494f33e2cae116e4930f2a0f3dd2000) Signed-off-by: Konrad Weihmann <kweihmann@outlook.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/runtime/decorator/package.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/meta/lib/oeqa/runtime/decorator/package.py b/meta/lib/oeqa/runtime/decorator/package.py
index 4c5ca198b0..57178655cc 100644
--- a/meta/lib/oeqa/runtime/decorator/package.py
+++ b/meta/lib/oeqa/runtime/decorator/package.py
@@ -46,11 +46,41 @@ class OEHasPackage(OETestDecorator):
46 self.logger.debug(msg) 46 self.logger.debug(msg)
47 if not self.case.tc.image_packages.isdisjoint(unneed_pkgs): 47 if not self.case.tc.image_packages.isdisjoint(unneed_pkgs):
48 msg = "Test can't run with %s installed" % ', or'.join(unneed_pkgs) 48 msg = "Test can't run with %s installed" % ', or'.join(unneed_pkgs)
49 self.case.skipTest(msg) 49 self._decorator_fail(msg)
50 50
51 if need_pkgs: 51 if need_pkgs:
52 msg = 'Checking if at least one of %s is installed' % ', '.join(need_pkgs) 52 msg = 'Checking if at least one of %s is installed' % ', '.join(need_pkgs)
53 self.logger.debug(msg) 53 self.logger.debug(msg)
54 if self.case.tc.image_packages.isdisjoint(need_pkgs): 54 if self.case.tc.image_packages.isdisjoint(need_pkgs):
55 msg = "Test requires %s to be installed" % ', or'.join(need_pkgs) 55 msg = "Test requires %s to be installed" % ', or'.join(need_pkgs)
56 self.case.skipTest(msg) 56 self._decorator_fail(msg)
57
58 def _decorator_fail(self, msg):
59 self.case.skipTest(msg)
60
61@registerDecorator
62class OERequirePackage(OEHasPackage):
63 """
64 Checks if image has packages (un)installed.
65 It is almost the same as OEHasPackage, but if dependencies are missing
66 the test case fails.
67
68 The argument must be a string, set, or list of packages that must be
69 installed or not present in the image.
70
71 The way to tell a package must not be in an image is using an
72 exclamation point ('!') before the name of the package.
73
74 If test depends on pkg1 or pkg2 you need to use:
75 @OERequirePackage({'pkg1', 'pkg2'})
76
77 If test depends on pkg1 and pkg2 you need to use:
78 @OERequirePackage('pkg1')
79 @OERequirePackage('pkg2')
80
81 If test depends on pkg1 but pkg2 must not be present use:
82 @OERequirePackage({'pkg1', '!pkg2'})
83 """
84
85 def _decorator_fail(self, msg):
86 self.case.fail(msg)