diff options
Diffstat (limited to 'poky/meta/lib/oeqa/runtime')
-rw-r--r-- | poky/meta/lib/oeqa/runtime/cases/ptest.py | 4 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/runtime/decorator/package.py | 34 |
2 files changed, 36 insertions, 2 deletions
diff --git a/poky/meta/lib/oeqa/runtime/cases/ptest.py b/poky/meta/lib/oeqa/runtime/cases/ptest.py index 1b1474adcf..a9572c81f0 100644 --- a/poky/meta/lib/oeqa/runtime/cases/ptest.py +++ b/poky/meta/lib/oeqa/runtime/cases/ptest.py @@ -42,6 +42,10 @@ class PtestRunnerTest(OERuntimeTestCase): # testdata.json is generated. if not test_log_dir: test_log_dir = os.path.join(self.td.get('WORKDIR', ''), 'testimage') + # Make the test output path absolute, otherwise the output content will be + # created relative to current directory + if not os.path.isabs(test_log_dir): + test_log_dir = os.path.join(self.td.get('TOPDIR', ''), test_log_dir) # Don't use self.td.get('DATETIME'), it's from testdata.json, not # up-to-date, and may cause "File exists" when re-reun. timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S') diff --git a/poky/meta/lib/oeqa/runtime/decorator/package.py b/poky/meta/lib/oeqa/runtime/decorator/package.py index 4c5ca198b0..57178655cc 100644 --- a/poky/meta/lib/oeqa/runtime/decorator/package.py +++ b/poky/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) |