diff options
Diffstat (limited to 'external/poky/meta/lib/oeqa/core/tests')
12 files changed, 123 insertions, 136 deletions
diff --git a/external/poky/meta/lib/oeqa/core/tests/cases/data.py b/external/poky/meta/lib/oeqa/core/tests/cases/data.py index 88003a6a..61f88547 100644 --- a/external/poky/meta/lib/oeqa/core/tests/cases/data.py +++ b/external/poky/meta/lib/oeqa/core/tests/cases/data.py @@ -1,8 +1,11 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# from oeqa.core.case import OETestCase -from oeqa.core.decorator.oetag import OETestTag +from oeqa.core.decorator import OETestTag from oeqa.core.decorator.data import OETestDataDepends class DataTest(OETestCase): diff --git a/external/poky/meta/lib/oeqa/core/tests/cases/depends.py b/external/poky/meta/lib/oeqa/core/tests/cases/depends.py index 17cdd90b..46e7db90 100644 --- a/external/poky/meta/lib/oeqa/core/tests/cases/depends.py +++ b/external/poky/meta/lib/oeqa/core/tests/cases/depends.py @@ -1,5 +1,8 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# from oeqa.core.case import OETestCase from oeqa.core.decorator.depends import OETestDepends diff --git a/external/poky/meta/lib/oeqa/core/tests/cases/loader/invalid/oeid.py b/external/poky/meta/lib/oeqa/core/tests/cases/loader/invalid/oeid.py deleted file mode 100644 index 038d4459..00000000 --- a/external/poky/meta/lib/oeqa/core/tests/cases/loader/invalid/oeid.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) - -from oeqa.core.case import OETestCase - -class AnotherIDTest(OETestCase): - - def testAnotherIdGood(self): - self.assertTrue(True, msg='How is this possible?') - - def testAnotherIdOther(self): - self.assertTrue(True, msg='How is this possible?') - - def testAnotherIdNone(self): - self.assertTrue(True, msg='How is this possible?') diff --git a/external/poky/meta/lib/oeqa/core/tests/cases/loader/valid/another.py b/external/poky/meta/lib/oeqa/core/tests/cases/loader/valid/another.py index c9ffd177..bedc20c8 100644 --- a/external/poky/meta/lib/oeqa/core/tests/cases/loader/valid/another.py +++ b/external/poky/meta/lib/oeqa/core/tests/cases/loader/valid/another.py @@ -1,5 +1,8 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# from oeqa.core.case import OETestCase diff --git a/external/poky/meta/lib/oeqa/core/tests/cases/oeid.py b/external/poky/meta/lib/oeqa/core/tests/cases/oeid.py deleted file mode 100644 index c2d3d32f..00000000 --- a/external/poky/meta/lib/oeqa/core/tests/cases/oeid.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) - -from oeqa.core.case import OETestCase -from oeqa.core.decorator.oeid import OETestID - -class IDTest(OETestCase): - - @OETestID(101) - def testIdGood(self): - self.assertTrue(True, msg='How is this possible?') - - @OETestID(102) - def testIdOther(self): - self.assertTrue(True, msg='How is this possible?') - - def testIdNone(self): - self.assertTrue(True, msg='How is this possible?') diff --git a/external/poky/meta/lib/oeqa/core/tests/cases/oetag.py b/external/poky/meta/lib/oeqa/core/tests/cases/oetag.py index 0cae02e7..52f97dfd 100644 --- a/external/poky/meta/lib/oeqa/core/tests/cases/oetag.py +++ b/external/poky/meta/lib/oeqa/core/tests/cases/oetag.py @@ -1,11 +1,13 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# from oeqa.core.case import OETestCase -from oeqa.core.decorator.oetag import OETestTag +from oeqa.core.decorator import OETestTag class TagTest(OETestCase): - @OETestTag('goodTag') def testTagGood(self): self.assertTrue(True, msg='How is this possible?') @@ -14,5 +16,23 @@ class TagTest(OETestCase): def testTagOther(self): self.assertTrue(True, msg='How is this possible?') + @OETestTag('otherTag', 'multiTag') + def testTagOtherMulti(self): + self.assertTrue(True, msg='How is this possible?') + def testTagNone(self): self.assertTrue(True, msg='How is this possible?') + +@OETestTag('classTag') +class TagClassTest(OETestCase): + @OETestTag('otherTag') + def testTagOther(self): + self.assertTrue(True, msg='How is this possible?') + + @OETestTag('otherTag', 'multiTag') + def testTagOtherMulti(self): + self.assertTrue(True, msg='How is this possible?') + + def testTagNone(self): + self.assertTrue(True, msg='How is this possible?') + diff --git a/external/poky/meta/lib/oeqa/core/tests/cases/timeout.py b/external/poky/meta/lib/oeqa/core/tests/cases/timeout.py index 870c3157..5dfecc7b 100644 --- a/external/poky/meta/lib/oeqa/core/tests/cases/timeout.py +++ b/external/poky/meta/lib/oeqa/core/tests/cases/timeout.py @@ -1,5 +1,8 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# from time import sleep diff --git a/external/poky/meta/lib/oeqa/core/tests/common.py b/external/poky/meta/lib/oeqa/core/tests/common.py index 52b18a1c..88cc758a 100644 --- a/external/poky/meta/lib/oeqa/core/tests/common.py +++ b/external/poky/meta/lib/oeqa/core/tests/common.py @@ -1,5 +1,8 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# import sys import os @@ -27,9 +30,9 @@ class TestBase(unittest.TestCase): directory = os.path.dirname(os.path.abspath(__file__)) self.cases_path = os.path.join(directory, 'cases') - def _testLoader(self, d={}, modules=[], tests=[], filters={}): + def _testLoader(self, d={}, modules=[], tests=[], **kwargs): from oeqa.core.context import OETestContext tc = OETestContext(d, self.logger) tc.loadTests(self.cases_path, modules=modules, tests=tests, - filters=filters) + **kwargs) return tc diff --git a/external/poky/meta/lib/oeqa/core/tests/test_data.py b/external/poky/meta/lib/oeqa/core/tests/test_data.py index 21b6c68b..ac74098b 100755 --- a/external/poky/meta/lib/oeqa/core/tests/test_data.py +++ b/external/poky/meta/lib/oeqa/core/tests/test_data.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# import unittest import logging @@ -20,8 +22,9 @@ class TestData(TestBase): expectedException = "oeqa.core.exception.OEQAMissingVariable" tc = self._testLoader(modules=self.modules) - self.assertEqual(False, tc.runTests().wasSuccessful()) - for test, data in tc.errors: + results = tc.runTests() + self.assertFalse(results.wasSuccessful()) + for test, data in results.errors: expect = False if expectedException in data: expect = True @@ -33,8 +36,9 @@ class TestData(TestBase): d = {'IMAGE' : 'core-image-sato', 'ARCH' : 'arm'} tc = self._testLoader(d=d, modules=self.modules) - self.assertEqual(False, tc.runTests().wasSuccessful()) - for test, data in tc.failures: + results = tc.runTests() + self.assertFalse(results.wasSuccessful()) + for test, data in results.failures: expect = False if expectedError in data: expect = True diff --git a/external/poky/meta/lib/oeqa/core/tests/test_decorators.py b/external/poky/meta/lib/oeqa/core/tests/test_decorators.py index f7d11e88..b798bf7d 100755 --- a/external/poky/meta/lib/oeqa/core/tests/test_decorators.py +++ b/external/poky/meta/lib/oeqa/core/tests/test_decorators.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 - +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# import signal import unittest @@ -12,58 +14,58 @@ setup_sys_path() from oeqa.core.exception import OEQADependency from oeqa.core.utils.test import getCaseMethod, getSuiteCasesNames, getSuiteCasesIDs -class TestFilterDecorator(TestBase): - - def _runFilterTest(self, modules, filters, expect, msg): - tc = self._testLoader(modules=modules, filters=filters) - test_loaded = set(getSuiteCasesNames(tc.suites)) - self.assertEqual(expect, test_loaded, msg=msg) +class TestTagDecorator(TestBase): + def _runTest(self, modules, filterfn, expect): + tc = self._testLoader(modules = modules, tags_filter = filterfn) + test_loaded = set(getSuiteCasesIDs(tc.suites)) + self.assertEqual(expect, test_loaded) def test_oetag(self): - # Get all cases without filtering. - filter_all = {} - test_all = {'testTagGood', 'testTagOther', 'testTagNone'} - msg_all = 'Failed to get all oetag cases without filtering.' - - # Get cases with 'goodTag'. - filter_good = {'oetag':'goodTag'} - test_good = {'testTagGood'} - msg_good = 'Failed to get just one test filtering with "goodTag" oetag.' - - # Get cases with an invalid tag. - filter_invalid = {'oetag':'invalidTag'} - test_invalid = set() - msg_invalid = 'Failed to filter all test using an invalid oetag.' - - tests = ((filter_all, test_all, msg_all), - (filter_good, test_good, msg_good), - (filter_invalid, test_invalid, msg_invalid)) - - for test in tests: - self._runFilterTest(['oetag'], test[0], test[1], test[2]) - - def test_oeid(self): - # Get all cases without filtering. - filter_all = {} - test_all = {'testIdGood', 'testIdOther', 'testIdNone'} - msg_all = 'Failed to get all oeid cases without filtering.' - - # Get cases with '101' oeid. - filter_good = {'oeid': 101} - test_good = {'testIdGood'} - msg_good = 'Failed to get just one tes filtering with "101" oeid.' - - # Get cases with an invalid id. - filter_invalid = {'oeid':999} - test_invalid = set() - msg_invalid = 'Failed to filter all test using an invalid oeid.' - - tests = ((filter_all, test_all, msg_all), - (filter_good, test_good, msg_good), - (filter_invalid, test_invalid, msg_invalid)) - - for test in tests: - self._runFilterTest(['oeid'], test[0], test[1], test[2]) + # get all cases without any filtering + self._runTest(['oetag'], None, { + 'oetag.TagTest.testTagGood', + 'oetag.TagTest.testTagOther', + 'oetag.TagTest.testTagOtherMulti', + 'oetag.TagTest.testTagNone', + 'oetag.TagClassTest.testTagOther', + 'oetag.TagClassTest.testTagOtherMulti', + 'oetag.TagClassTest.testTagNone', + }) + + # exclude any case with tags + self._runTest(['oetag'], lambda tags: tags, { + 'oetag.TagTest.testTagNone', + }) + + # exclude any case with otherTag + self._runTest(['oetag'], lambda tags: "otherTag" in tags, { + 'oetag.TagTest.testTagGood', + 'oetag.TagTest.testTagNone', + 'oetag.TagClassTest.testTagNone', + }) + + # exclude any case with classTag + self._runTest(['oetag'], lambda tags: "classTag" in tags, { + 'oetag.TagTest.testTagGood', + 'oetag.TagTest.testTagOther', + 'oetag.TagTest.testTagOtherMulti', + 'oetag.TagTest.testTagNone', + }) + + # include any case with classTag + self._runTest(['oetag'], lambda tags: "classTag" not in tags, { + 'oetag.TagClassTest.testTagOther', + 'oetag.TagClassTest.testTagOtherMulti', + 'oetag.TagClassTest.testTagNone', + }) + + # include any case with classTag or no tags + self._runTest(['oetag'], lambda tags: tags and "classTag" not in tags, { + 'oetag.TagTest.testTagNone', + 'oetag.TagClassTest.testTagOther', + 'oetag.TagClassTest.testTagOtherMulti', + 'oetag.TagClassTest.testTagNone', + }) class TestDependsDecorator(TestBase): modules = ['depends'] diff --git a/external/poky/meta/lib/oeqa/core/tests/test_loader.py b/external/poky/meta/lib/oeqa/core/tests/test_loader.py index b79b8bad..cb38ac84 100755 --- a/external/poky/meta/lib/oeqa/core/tests/test_loader.py +++ b/external/poky/meta/lib/oeqa/core/tests/test_loader.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 - +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# import os import unittest @@ -13,36 +15,12 @@ from oeqa.core.exception import OEQADependency from oeqa.core.utils.test import getSuiteModules, getSuiteCasesIDs class TestLoader(TestBase): - - def test_fail_empty_filter(self): - filters = {'oetag' : ''} - expect = 'Filter oetag specified is empty' - msg = 'Expected TypeError exception for having invalid filter' - try: - # Must throw TypeError because empty filter - tc = self._testLoader(filters=filters) - self.fail(msg) - except TypeError as e: - result = True if expect in str(e) else False - self.assertTrue(result, msg=msg) - - def test_fail_invalid_filter(self): - filters = {'invalid' : 'good'} - expect = 'filter but not declared in any of' - msg = 'Expected TypeError exception for having invalid filter' - try: - # Must throw TypeError because invalid filter - tc = self._testLoader(filters=filters) - self.fail(msg) - except TypeError as e: - result = True if expect in str(e) else False - self.assertTrue(result, msg=msg) - + @unittest.skip("invalid directory is missing oetag.py") def test_fail_duplicated_module(self): cases_path = self.cases_path invalid_path = os.path.join(cases_path, 'loader', 'invalid') self.cases_path = [self.cases_path, invalid_path] - expect = 'Duplicated oeid module found in' + expect = 'Duplicated oetag module found in' msg = 'Expected ImportError exception for having duplicated module' try: # Must throw ImportEror because duplicated module @@ -55,17 +33,16 @@ class TestLoader(TestBase): self.cases_path = cases_path def test_filter_modules(self): - expected_modules = {'oeid', 'oetag'} + expected_modules = {'oetag'} tc = self._testLoader(modules=expected_modules) modules = getSuiteModules(tc.suites) msg = 'Expected just %s modules' % ', '.join(expected_modules) self.assertEqual(modules, expected_modules, msg=msg) def test_filter_cases(self): - modules = ['oeid', 'oetag', 'data'] + modules = ['oetag', 'data'] expected_cases = {'data.DataTest.testDataOk', - 'oetag.TagTest.testTagGood', - 'oeid.IDTest.testIdGood'} + 'oetag.TagTest.testTagGood'} tc = self._testLoader(modules=modules, tests=expected_cases) cases = set(getSuiteCasesIDs(tc.suites)) msg = 'Expected just %s cases' % ', '.join(expected_cases) @@ -74,7 +51,7 @@ class TestLoader(TestBase): def test_import_from_paths(self): cases_path = self.cases_path cases2_path = os.path.join(cases_path, 'loader', 'valid') - expected_modules = {'oeid', 'another'} + expected_modules = {'another'} self.cases_path = [self.cases_path, cases2_path] tc = self._testLoader(modules=expected_modules) modules = getSuiteModules(tc.suites) diff --git a/external/poky/meta/lib/oeqa/core/tests/test_runner.py b/external/poky/meta/lib/oeqa/core/tests/test_runner.py index a3f3861f..205464cf 100755 --- a/external/poky/meta/lib/oeqa/core/tests/test_runner.py +++ b/external/poky/meta/lib/oeqa/core/tests/test_runner.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 - +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# import unittest import logging |