summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core/decorator
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-11-09 11:24:57 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:03:52 +0000
commit7dc519d20e835ee7693c31903e164c4bc0e5e598 (patch)
tree316fd53437252d87b7e0e1275c2a169fdb206a30 /meta/lib/oeqa/core/decorator
parent1bf66a370361912e9950d7ff45e382c93622a169 (diff)
downloadopenembedded-core-contrib-7dc519d20e835ee7693c31903e164c4bc0e5e598.tar.gz
oeqa/core/decorator: Add support for OETestDataDepends and skipIfDataVar
The OETestDataDepends decorator skips a test case if a variable isn't into test data (d). The skipIfDataVar decorator skips a test case if a variable has certain value. Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Diffstat (limited to 'meta/lib/oeqa/core/decorator')
-rw-r--r--meta/lib/oeqa/core/decorator/data.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/meta/lib/oeqa/core/decorator/data.py b/meta/lib/oeqa/core/decorator/data.py
new file mode 100644
index 0000000000..73cca88d7b
--- /dev/null
+++ b/meta/lib/oeqa/core/decorator/data.py
@@ -0,0 +1,36 @@
+# Copyright (C) 2016 Intel Corporation
+# Released under the MIT license (see COPYING.MIT)
+
+from oeqa.core.exception import OEQAMissingVariable
+
+from . import OETestDecorator, registerDecorator
+
+@registerDecorator
+class skipIfDataVar(OETestDecorator):
+ """
+ Skip test based on value of a data store's variable.
+
+ It will get the info of var from the data store and will
+ check it against value; if are equal it will skip the test
+ with msg as the reason.
+ """
+
+ attrs = ('var', 'value', 'msg')
+
+ def setUpDecorator(self):
+ msg = 'Checking if %r value is %r to skip test' % (self.var, self.value)
+ self.logger.debug(msg)
+ if self.case.td.get(self.var) == self.value:
+ self.case.skipTest(self.msg)
+
+@registerDecorator
+class OETestDataDepends(OETestDecorator):
+ attrs = ('td_depends',)
+
+ def setUpDecorator(self):
+ for v in self.td_depends:
+ try:
+ value = self.case.td[v]
+ except KeyError:
+ raise OEQAMissingVariable("Test case need %s variable but"\
+ " isn't into td" % v)