summaryrefslogtreecommitdiffstats
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:09:27 +0100
commitc5be39df1494f33e2cae116e4930f2a0f3dd2000 (patch)
treecb0ae4ca381f55346566f8dcb0353232bf8ce07d
parent9a2386443af23d4b713b9635a0275165565ef8f4 (diff)
downloadopenembedded-core-contrib-c5be39df1494f33e2cae116e4930f2a0f3dd2000.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 Signed-off-by: Konrad Weihmann <kweihmann@outlook.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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):
self.logger.debug(msg)
if not self.case.tc.image_packages.isdisjoint(unneed_pkgs):
msg = "Test can't run with %s installed" % ', or'.join(unneed_pkgs)
- self.case.skipTest(msg)
+ self._decorator_fail(msg)
if need_pkgs:
msg = 'Checking if at least one of %s is installed' % ', '.join(need_pkgs)
self.logger.debug(msg)
if self.case.tc.image_packages.isdisjoint(need_pkgs):
msg = "Test requires %s to be installed" % ', or'.join(need_pkgs)
- self.case.skipTest(msg)
+ self._decorator_fail(msg)
+
+ def _decorator_fail(self, msg):
+ self.case.skipTest(msg)
+
+@registerDecorator
+class OERequirePackage(OEHasPackage):
+ """
+ Checks if image has packages (un)installed.
+ It is almost the same as OEHasPackage, but if dependencies are missing
+ the test case fails.
+
+ The argument must be a string, set, or list of packages that must be
+ installed or not present in the image.
+
+ The way to tell a package must not be in an image is using an
+ exclamation point ('!') before the name of the package.
+
+ If test depends on pkg1 or pkg2 you need to use:
+ @OERequirePackage({'pkg1', 'pkg2'})
+
+ If test depends on pkg1 and pkg2 you need to use:
+ @OERequirePackage('pkg1')
+ @OERequirePackage('pkg2')
+
+ If test depends on pkg1 but pkg2 must not be present use:
+ @OERequirePackage({'pkg1', '!pkg2'})
+ """
+
+ def _decorator_fail(self, msg):
+ self.case.fail(msg)