summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/oetest.py
diff options
context:
space:
mode:
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)