summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2017-07-26 10:04:09 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-30 08:46:19 +0100
commit2d50f153b5b76adbd4157d2f69001ed91e9148dc (patch)
tree388a4933b0232a6f35e186602a9720760bfa05fb /meta/lib/oeqa
parent4c09b7a745dbc4b9ff7dcbe4789fbb34da31b74a (diff)
downloadpoky-2d50f153b5b76adbd4157d2f69001ed91e9148dc.tar.gz
oeqa/{core,selftest}: Add support to validate if a specified test case isn't found
If some test module/case is specified to run and isn't found the OEQA framework didn't notice it, so complete the implementation using modules_required and validate for the test case prescense. Raise an exception when the test module/case required isn't found. [YOCTO #11645] (From OE-Core rev: e50b415aaaa1581473f85f0a8afa278b5f95129b) 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/oeqa')
-rw-r--r--meta/lib/oeqa/core/context.py9
-rw-r--r--meta/lib/oeqa/core/exception.py3
-rw-r--r--meta/lib/oeqa/core/loader.py26
-rw-r--r--meta/lib/oeqa/selftest/context.py8
4 files changed, 42 insertions, 4 deletions
diff --git a/meta/lib/oeqa/core/context.py b/meta/lib/oeqa/core/context.py
index 2d543ffa31..422e289992 100644
--- a/meta/lib/oeqa/core/context.py
+++ b/meta/lib/oeqa/core/context.py
@@ -10,7 +10,7 @@ import collections
10 10
11from oeqa.core.loader import OETestLoader 11from oeqa.core.loader import OETestLoader
12from oeqa.core.runner import OETestRunner 12from oeqa.core.runner import OETestRunner
13from oeqa.core.exception import OEQAMissingManifest 13from oeqa.core.exception import OEQAMissingManifest, OEQATestNotFound
14 14
15class OETestContext(object): 15class OETestContext(object):
16 loaderClass = OETestLoader 16 loaderClass = OETestLoader
@@ -139,6 +139,7 @@ class OETestContextExecutor(object):
139 139
140 if args.run_tests: 140 if args.run_tests:
141 self.tc_kwargs['load']['modules'] = args.run_tests 141 self.tc_kwargs['load']['modules'] = args.run_tests
142 self.tc_kwargs['load']['modules_required'] = args.run_tests
142 else: 143 else:
143 self.tc_kwargs['load']['modules'] = [] 144 self.tc_kwargs['load']['modules'] = []
144 145
@@ -151,7 +152,11 @@ class OETestContextExecutor(object):
151 self._process_args(logger, args) 152 self._process_args(logger, args)
152 153
153 self.tc = self._context_class(**self.tc_kwargs['init']) 154 self.tc = self._context_class(**self.tc_kwargs['init'])
154 self.tc.loadTests(self.module_paths, **self.tc_kwargs['load']) 155 try:
156 self.tc.loadTests(self.module_paths, **self.tc_kwargs['load'])
157 except OEQATestNotFound as ex:
158 logger.error(ex)
159 sys.exit(1)
155 160
156 if args.list_tests: 161 if args.list_tests:
157 rc = self.tc.listTests(args.list_tests, **self.tc_kwargs['run']) 162 rc = self.tc.listTests(args.list_tests, **self.tc_kwargs['run'])
diff --git a/meta/lib/oeqa/core/exception.py b/meta/lib/oeqa/core/exception.py
index a07961adc3..732f2efdeb 100644
--- a/meta/lib/oeqa/core/exception.py
+++ b/meta/lib/oeqa/core/exception.py
@@ -18,3 +18,6 @@ class OEQAMissingManifest(OEQAException):
18 18
19class OEQAPreRun(OEQAException): 19class OEQAPreRun(OEQAException):
20 pass 20 pass
21
22class OEQATestNotFound(OEQAException):
23 pass
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index e4c218b57f..332086a13d 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -9,6 +9,7 @@ import inspect
9from oeqa.core.utils.path import findFile 9from oeqa.core.utils.path import findFile
10from oeqa.core.utils.test import getSuiteModules, getCaseID 10from oeqa.core.utils.test import getSuiteModules, getCaseID
11 11
12from oeqa.core.exception import OEQATestNotFound
12from oeqa.core.case import OETestCase 13from oeqa.core.case import OETestCase
13from oeqa.core.decorator import decoratorClasses, OETestDecorator, \ 14from oeqa.core.decorator import decoratorClasses, OETestDecorator, \
14 OETestFilter, OETestDiscover 15 OETestFilter, OETestDiscover
@@ -277,6 +278,28 @@ class OETestLoader(unittest.TestLoader):
277 278
278 return self.suiteClass(suite) 279 return self.suiteClass(suite)
279 280
281 def _required_modules_validation(self):
282 """
283 Search in Test context registry if a required
284 test is found, raise an exception when not found.
285 """
286
287 for module in self.modules_required:
288 found = False
289
290 # The module name is splitted to only compare the
291 # first part of a test case id.
292 comp_len = len(module.split('.'))
293 for case in self.tc._registry['cases']:
294 case_comp = '.'.join(case.split('.')[0:comp_len])
295 if module == case_comp:
296 found = True
297 break
298
299 if not found:
300 raise OEQATestNotFound("Not found %s in loaded test cases" % \
301 module)
302
280 def discover(self): 303 def discover(self):
281 big_suite = self.suiteClass() 304 big_suite = self.suiteClass()
282 for path in self.module_paths: 305 for path in self.module_paths:
@@ -291,6 +314,9 @@ class OETestLoader(unittest.TestLoader):
291 for clss in discover_classes: 314 for clss in discover_classes:
292 cases = clss.discover(self.tc._registry) 315 cases = clss.discover(self.tc._registry)
293 316
317 if self.modules_required:
318 self._required_modules_validation()
319
294 return self.suiteClass(cases) if cases else big_suite 320 return self.suiteClass(cases) if cases else big_suite
295 321
296 def _filterModule(self, module): 322 def _filterModule(self, module):
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py
index 4575a0537f..990c761f29 100644
--- a/meta/lib/oeqa/selftest/context.py
+++ b/meta/lib/oeqa/selftest/context.py
@@ -13,7 +13,7 @@ from random import choice
13import oeqa 13import oeqa
14 14
15from oeqa.core.context import OETestContext, OETestContextExecutor 15from oeqa.core.context import OETestContext, OETestContextExecutor
16from oeqa.core.exception import OEQAPreRun 16from oeqa.core.exception import OEQAPreRun, OEQATestNotFound
17 17
18from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer 18from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer
19 19
@@ -196,7 +196,11 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
196 self.tc_kwargs['init']['td']['BBPATH'].split(':')) 196 self.tc_kwargs['init']['td']['BBPATH'].split(':'))
197 197
198 self.tc = self._context_class(**self.tc_kwargs['init']) 198 self.tc = self._context_class(**self.tc_kwargs['init'])
199 self.tc.loadTests(self.module_paths, **self.tc_kwargs['load']) 199 try:
200 self.tc.loadTests(self.module_paths, **self.tc_kwargs['load'])
201 except OEQATestNotFound as ex:
202 logger.error(ex)
203 sys.exit(1)
200 204
201 if args.list_tests: 205 if args.list_tests:
202 rc = self.tc.listTests(args.list_tests, **self.tc_kwargs['run']) 206 rc = self.tc.listTests(args.list_tests, **self.tc_kwargs['run'])