diff options
| -rw-r--r-- | meta-selftest/lib/oeqa/selftest/cases/external-layer.py | 16 | ||||
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/selftest.py | 51 |
2 files changed, 67 insertions, 0 deletions
diff --git a/meta-selftest/lib/oeqa/selftest/cases/external-layer.py b/meta-selftest/lib/oeqa/selftest/cases/external-layer.py new file mode 100644 index 0000000000..59b1afab7d --- /dev/null +++ b/meta-selftest/lib/oeqa/selftest/cases/external-layer.py | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #from oeqa.selftest.base import oeSelfTest | ||
| 2 | from oeqa.selftest.case import OESelftestTestCase | ||
| 3 | #from oeqa.utils.decorators import testcase | ||
| 4 | |||
| 5 | |||
| 6 | class ImportedTests(OESelftestTestCase): | ||
| 7 | |||
| 8 | def test_unconditional_pass(self): | ||
| 9 | """ | ||
| 10 | Summary: Doesn't check anything, used to check import test from other layers. | ||
| 11 | Expected: 1. Pass unconditionally | ||
| 12 | Product: oe-core | ||
| 13 | Author: Mariano Lopez <mariano.lopez@intel.com | ||
| 14 | """ | ||
| 15 | |||
| 16 | self.assertEqual(True, True, msg = "Impossible to fail this test") | ||
diff --git a/meta/lib/oeqa/selftest/cases/selftest.py b/meta/lib/oeqa/selftest/cases/selftest.py new file mode 100644 index 0000000000..4b3cb14463 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/selftest.py | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | import importlib | ||
| 2 | from oeqa.utils.commands import runCmd | ||
| 3 | import oeqa.selftest | ||
| 4 | from oeqa.selftest.case import OESelftestTestCase | ||
| 5 | from oeqa.core.decorator.oeid import OETestID | ||
| 6 | |||
| 7 | class ExternalLayer(OESelftestTestCase): | ||
| 8 | |||
| 9 | @OETestID(1885) | ||
| 10 | def test_list_imported(self): | ||
| 11 | """ | ||
| 12 | Summary: Checks functionality to import tests from other layers. | ||
| 13 | Expected: 1. File "external-layer.py" must be in | ||
| 14 | oeqa.selftest.__path__ | ||
| 15 | 2. test_unconditional_pas method must exists | ||
| 16 | in ImportedTests class | ||
| 17 | Product: oe-core | ||
| 18 | Author: Mariano Lopez <mariano.lopez@intel.com> | ||
| 19 | """ | ||
| 20 | |||
| 21 | test_file = "external-layer.py" | ||
| 22 | test_module = "oeqa.selftest.cases.external-layer" | ||
| 23 | method_name = "test_unconditional_pass" | ||
| 24 | |||
| 25 | # Check if "external-layer.py" is in oeqa path | ||
| 26 | found_file = search_test_file(test_file) | ||
| 27 | self.assertTrue(found_file, msg="Can't find %s in the oeqa path" % test_file) | ||
| 28 | |||
| 29 | # Import oeqa.selftest.external-layer module and search for | ||
| 30 | # test_unconditional_pass method of ImportedTests class | ||
| 31 | found_method = search_method(test_module, method_name) | ||
| 32 | self.assertTrue(method_name, msg="Can't find %s method" % method_name) | ||
| 33 | |||
| 34 | def search_test_file(file_name): | ||
| 35 | for layer_path in oeqa.selftest.__path__: | ||
| 36 | for _, _, files in os.walk(layer_path): | ||
| 37 | for f in files: | ||
| 38 | if f == file_name: | ||
| 39 | return True | ||
| 40 | return False | ||
| 41 | |||
| 42 | def search_method(module, method): | ||
| 43 | modlib = importlib.import_module(module) | ||
| 44 | for var in vars(modlib): | ||
| 45 | klass = vars(modlib)[var] | ||
| 46 | if isinstance(klass, type(OESelftestTestCase)) and issubclass(klass, OESelftestTestCase): | ||
| 47 | for m in dir(klass): | ||
| 48 | if m == method: | ||
| 49 | return True | ||
| 50 | return False | ||
| 51 | |||
