summaryrefslogtreecommitdiffstats
path: root/scripts/oe-selftest
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/oe-selftest')
-rwxr-xr-xscripts/oe-selftest29
1 files changed, 19 insertions, 10 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index 9444244e02..d18348d1c6 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -32,6 +32,8 @@ import logging
32import argparse 32import argparse
33import subprocess 33import subprocess
34import time as t 34import time as t
35import re
36import fnmatch
35 37
36sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') 38sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib')
37import scriptpath 39import scriptpath
@@ -197,7 +199,7 @@ class Tc:
197 self.tcclass = tcclass 199 self.tcclass = tcclass
198 self.tcmodule = tcmodule 200 self.tcmodule = tcmodule
199 self.tcid = tcid 201 self.tcid = tcid
200 # A test case can have multiple tags (as list or as tuples) otherwise str suffice 202 # A test case can have multiple tags (as tuples) otherwise str will suffice
201 self.tctag = tctag 203 self.tctag = tctag
202 self.fullpath = '.'.join(['oeqa', 'selftest', tcmodule, tcclass, tcname]) 204 self.fullpath = '.'.join(['oeqa', 'selftest', tcmodule, tcclass, tcname])
203 205
@@ -243,19 +245,17 @@ def get_all_tests():
243 testlist += get_tests_from_module(tmod) 245 testlist += get_tests_from_module(tmod)
244 return testlist 246 return testlist
245 247
248
246def get_testsuite_by(criteria, keyword): 249def get_testsuite_by(criteria, keyword):
247 # Get a testsuite based on 'keyword' 250 # Get a testsuite based on 'keyword'
248 # criteria: name, class, module, id, tag 251 # criteria: name, class, module, id, tag
249 # keyword: a list of tests, classes, modules, ids, tags 252 # keyword: a list of tests, classes, modules, ids, tags
250 253
251 import re
252 import fnmatch
253
254 ts = [] 254 ts = []
255 all_tests = get_all_tests() 255 all_tests = get_all_tests()
256 256
257 def get_matches(values): 257 def get_matches(values):
258 # Get a items and return the ones that match with keyword(s) 258 # Get an item and return the ones that match with keyword(s)
259 # values: the list of items (names, modules, classes...) 259 # values: the list of items (names, modules, classes...)
260 result = [] 260 result = []
261 remaining = values[:] 261 remaining = values[:]
@@ -267,9 +267,9 @@ def get_testsuite_by(criteria, keyword):
267 else: 267 else:
268 # Wildcard matching 268 # Wildcard matching
269 pattern = re.compile(fnmatch.translate(r"%s" % key)) 269 pattern = re.compile(fnmatch.translate(r"%s" % key))
270 added = [ x for x in remaining if pattern.match(x) ] 270 added = [x for x in remaining if pattern.match(x)]
271 result.extend(added) 271 result.extend(added)
272 remaining = [ x for x in remaining if not x in added ] 272 remaining = [x for x in remaining if x not in added]
273 273
274 return result 274 return result
275 275
@@ -292,14 +292,23 @@ def get_testsuite_by(criteria, keyword):
292 elif criteria == 'tag': 292 elif criteria == 'tag':
293 values = set() 293 values = set()
294 for tc in all_tests: 294 for tc in all_tests:
295 # tc can have multiple tags (as list or tuple) otherwise as str 295 # tc can have multiple tags (as tuple) otherwise str will suffice
296 if isinstance(tc.tctag, (list, tuple)): 296 if isinstance(tc.tctag, tuple):
297 values |= { str(tag) for tag in tc.tctag } 297 values |= { str(tag) for tag in tc.tctag }
298 else: 298 else:
299 values.add(str(tc.tctag)) 299 values.add(str(tc.tctag))
300 300
301 tags = get_matches(list(values)) 301 tags = get_matches(list(values))
302 ts = [ tc for tc in all_tests if str(tc.tctag) in tags ] 302
303 for tc in all_tests:
304 for tag in tags:
305 if isinstance(tc.tctag, tuple) and tag in tc.tctag:
306 ts.append(tc)
307 elif tag == tc.tctag:
308 ts.append(tc)
309
310 # Remove duplicates from the list
311 ts = list(set(ts))
303 312
304 return ts 313 return ts
305 314