]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/core/decorator/data.py: Add skipIfNotFeature decorator
authorMariano Lopez <mariano.lopez@linux.intel.com>
Fri, 2 Dec 2016 22:05:44 +0000 (16:05 -0600)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 23 Jan 2017 12:03:55 +0000 (12:03 +0000)
This adds a new decorator to check if image under tests has
certain DISTRO_FEATURE or IMAGE_FEATURE.

[YOCTO #10234]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
meta/lib/oeqa/core/decorator/data.py

index 73cca88d7b95278b5333e13b8badbe6092737d8e..fdeba9fe1d03ba863d9dfbd73d6a16b4fc789827 100644 (file)
@@ -5,6 +5,16 @@ from oeqa.core.exception import OEQAMissingVariable
 
 from . import OETestDecorator, registerDecorator
 
+def has_feature(td, feature):
+    """
+        Checks for feature in DISTRO_FEATURES or IMAGE_FEATURES.
+    """
+
+    if (feature in td.get('DISTRO_FEATURES', '') or
+        feature in td.get('IMAGE_FEATURES', '')):
+        return True
+    return False
+
 @registerDecorator
 class skipIfDataVar(OETestDecorator):
     """
@@ -34,3 +44,21 @@ class OETestDataDepends(OETestDecorator):
             except KeyError:
                 raise OEQAMissingVariable("Test case need %s variable but"\
                         " isn't into td" % v)
+
+@registerDecorator
+class skipIfNotFeature(OETestDecorator):
+    """
+        Skip test based on DISTRO_FEATURES.
+
+        value must be in distro features or it will skip the test
+        with msg as the reason.
+    """
+
+    attrs = ('value', 'msg')
+
+    def setUpDecorator(self):
+        msg = ('Checking if %s is in DISTRO_FEATURES '
+               'or IMAGE_FEATURES' % (self.value))
+        self.logger.debug(msg)
+        if not has_feature(self.case.td, self.value):
+            self.case.skipTest(self.msg)