summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorzjh <junhuix.zhang@intel.com>2015-09-02 15:39:54 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-04 16:23:52 +0100
commitfac0d67ec25f357684bcd0c80be282e1bca3adef (patch)
tree6bdf3ffc8fbb5f84d0ea6cf7fc0fee1e6d2ff553 /meta/lib/oeqa/utils
parent1efd172dd89d13e10269c13d9ed8bb1c7f7ea2f0 (diff)
downloadpoky-fac0d67ec25f357684bcd0c80be282e1bca3adef.tar.gz
testimage: filter proper test cases by tags
If a test case is decorate by oeqa.utils.decorators.tag, this case will by add a tag, testrunner will filter these tags by TEST_SUITES_TAGS [YOCTO #7849] (From OE-Core rev: 085589b1018ba4d950baf7bcfb499be02c1b29fc) Signed-off-by: zjh <junhuix.zhang@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/decorators.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index b9fc76c9ee..769b4fffdd 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -185,4 +185,36 @@ def timeout(seconds):
185 return wrapped_f 185 return wrapped_f
186 else: 186 else:
187 return fn 187 return fn
188 return decorator \ No newline at end of file 188 return decorator
189
190__tag_prefix = "tag__"
191def tag(*args, **kwargs):
192 """Decorator that adds attributes to classes or functions
193 for use with the Attribute (-a) plugin.
194 """
195 def wrap_ob(ob):
196 for name in args:
197 setattr(ob, __tag_prefix + name, True)
198 for name, value in kwargs.iteritems():
199 setattr(ob, __tag_prefix + name, value)
200 return ob
201 return wrap_ob
202
203def gettag(obj, key, default=None):
204 key = __tag_prefix + key
205 if not isinstance(obj, unittest.TestCase):
206 return getattr(obj, key, default)
207 tc_method = getattr(obj, obj._testMethodName)
208 ret = getattr(tc_method, key, getattr(obj, key, default))
209 return ret
210
211def getAllTags(obj):
212 def __gettags(o):
213 r = {k[len(__tag_prefix):]:getattr(o,k) for k in dir(o) if k.startswith(__tag_prefix)}
214 return r
215 if not isinstance(obj, unittest.TestCase):
216 return __gettags(obj)
217 tc_method = getattr(obj, obj._testMethodName)
218 ret = __gettags(obj)
219 ret.update(__gettags(tc_method))
220 return ret