summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2017-05-26 15:37:45 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-02 13:36:14 +0100
commitc746ee11eca0f09d71e23986fb77392777e255cd (patch)
tree3a55b1f77d403e0792456e91f5aae1d6a9876eca /meta/lib
parent49223c47fc20ed4215cf82831a07dae6a1793dd0 (diff)
downloadpoky-c746ee11eca0f09d71e23986fb77392777e255cd.tar.gz
oeqa/core: Add support for run tests by module, class and name
This will enable only run certain module tests and filter by class and test name. (From OE-Core rev: 0f7531803aa6ffef2b7c5be9acee3efe7d2974ef) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/core/context.py6
-rw-r--r--meta/lib/oeqa/core/loader.py66
2 files changed, 68 insertions, 4 deletions
diff --git a/meta/lib/oeqa/core/context.py b/meta/lib/oeqa/core/context.py
index bc958d0dfe..28ae017090 100644
--- a/meta/lib/oeqa/core/context.py
+++ b/meta/lib/oeqa/core/context.py
@@ -85,9 +85,9 @@ class OETestContextExecutor(object):
85 help="results output log, default: %s" % self.default_output_log) 85 help="results output log, default: %s" % self.default_output_log)
86 86
87 group = self.parser.add_mutually_exclusive_group() 87 group = self.parser.add_mutually_exclusive_group()
88 group.add_argument('--run-tests', action='store', 88 group.add_argument('--run-tests', action='store', nargs='+',
89 default=self.default_tests, 89 default=self.default_tests,
90 help="tests to run in <module>[.<class>[.<name>]] format. Just works for modules now") 90 help="tests to run in <module>[.<class>[.<name>]]")
91 group.add_argument('--list-tests', action='store', 91 group.add_argument('--list-tests', action='store',
92 choices=('module', 'class', 'name'), 92 choices=('module', 'class', 'name'),
93 help="lists available tests") 93 help="lists available tests")
@@ -136,7 +136,7 @@ class OETestContextExecutor(object):
136 self.tc_kwargs['init']['td'] = {} 136 self.tc_kwargs['init']['td'] = {}
137 137
138 if args.run_tests: 138 if args.run_tests:
139 self.tc_kwargs['load']['modules'] = args.run_tests.split() 139 self.tc_kwargs['load']['modules'] = args.run_tests
140 else: 140 else:
141 self.tc_kwargs['load']['modules'] = None 141 self.tc_kwargs['load']['modules'] = None
142 142
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index 63a1703536..bffb2dac8d 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -29,6 +29,51 @@ def _find_duplicated_modules(suite, directory):
29 if path: 29 if path:
30 raise ImportError("Duplicated %s module found in %s" % (module, path)) 30 raise ImportError("Duplicated %s module found in %s" % (module, path))
31 31
32def _built_modules_dict(modules):
33 modules_dict = {}
34
35 if modules == None:
36 return modules_dict
37
38 for m in modules:
39 ms = m.split('.')
40
41 if len(ms) == 1:
42 module_name = ms[0]
43 if not module_name in modules_dict:
44 modules_dict[module_name] = {}
45 elif len(ms) == 2:
46 module_name = ms[0]
47 class_name = ms[1]
48 if not module_name in modules_dict:
49 modules_dict[module_name] = {}
50 if not class_name in modules_dict[module_name]:
51 modules_dict[module_name][class_name] = []
52 elif len(ms) == 3:
53 module_name = ms[0]
54 class_name = ms[1]
55 test_name = ms[2]
56
57 if not module_name in modules_dict:
58 modules_dict[module_name] = {}
59 if not class_name in modules_dict[module_name]:
60 modules_dict[module_name][class_name] = []
61 if not test_name in modules_dict[module_name][class_name]:
62 modules_dict[module_name][class_name].append(test_name)
63 elif len(ms) >= 4:
64 module_name = '.'.join(ms[0:-2])
65 class_name = ms[-2]
66 test_name = ms[-1]
67
68 if not module_name in modules_dict:
69 modules_dict[module_name] = {}
70 if not class_name in modules_dict[module_name]:
71 modules_dict[module_name][class_name] = []
72 if not test_name in modules_dict[module_name][class_name]:
73 modules_dict[module_name][class_name].append(test_name)
74
75 return modules_dict
76
32class OETestLoader(unittest.TestLoader): 77class OETestLoader(unittest.TestLoader):
33 caseClass = OETestCase 78 caseClass = OETestCase
34 79
@@ -39,7 +84,8 @@ class OETestLoader(unittest.TestLoader):
39 filters, *args, **kwargs): 84 filters, *args, **kwargs):
40 self.tc = tc 85 self.tc = tc
41 86
42 self.modules = modules 87 self.modules = _built_modules_dict(modules)
88
43 self.tests = tests 89 self.tests = tests
44 self.modules_required = modules_required 90 self.modules_required = modules_required
45 91
@@ -116,6 +162,24 @@ class OETestLoader(unittest.TestLoader):
116 """ 162 """
117 Returns True if test case must be filtered, False otherwise. 163 Returns True if test case must be filtered, False otherwise.
118 """ 164 """
165 # Filters by module.class.name
166 module_name = case.__module__
167 class_name = case.__class__.__name__
168 test_name = case._testMethodName
169
170 if self.modules:
171 if not module_name in self.modules:
172 return True
173
174 if self.modules[module_name]:
175 if not class_name in self.modules[module_name]:
176 return True
177
178 if self.modules[module_name][class_name]:
179 if test_name not in self.modules[module_name][class_name]:
180 return True
181
182 # Decorator filters
119 if self.filters: 183 if self.filters:
120 filters = self.filters.copy() 184 filters = self.filters.copy()
121 case_decorators = [cd for cd in case.decorators 185 case_decorators = [cd for cd in case.decorators