summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/oetest.py
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/oetest.py
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/oetest.py')
-rw-r--r--meta/lib/oeqa/oetest.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 4773bdd4d8..9724325083 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -12,9 +12,32 @@ import unittest
12import inspect 12import inspect
13import subprocess 13import subprocess
14import bb 14import bb
15from oeqa.utils.decorators import LogResults 15from oeqa.utils.decorators import LogResults, gettag
16from sys import exc_info, exc_clear 16from sys import exc_info, exc_clear
17 17
18def getVar(obj):
19 #extend form dict, if a variable didn't exists, need find it in testcase
20 class VarDict(dict):
21 def __getitem__(self, key):
22 return gettag(obj, key)
23 return VarDict()
24
25def checkTags(tc, tagexp):
26 return eval(tagexp, None, getVar(tc))
27
28
29def filterByTagExp(testsuite, tagexp):
30 if not tagexp:
31 return testsuite
32 caseList = []
33 for each in testsuite:
34 if not isinstance(each, unittest.BaseTestSuite):
35 if checkTags(each, tagexp):
36 caseList.append(each)
37 else:
38 caseList.append(filterByTagExp(each, tagexp))
39 return testsuite.__class__(caseList)
40
18def loadTests(tc, type="runtime"): 41def loadTests(tc, type="runtime"):
19 if type == "runtime": 42 if type == "runtime":
20 # set the context object passed from the test class 43 # set the context object passed from the test class
@@ -29,6 +52,7 @@ def loadTests(tc, type="runtime"):
29 testloader = unittest.TestLoader() 52 testloader = unittest.TestLoader()
30 testloader.sortTestMethodsUsing = None 53 testloader.sortTestMethodsUsing = None
31 suites = [testloader.loadTestsFromName(name) for name in tc.testslist] 54 suites = [testloader.loadTestsFromName(name) for name in tc.testslist]
55 suites = filterByTagExp(suites, getattr(tc, "tagexp", None))
32 56
33 def getTests(test): 57 def getTests(test):
34 '''Return all individual tests executed when running the suite.''' 58 '''Return all individual tests executed when running the suite.'''
@@ -86,6 +110,8 @@ def runTests(tc, type="runtime"):
86 110
87 suite = loadTests(tc, type) 111 suite = loadTests(tc, type)
88 bb.note("Test modules %s" % tc.testslist) 112 bb.note("Test modules %s" % tc.testslist)
113 if hasattr(tc, "tagexp") and tc.tagexp:
114 bb.note("Filter test cases by tags: %s" % tc.tagexp)
89 bb.note("Found %s tests" % suite.countTestCases()) 115 bb.note("Found %s tests" % suite.countTestCases())
90 runner = unittest.TextTestRunner(verbosity=2) 116 runner = unittest.TextTestRunner(verbosity=2)
91 result = runner.run(suite) 117 result = runner.run(suite)