summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/core')
-rw-r--r--meta/lib/oeqa/core/decorator/oeid.py23
-rw-r--r--meta/lib/oeqa/core/runner.py31
-rw-r--r--meta/lib/oeqa/core/tests/cases/loader/invalid/oeid.py15
-rw-r--r--meta/lib/oeqa/core/tests/cases/oeid.py18
-rwxr-xr-xmeta/lib/oeqa/core/tests/test_decorators.py23
-rwxr-xr-xmeta/lib/oeqa/core/tests/test_loader.py11
6 files changed, 8 insertions, 113 deletions
diff --git a/meta/lib/oeqa/core/decorator/oeid.py b/meta/lib/oeqa/core/decorator/oeid.py
deleted file mode 100644
index ea8017a55a..0000000000
--- a/meta/lib/oeqa/core/decorator/oeid.py
+++ /dev/null
@@ -1,23 +0,0 @@
1# Copyright (C) 2016 Intel Corporation
2# Released under the MIT license (see COPYING.MIT)
3
4from . import OETestFilter, registerDecorator
5from oeqa.core.utils.misc import intToList
6
7def _idFilter(oeid, filters):
8 return False if oeid in filters else True
9
10@registerDecorator
11class OETestID(OETestFilter):
12 attrs = ('oeid',)
13
14 def bind(self, registry, case):
15 super(OETestID, self).bind(registry, case)
16
17 def filtrate(self, filters):
18 if filters.get('oeid'):
19 filterx = intToList(filters['oeid'], 'oeid')
20 del filters['oeid']
21 if _idFilter(self.oeid, filterx):
22 return True
23 return False
diff --git a/meta/lib/oeqa/core/runner.py b/meta/lib/oeqa/core/runner.py
index 478b7b6683..ee1fb43028 100644
--- a/meta/lib/oeqa/core/runner.py
+++ b/meta/lib/oeqa/core/runner.py
@@ -139,19 +139,13 @@ class OETestResult(_TestResult):
139 139
140 (status, log) = self._getTestResultDetails(case) 140 (status, log) = self._getTestResultDetails(case)
141 141
142 oeid = -1
143 if hasattr(case, 'decorators'):
144 for d in case.decorators:
145 if hasattr(d, 'oeid'):
146 oeid = d.oeid
147
148 t = "" 142 t = ""
149 if case.id() in self.starttime and case.id() in self.endtime: 143 if case.id() in self.starttime and case.id() in self.endtime:
150 t = " (" + "{0:.2f}".format(self.endtime[case.id()] - self.starttime[case.id()]) + "s)" 144 t = " (" + "{0:.2f}".format(self.endtime[case.id()] - self.starttime[case.id()]) + "s)"
151 145
152 if status not in logs: 146 if status not in logs:
153 logs[status] = [] 147 logs[status] = []
154 logs[status].append("RESULTS - %s - Testcase %s: %s%s" % (case.id(), oeid, status, t)) 148 logs[status].append("RESULTS - %s: %s%s" % (case.id(), status, t))
155 report = {'status': status} 149 report = {'status': status}
156 if log: 150 if log:
157 report['log'] = log 151 report['log'] = log
@@ -202,38 +196,19 @@ class OETestRunner(_TestRunner):
202 self._walked_cases = self._walked_cases + 1 196 self._walked_cases = self._walked_cases + 1
203 197
204 def _list_tests_name(self, suite): 198 def _list_tests_name(self, suite):
205 from oeqa.core.decorator.oeid import OETestID
206 from oeqa.core.decorator.oetag import OETestTag 199 from oeqa.core.decorator.oetag import OETestTag
207 200
208 self._walked_cases = 0 201 self._walked_cases = 0
209 202
210 def _list_cases_without_id(logger, case):
211
212 found_id = False
213 if hasattr(case, 'decorators'):
214 for d in case.decorators:
215 if isinstance(d, OETestID):
216 found_id = True
217
218 if not found_id:
219 logger.info('oeid missing for %s' % case.id())
220
221 def _list_cases(logger, case): 203 def _list_cases(logger, case):
222 oeid = None
223 oetag = None 204 oetag = None
224 205
225 if hasattr(case, 'decorators'): 206 if hasattr(case, 'decorators'):
226 for d in case.decorators: 207 for d in case.decorators:
227 if isinstance(d, OETestID): 208 if isinstance(d, OETestTag):
228 oeid = d.oeid
229 elif isinstance(d, OETestTag):
230 oetag = d.oetag 209 oetag = d.oetag
231 210
232 logger.info("%s\t%s\t\t%s" % (oeid, oetag, case.id())) 211 logger.info("%s\t\t%s" % (oetag, case.id()))
233
234 self.tc.logger.info("Listing test cases that don't have oeid ...")
235 self._walk_suite(suite, _list_cases_without_id)
236 self.tc.logger.info("-" * 80)
237 212
238 self.tc.logger.info("Listing all available tests:") 213 self.tc.logger.info("Listing all available tests:")
239 self._walked_cases = 0 214 self._walked_cases = 0
diff --git a/meta/lib/oeqa/core/tests/cases/loader/invalid/oeid.py b/meta/lib/oeqa/core/tests/cases/loader/invalid/oeid.py
deleted file mode 100644
index 038d445931..0000000000
--- a/meta/lib/oeqa/core/tests/cases/loader/invalid/oeid.py
+++ /dev/null
@@ -1,15 +0,0 @@
1# Copyright (C) 2016 Intel Corporation
2# Released under the MIT license (see COPYING.MIT)
3
4from oeqa.core.case import OETestCase
5
6class AnotherIDTest(OETestCase):
7
8 def testAnotherIdGood(self):
9 self.assertTrue(True, msg='How is this possible?')
10
11 def testAnotherIdOther(self):
12 self.assertTrue(True, msg='How is this possible?')
13
14 def testAnotherIdNone(self):
15 self.assertTrue(True, msg='How is this possible?')
diff --git a/meta/lib/oeqa/core/tests/cases/oeid.py b/meta/lib/oeqa/core/tests/cases/oeid.py
deleted file mode 100644
index c2d3d32f2d..0000000000
--- a/meta/lib/oeqa/core/tests/cases/oeid.py
+++ /dev/null
@@ -1,18 +0,0 @@
1# Copyright (C) 2016 Intel Corporation
2# Released under the MIT license (see COPYING.MIT)
3
4from oeqa.core.case import OETestCase
5from oeqa.core.decorator.oeid import OETestID
6
7class IDTest(OETestCase):
8
9 @OETestID(101)
10 def testIdGood(self):
11 self.assertTrue(True, msg='How is this possible?')
12
13 @OETestID(102)
14 def testIdOther(self):
15 self.assertTrue(True, msg='How is this possible?')
16
17 def testIdNone(self):
18 self.assertTrue(True, msg='How is this possible?')
diff --git a/meta/lib/oeqa/core/tests/test_decorators.py b/meta/lib/oeqa/core/tests/test_decorators.py
index f7d11e885a..67dce773bd 100755
--- a/meta/lib/oeqa/core/tests/test_decorators.py
+++ b/meta/lib/oeqa/core/tests/test_decorators.py
@@ -42,29 +42,6 @@ class TestFilterDecorator(TestBase):
42 for test in tests: 42 for test in tests:
43 self._runFilterTest(['oetag'], test[0], test[1], test[2]) 43 self._runFilterTest(['oetag'], test[0], test[1], test[2])
44 44
45 def test_oeid(self):
46 # Get all cases without filtering.
47 filter_all = {}
48 test_all = {'testIdGood', 'testIdOther', 'testIdNone'}
49 msg_all = 'Failed to get all oeid cases without filtering.'
50
51 # Get cases with '101' oeid.
52 filter_good = {'oeid': 101}
53 test_good = {'testIdGood'}
54 msg_good = 'Failed to get just one tes filtering with "101" oeid.'
55
56 # Get cases with an invalid id.
57 filter_invalid = {'oeid':999}
58 test_invalid = set()
59 msg_invalid = 'Failed to filter all test using an invalid oeid.'
60
61 tests = ((filter_all, test_all, msg_all),
62 (filter_good, test_good, msg_good),
63 (filter_invalid, test_invalid, msg_invalid))
64
65 for test in tests:
66 self._runFilterTest(['oeid'], test[0], test[1], test[2])
67
68class TestDependsDecorator(TestBase): 45class TestDependsDecorator(TestBase):
69 modules = ['depends'] 46 modules = ['depends']
70 47
diff --git a/meta/lib/oeqa/core/tests/test_loader.py b/meta/lib/oeqa/core/tests/test_loader.py
index b79b8bad4d..39f2d6e2a7 100755
--- a/meta/lib/oeqa/core/tests/test_loader.py
+++ b/meta/lib/oeqa/core/tests/test_loader.py
@@ -42,7 +42,7 @@ class TestLoader(TestBase):
42 cases_path = self.cases_path 42 cases_path = self.cases_path
43 invalid_path = os.path.join(cases_path, 'loader', 'invalid') 43 invalid_path = os.path.join(cases_path, 'loader', 'invalid')
44 self.cases_path = [self.cases_path, invalid_path] 44 self.cases_path = [self.cases_path, invalid_path]
45 expect = 'Duplicated oeid module found in' 45 expect = 'Duplicated oetag module found in'
46 msg = 'Expected ImportError exception for having duplicated module' 46 msg = 'Expected ImportError exception for having duplicated module'
47 try: 47 try:
48 # Must throw ImportEror because duplicated module 48 # Must throw ImportEror because duplicated module
@@ -55,17 +55,16 @@ class TestLoader(TestBase):
55 self.cases_path = cases_path 55 self.cases_path = cases_path
56 56
57 def test_filter_modules(self): 57 def test_filter_modules(self):
58 expected_modules = {'oeid', 'oetag'} 58 expected_modules = {'oetag'}
59 tc = self._testLoader(modules=expected_modules) 59 tc = self._testLoader(modules=expected_modules)
60 modules = getSuiteModules(tc.suites) 60 modules = getSuiteModules(tc.suites)
61 msg = 'Expected just %s modules' % ', '.join(expected_modules) 61 msg = 'Expected just %s modules' % ', '.join(expected_modules)
62 self.assertEqual(modules, expected_modules, msg=msg) 62 self.assertEqual(modules, expected_modules, msg=msg)
63 63
64 def test_filter_cases(self): 64 def test_filter_cases(self):
65 modules = ['oeid', 'oetag', 'data'] 65 modules = ['oetag', 'data']
66 expected_cases = {'data.DataTest.testDataOk', 66 expected_cases = {'data.DataTest.testDataOk',
67 'oetag.TagTest.testTagGood', 67 'oetag.TagTest.testTagGood'}
68 'oeid.IDTest.testIdGood'}
69 tc = self._testLoader(modules=modules, tests=expected_cases) 68 tc = self._testLoader(modules=modules, tests=expected_cases)
70 cases = set(getSuiteCasesIDs(tc.suites)) 69 cases = set(getSuiteCasesIDs(tc.suites))
71 msg = 'Expected just %s cases' % ', '.join(expected_cases) 70 msg = 'Expected just %s cases' % ', '.join(expected_cases)
@@ -74,7 +73,7 @@ class TestLoader(TestBase):
74 def test_import_from_paths(self): 73 def test_import_from_paths(self):
75 cases_path = self.cases_path 74 cases_path = self.cases_path
76 cases2_path = os.path.join(cases_path, 'loader', 'valid') 75 cases2_path = os.path.join(cases_path, 'loader', 'valid')
77 expected_modules = {'oeid', 'another'} 76 expected_modules = {'another'}
78 self.cases_path = [self.cases_path, cases2_path] 77 self.cases_path = [self.cases_path, cases2_path]
79 tc = self._testLoader(modules=expected_modules) 78 tc = self._testLoader(modules=expected_modules)
80 modules = getSuiteModules(tc.suites) 79 modules = getSuiteModules(tc.suites)